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

socksocket support for UDP sockets without proxy server #173

Open
oryanperl opened this issue Jan 21, 2025 · 1 comment
Open

socksocket support for UDP sockets without proxy server #173

oryanperl opened this issue Jan 21, 2025 · 1 comment

Comments

@oryanperl
Copy link

oryanperl commented Jan 21, 2025

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

@oryanperl
Copy link
Author

oryanperl commented Jan 21, 2025

As it now states in the issue content itself:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant