ssb: We can show what state a connection is in.

This commit is contained in:
Cory McWilliams 2024-11-13 19:15:59 -05:00
parent 62e15e0208
commit 50089f72c6

View File

@ -389,6 +389,23 @@ static void _tf_ssb_start_update_settings(tf_ssb_t* ssb);
static void _tf_ssb_update_settings(tf_ssb_t* ssb); static void _tf_ssb_update_settings(tf_ssb_t* ssb);
static void _tf_ssb_write(tf_ssb_connection_t* connection, void* data, size_t size); static void _tf_ssb_write(tf_ssb_connection_t* connection, void* data, size_t size);
static const char* _tf_ssb_connection_state_to_string(tf_ssb_state_t state)
{
switch (state)
{
case k_tf_ssb_state_invalid: return "invalid";
case k_tf_ssb_state_connected: return "connected";
case k_tf_ssb_state_sent_hello: return "sent hello";
case k_tf_ssb_state_sent_identity: return "sent identity";
case k_tf_ssb_state_verified: return "verified";
case k_tf_ssb_state_server_wait_hello: return "server wait hello";
case k_tf_ssb_state_server_wait_client_identity: return "server wait client identity";
case k_tf_ssb_state_server_verified: return "server verified";
case k_tf_ssb_state_closing: return "closing";
default: return "unknown";
}
}
static void _tf_ssb_add_debug_close(tf_ssb_t* ssb, tf_ssb_connection_t* connection, const char* reason) static void _tf_ssb_add_debug_close(tf_ssb_t* ssb, tf_ssb_connection_t* connection, const char* reason)
{ {
if (!ssb->store_debug_messages) if (!ssb->store_debug_messages)
@ -2731,7 +2748,7 @@ static tf_ssb_connection_t* _tf_ssb_connection_create(
char id[k_id_base64_len]; char id[k_id_base64_len];
tf_ssb_id_bin_to_str(id, sizeof(id), public_key); tf_ssb_id_bin_to_str(id, sizeof(id), public_key);
char reason[1024]; char reason[1024];
snprintf(reason, sizeof(reason), "Already connected to %s (state = %d).", id, connection->state); snprintf(reason, sizeof(reason), "Already connected to %s (%s).", id, _tf_ssb_connection_state_to_string(connection->state));
callback(NULL, reason, user_data); callback(NULL, reason, user_data);
} }
return NULL; return NULL;