Skip to content

socksocket support for UDP sockets without proxy server #173

Open
@oryanperl

Description

@oryanperl

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):

  1. 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.
  2. 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:

Image

After fix:

Image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions