diff --git a/apps/ssb.json b/apps/ssb.json index 9db8974e..6949ab38 100644 --- a/apps/ssb.json +++ b/apps/ssb.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "🦀", - "previous": "&XXMkhzapfVH8TnYyi4A+lCq2orE57Z5kStC4AbfX04Q=.sha256" + "previous": "&JVIVaxuqwtqP70qgese6cIMI0gtN4BdJetFLSq8TJzY=.sha256" } diff --git a/apps/ssb/tf-tab-connections.js b/apps/ssb/tf-tab-connections.js index 0068dcc3..e07aa550 100644 --- a/apps/ssb/tf-tab-connections.js +++ b/apps/ssb/tf-tab-connections.js @@ -308,6 +308,12 @@ class TfTabConnectionsElement extends LitElement {
${x.address}:${x.port}
+
+ Last connection: + ${new Date(x.last_success * 1000)} +
${this.render_message(x)} diff --git a/src/ssb.db.c b/src/ssb.db.c index 6fd4083f..36ab1c99 100644 --- a/src/ssb.db.c +++ b/src/ssb.db.c @@ -1888,13 +1888,15 @@ tf_ssb_db_stored_connection_t* tf_ssb_db_get_stored_connections(tf_ssb_t* ssb, i int count = 0; sqlite3_stmt* statement; - if (sqlite3_prepare_v2(db, "SELECT host, port, key FROM connections ORDER BY host, port, key", -1, &statement, NULL) == SQLITE_OK) + if (sqlite3_prepare_v2(db, "SELECT host, port, key, last_attempt, last_success FROM connections ORDER BY host, port, key", -1, &statement, NULL) == SQLITE_OK) { while (sqlite3_step(statement) == SQLITE_ROW) { result = tf_resize_vec(result, sizeof(tf_ssb_db_stored_connection_t) * (count + 1)); result[count] = (tf_ssb_db_stored_connection_t) { .port = sqlite3_column_int(statement, 1), + .last_attempt = sqlite3_column_int64(statement, 3), + .last_success = sqlite3_column_int64(statement, 4), }; snprintf(result[count].address, sizeof(result[count].address), "%s", (const char*)sqlite3_column_text(statement, 0)); snprintf(result[count].pubkey, sizeof(result[count].pubkey), "%s", (const char*)sqlite3_column_text(statement, 2)); diff --git a/src/ssb.db.h b/src/ssb.db.h index c7f40030..431f896e 100644 --- a/src/ssb.db.h +++ b/src/ssb.db.h @@ -340,6 +340,10 @@ typedef struct _tf_ssb_db_stored_connection_t int port; /** The identity. */ char pubkey[k_id_base64_len]; + /** Time of last attempted connection. */ + int64_t last_attempt; + /** Time of last successful connection. */ + int64_t last_success; } tf_ssb_db_stored_connection_t; /** diff --git a/src/ssb.js.c b/src/ssb.js.c index f72fba79..17e267fc 100644 --- a/src/ssb.js.c +++ b/src/ssb.js.c @@ -988,6 +988,8 @@ static void _tf_ssb_stored_connections_after_work(tf_ssb_t* ssb, int status, voi JS_SetPropertyStr(context, connection, "address", JS_NewString(context, work->connections[i].address)); JS_SetPropertyStr(context, connection, "port", JS_NewInt32(context, work->connections[i].port)); JS_SetPropertyStr(context, connection, "pubkey", JS_NewString(context, work->connections[i].pubkey)); + JS_SetPropertyStr(context, connection, "last_attempt", JS_NewInt64(context, work->connections[i].last_attempt)); + JS_SetPropertyStr(context, connection, "last_success", JS_NewInt64(context, work->connections[i].last_success)); JS_SetPropertyUint32(context, result, i, connection); } tf_free(work->connections);