ssb: Fix trying to connect to the same stored connection over and over.
This commit is contained in:
parent
e59a00922b
commit
17eba059f0
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "🦀",
|
"emoji": "🦀",
|
||||||
"previous": "&jbL9Ab+XdvWnZbb50yimceFHR7XFDfBSWv9/XrbZ82I=.sha256"
|
"previous": "&BHYyqkjBliajHR0fokZPpBjkB0Ds8kkwEIRHWit0kIk=.sha256"
|
||||||
}
|
}
|
||||||
|
@ -142,12 +142,15 @@ class TfTabConnectionsElement extends LitElement {
|
|||||||
}, {})
|
}, {})
|
||||||
);
|
);
|
||||||
return html`
|
return html`
|
||||||
<button
|
${connection.connected ? html`
|
||||||
class="w3-button w3-theme-d1"
|
<button
|
||||||
@click=${() => tfrpc.rpc.closeConnection(connection.id)}
|
class="w3-button w3-theme-d1"
|
||||||
>
|
@click=${() => tfrpc.rpc.closeConnection(connection.id)}
|
||||||
Close
|
>
|
||||||
</button>
|
Close
|
||||||
|
</button>
|
||||||
|
`
|
||||||
|
: undefined}
|
||||||
${connection.flags.one_shot ? '🔃' : undefined}
|
${connection.flags.one_shot ? '🔃' : undefined}
|
||||||
<tf-user id=${connection.id} .users=${this.users}></tf-user>
|
<tf-user id=${connection.id} .users=${this.users}></tf-user>
|
||||||
${connection.tunnel !== undefined
|
${connection.tunnel !== undefined
|
||||||
|
@ -1356,7 +1356,8 @@ bool tf_ssb_connection_is_client(tf_ssb_connection_t* connection)
|
|||||||
|
|
||||||
bool tf_ssb_connection_is_connected(tf_ssb_connection_t* connection)
|
bool tf_ssb_connection_is_connected(tf_ssb_connection_t* connection)
|
||||||
{
|
{
|
||||||
return connection->state == k_tf_ssb_state_verified || connection->state == k_tf_ssb_state_server_verified;
|
return (connection->state == k_tf_ssb_state_verified || connection->state == k_tf_ssb_state_server_verified) &&
|
||||||
|
!connection->is_closing;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tf_ssb_connection_is_closing(tf_ssb_connection_t* connection)
|
bool tf_ssb_connection_is_closing(tf_ssb_connection_t* connection)
|
||||||
@ -2795,8 +2796,6 @@ static tf_ssb_connection_t* _tf_ssb_connection_create_internal(tf_ssb_t* ssb, co
|
|||||||
connection->next = ssb->connections;
|
connection->next = ssb->connections;
|
||||||
ssb->connections = connection;
|
ssb->connections = connection;
|
||||||
ssb->connections_count++;
|
ssb->connections_count++;
|
||||||
_tf_ssb_notify_connections_changed(ssb, k_tf_ssb_change_create, connection);
|
|
||||||
|
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2847,6 +2846,7 @@ static tf_ssb_connection_t* _tf_ssb_connection_create(
|
|||||||
}
|
}
|
||||||
|
|
||||||
memcpy(connection->serverpub, public_key, sizeof(connection->serverpub));
|
memcpy(connection->serverpub, public_key, sizeof(connection->serverpub));
|
||||||
|
_tf_ssb_notify_connections_changed(ssb, k_tf_ssb_change_create, connection);
|
||||||
|
|
||||||
connection->tcp.data = connection;
|
connection->tcp.data = connection;
|
||||||
uv_tcp_init(ssb->loop, &connection->tcp);
|
uv_tcp_init(ssb->loop, &connection->tcp);
|
||||||
@ -2928,6 +2928,7 @@ tf_ssb_connection_t* tf_ssb_connection_tunnel_create(tf_ssb_t* ssb, const char*
|
|||||||
{
|
{
|
||||||
tunnel->state = k_tf_ssb_state_server_wait_hello;
|
tunnel->state = k_tf_ssb_state_server_wait_hello;
|
||||||
}
|
}
|
||||||
|
_tf_ssb_notify_connections_changed(ssb, k_tf_ssb_change_create, connection);
|
||||||
|
|
||||||
return tunnel;
|
return tunnel;
|
||||||
}
|
}
|
||||||
@ -3058,6 +3059,7 @@ static void _tf_ssb_on_connection(uv_stream_t* stream, int status)
|
|||||||
}
|
}
|
||||||
|
|
||||||
connection->state = k_tf_ssb_state_server_wait_hello;
|
connection->state = k_tf_ssb_state_server_wait_hello;
|
||||||
|
_tf_ssb_notify_connections_changed(ssb, k_tf_ssb_change_create, connection);
|
||||||
_tf_ssb_connection_read_start(connection);
|
_tf_ssb_connection_read_start(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1015,6 +1015,7 @@ static JSValue _tf_ssb_connections(JSContext* context, JSValueConst this_val, in
|
|||||||
int flags = tf_ssb_connection_get_flags(connection);
|
int flags = tf_ssb_connection_get_flags(connection);
|
||||||
JS_SetPropertyStr(context, flags_object, "one_shot", JS_NewBool(context, (flags & k_tf_ssb_connect_flag_one_shot) != 0));
|
JS_SetPropertyStr(context, flags_object, "one_shot", JS_NewBool(context, (flags & k_tf_ssb_connect_flag_one_shot) != 0));
|
||||||
JS_SetPropertyStr(context, object, "flags", flags_object);
|
JS_SetPropertyStr(context, object, "flags", flags_object);
|
||||||
|
JS_SetPropertyStr(context, object, "connected", JS_NewBool(context, tf_ssb_connection_is_connected(connection)));
|
||||||
const char* destroy_reason = tf_ssb_connection_get_destroy_reason(connection);
|
const char* destroy_reason = tf_ssb_connection_get_destroy_reason(connection);
|
||||||
if (destroy_reason)
|
if (destroy_reason)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user