r/pythonhelp • • 4d ago

python socks5 proxy server lib

is there library wich handless socks5 protocol for me and allows me to decide tru wich socks5 proxy to route each connection and to wich ip wich domain to resolve by giving it functions wich it calls when need to connect/resolve domain tru my proxy

example function that it gives(its not fully python syntax since python typing system is hard to read):

    run(
      ip,port,user,pass,
      resolve(domain)->ip, #called when client tryes to resolve domain and return ip it will get 
      connect(ip)->(ip,port,user,pass) #called when client wants to connect to specific ip and returns ip,port,user,pass of socks5 proxy tru wich it will connect,if user and pass is None connects without them
    )
2 Upvotes

3 comments sorted by

View all comments

1

u/RyanDubois43 4d ago

PySocks only handles client-side, not server, so you want PySocks for connecting but not for building a custom socks5 server. For server with hooks like that, look at python-socks5-server and subclass Socks5ServerHandler to override connect and resolve logic.