Description
In order to allow a smooth and frictionless transition from socket.socket
into socks.socksocket
, socksocket
needs to support both using and not using proxy server, when no proxy server is set, the original socket.socket
behaviour needs to remain intact.
When using socks.socksocket
with a udp socket and no proxy server, the socket can't be used as the socket tries to call socksocket.bind
in order to initialize a _proxyconn
.
when no proxy server is used this is not needed and causes an error in one of two ways (depending on the flow):
- Trying to send socks header to a non socks address (sock address isn't set). This error happens on the first usage of the socket.
- when trying to re-use the socket as when no proxy is set, the original
socket.socket.bind
is called, which fails after consecutive calls (calling.bind(...)
for an already bound socket). This error happens on all consecutive usages of the same socket
Before fix:
After fix:
To perform the fix - check if a proxy is set or not in the sending and receiving bottlenecks (sendto
, recvfrom
and only call bind
when a proxy is set.
PR is created here:
#174
If prefered i attached a git patch file:
0001-Support-udp-sockets-without-proxying.patch