diff options
-rw-r--r-- | src/fastd.c | 3 | ||||
-rw-r--r-- | src/fastd.h | 2 | ||||
-rw-r--r-- | src/peer.c | 1 | ||||
-rw-r--r-- | src/peer.h | 1 | ||||
-rw-r--r-- | src/status.c | 4 |
5 files changed, 11 insertions, 0 deletions
diff --git a/src/fastd.c b/src/fastd.c index fcefc6b..1bb4caa 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -478,6 +478,9 @@ static inline void init(int argc, char *argv[]) { pr_info("fastd " FASTD_VERSION " starting"); + fastd_update_time(); + ctx.started = ctx.now; + fastd_cap_init(); init_sockets(); diff --git a/src/fastd.h b/src/fastd.h index f38b9e8..93788bd 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -257,6 +257,8 @@ struct fastd_context { char *ifname; /**< The actual interface name */ + int64_t started; /**< The timestamp when fastd was started */ + int64_t now; /**< The current monotonous timestamp in microseconds after an arbitrary point in time */ uint64_t next_peer_id; /**< An monotonously increasing ID peers are identified with in some components */ @@ -843,6 +843,7 @@ void fastd_peer_set_established(fastd_peer_t *peer) { return; peer->state = STATE_ESTABLISHED; + peer->established = ctx.now; on_establish(peer); pr_info("connection with %P established.", peer); } @@ -89,6 +89,7 @@ struct fastd_peer { fastd_timeout_t last_handshake_response_timeout; /**< All handshakes from last_handshake_address will be ignored until this timeout has occured */ fastd_peer_address_t last_handshake_response_address; /**< The address the last handshake was received from */ + int64_t established; /**< The time this peer connection has been established */ fastd_timeout_t establish_handshake_timeout; /**< A timeout during which all handshakes for this peer will be ignored after a new connection has been established */ const char *config_source_dir; /**< The directory this peer's configuration was loaded from */ diff --git a/src/status.c b/src/status.c index 0e688a5..fd34747 100644 --- a/src/status.c +++ b/src/status.c @@ -115,6 +115,8 @@ static json_object * dump_peer(const fastd_peer_t *peer) { if (fastd_peer_is_established(peer)) { connection = json_object_new_object(); + json_object_object_add(connection, "established", json_object_new_int64(ctx.now - peer->established)); + struct json_object *method = NULL; const fastd_method_info_t *method_info = conf.protocol->get_current_method(peer); @@ -158,6 +160,8 @@ static json_object * dump_peer(const fastd_peer_t *peer) { static void dump_status(int fd) { struct json_object *json = json_object_new_object(); + json_object_object_add(json, "uptime", json_object_new_int64(ctx.now - ctx.started)); + json_object_object_add(json, "statistics", dump_stats(&ctx.stats)); struct json_object *peers = json_object_new_object(); |