Skip to content

Commit

Permalink
Support tor-specific socks error messages
Browse files Browse the repository at this point in the history
The socks port 'ExtendedErrors' flag must be set in the tor
configuration for tor to return these error codes.
  • Loading branch information
stevenengler committed Oct 13, 2021
1 parent e69787d commit 7b12598
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions src/tgen-transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ static TGenEvent _tgentransport_receiveSocksResponseStatus(TGenTransport* transp
return TGEN_EVENT_READ;
} else {
gchar version = transport->socksBuffer->str[0];
gchar status = transport->socksBuffer->str[1];
guchar status = transport->socksBuffer->str[1];

g_string_free(transport->socksBuffer, TRUE);
transport->socksBuffer = NULL;
Expand All @@ -1087,7 +1087,9 @@ static TGenEvent _tgentransport_receiveSocksResponseStatus(TGenTransport* transp
g_string_append_printf(messageBuffer, "our request was not granted by "
"the SOCKS server: error status %X: ", status);

/* error codes: https://en.wikipedia.org/wiki/SOCKS#SOCKS5 */
/* error codes: https://en.wikipedia.org/wiki/SOCKS#SOCKS5
* we also include non-standard tor error codes, which could potentially have a
* different meaning for non-tor clients */
switch(status) {
case 0x01: {
g_string_append_printf(messageBuffer, "general failure");
Expand Down Expand Up @@ -1121,6 +1123,38 @@ static TGenEvent _tgentransport_receiveSocksResponseStatus(TGenTransport* transp
g_string_append_printf(messageBuffer, "address type not supported");
break;
}
case 0xF0: {
g_string_append_printf(messageBuffer, "(tor) onion service descriptor can not be found");
break;
}
case 0xF1: {
g_string_append_printf(messageBuffer, "(tor) onion service descriptor is invalid");
break;
}
case 0xF2: {
g_string_append_printf(messageBuffer, "(tor) onion service introduction failed");
break;
}
case 0xF3: {
g_string_append_printf(messageBuffer, "(tor) onion service rendezvous failed");
break;
}
case 0xF4: {
g_string_append_printf(messageBuffer, "(tor) onion service missing client authorization");
break;
}
case 0xF5: {
g_string_append_printf(messageBuffer, "(tor) onion service wrong client authorization");
break;
}
case 0xF6: {
g_string_append_printf(messageBuffer, "(tor) onion service invalid address");
break;
}
case 0xF7: {
g_string_append_printf(messageBuffer, "(tor) onion service introduction timed out");
break;
}
default: {
g_string_append_printf(messageBuffer, "unknown error");
break;
Expand Down

0 comments on commit 7b12598

Please sign in to comment.