Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tor-specific socks error messages #15

Merged
merged 1 commit into from
Oct 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 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,10 @@ 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 (enabled with the 'ExtendedErrors'
* torrc flag), which could potentially have different meanings for non-tor
* proxies */
switch(status) {
case 0x01: {
g_string_append_printf(messageBuffer, "general failure");
Expand Down Expand Up @@ -1121,6 +1124,38 @@ static TGenEvent _tgentransport_receiveSocksResponseStatus(TGenTransport* transp
g_string_append_printf(messageBuffer, "address type not supported");
break;
}
case 0xF0: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we connect to a non-Tor SOCKS proxy (which I realize is unlikely given tgen's main purpose), is it possible that they send us these error codes but they have a different meaning? Might be worth a comment in the code?

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