ssb: No duplicate tunnels.

This commit is contained in:
Cory McWilliams 2024-10-13 18:13:31 -04:00
parent c882bf31ec
commit 29a1478c86

View File

@ -4300,7 +4300,7 @@ void tf_ssb_sync_start(tf_ssb_t* ssb)
bool tf_ssb_tunnel_create(tf_ssb_t* ssb, const char* portal_id, const char* target_id, int connect_flags) bool tf_ssb_tunnel_create(tf_ssb_t* ssb, const char* portal_id, const char* target_id, int connect_flags)
{ {
tf_ssb_connection_t* connection = tf_ssb_connection_get(ssb, portal_id); tf_ssb_connection_t* connection = tf_ssb_connection_get(ssb, portal_id);
if (connection) if (connection && !tf_ssb_connection_get(ssb, target_id))
{ {
JSContext* context = ssb->context; JSContext* context = ssb->context;
int32_t request_number = tf_ssb_connection_next_request_number(connection); int32_t request_number = tf_ssb_connection_next_request_number(connection);
@ -4320,8 +4320,9 @@ bool tf_ssb_tunnel_create(tf_ssb_t* ssb, const char* portal_id, const char* targ
JS_FreeValue(context, message); JS_FreeValue(context, message);
tf_ssb_connection_tunnel_create(ssb, portal_id, request_number, target_id, connect_flags); tf_ssb_connection_tunnel_create(ssb, portal_id, request_number, target_id, connect_flags);
return true;
} }
return connection != NULL; return false;
} }
int tf_ssb_connection_get_flags(tf_ssb_connection_t* connection) int tf_ssb_connection_get_flags(tf_ssb_connection_t* connection)