Socks5 Proxy: Wrong error returned when using no authentication
If a proxy needs authentication, but we don't set username and password, GLib returns G_IO_ERROR_PROXY_AUTH_FAILED
instead of G_IO_ERROR_PROXY_NEED_AUTH
This is because we don't always announce all AUTH methods GLib supports
gsocks5proxy.c
static gint
set_nego_msg (guint8 *msg, gboolean has_auth)
{
gint len = 3;
msg[0] = SOCKS5_VERSION;
msg[1] = 0x01; /* number of methods supported */
msg[2] = SOCKS5_AUTH_NONE;
/* add support for authentication method */
if (has_auth)
{
msg[1] = 0x02; /* number of methods supported */
msg[3] = SOCKS5_AUTH_USR_PASS;
len++;
}
return len;
}
SOCKS5_AUTH_USR_PASS
is only added if we set a username and password
of course the server answers with SOCKS5_AUTH_NO_ACCEPT
which triggers G_IO_ERROR_PROXY_AUTH_FAILED
.
Instead GLib should always announce SOCKS5_AUTH_USR_PASS
the server can then choose and return SOCKS5_AUTH_USR_PASS
which should then trigger in GLib G_IO_ERROR_PROXY_NEED_AUTH
because no username and password was set