Try to respond to tunnel errors I'm seeing instead of forwarding them over the tunnel, which obviously won't work. Allow creating multiple connections to the same ID if it's for the sake of a tunnel. I think this explains timeouts I'm seeing with tunnels. More error handling, too. C'mon, fix tunnels.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4409 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
fef88e2032
commit
d72ba81a67
27
src/ssb.c
27
src/ssb.c
@ -2477,17 +2477,27 @@ static void _tf_ssb_connection_tunnel_callback(
|
||||
void* user_data)
|
||||
{
|
||||
tf_ssb_connection_t* tunnel = user_data;
|
||||
if (flags & k_ssb_rpc_flag_end_error)
|
||||
{
|
||||
tf_ssb_connection_rpc_send(
|
||||
connection,
|
||||
flags,
|
||||
-request_number,
|
||||
(const uint8_t*)"false",
|
||||
strlen("false"),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
tf_ssb_connection_close(tunnel);
|
||||
}
|
||||
else
|
||||
{
|
||||
_tf_ssb_connection_on_tcp_recv_internal(tunnel, message, size);
|
||||
}
|
||||
}
|
||||
|
||||
tf_ssb_connection_t* tf_ssb_connection_tunnel_create(tf_ssb_t* ssb, const char* portal_id, int32_t request_number, const char* target_id)
|
||||
{
|
||||
if (tf_ssb_connection_get(ssb, target_id))
|
||||
{
|
||||
/* Already have a possibly more direct connection to target. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tf_ssb_connection_t* connection = tf_ssb_connection_get(ssb, portal_id);
|
||||
|
||||
JSContext* context = ssb->context;
|
||||
@ -2975,6 +2985,11 @@ tf_ssb_connection_t* tf_ssb_connection_get(tf_ssb_t* ssb, const char* id)
|
||||
tf_ssb_id_str_to_bin(pub, id);
|
||||
for (tf_ssb_connection_t* connection = ssb->connections; connection; connection = connection->next)
|
||||
{
|
||||
if (connection->tunnel_connection)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (memcmp(connection->serverpub, pub, k_id_bin_len) == 0)
|
||||
{
|
||||
return connection;
|
||||
|
@ -376,6 +376,10 @@ static void _tf_ssb_rpc_tunnel_connect(tf_ssb_connection_t* connection, uint8_t
|
||||
JS_FreeValue(context, message);
|
||||
JS_FreeCString(context, portal_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
tf_ssb_connection_rpc_send_error(connection, flags, -request_number, "Connection not found.");
|
||||
}
|
||||
JS_FreeCString(context, target_str);
|
||||
}
|
||||
else if (!JS_IsUndefined(origin) &&
|
||||
|
Loading…
Reference in New Issue
Block a user