Skip to content

feat: Implement SOCKS4/a CONNECT#108

Open
HellLord77 wants to merge 4 commits intocfal:masterfrom
HellLord77:socks4
Open

feat: Implement SOCKS4/a CONNECT#108
HellLord77 wants to merge 4 commits intocfal:masterfrom
HellLord77:socks4

Conversation

@HellLord77
Copy link

only CONNECT is supported (no BIND)
this could be added to mixed mode

Copilot AI review requested due to automatic review settings February 9, 2026 18:25
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds SOCKS4/SOCKS4a (CONNECT-only) support to the proxy stack by introducing new client/server handlers and wiring them into TCP handler factories and config enums.

Changes:

  • Add Socks4TcpServerHandler and Socks4TcpClientHandler implementing SOCKS4/SOCKS4a CONNECT.
  • Extend client/server config enums and TCP handler factories to support type: socks4.
  • Add a basic SOCKS4 example configuration.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/tcp/tcp_server_handler_factory.rs Wires ServerProxyConfig::Socks4 to the new SOCKS4 server handler.
src/tcp/tcp_client_handler_factory.rs Wires ClientProxyConfig::Socks4 to the new SOCKS4 client handler (with optional local DNS resolution).
src/socks4_handler.rs Implements SOCKS4/SOCKS4a parsing and request/response handling for CONNECT.
src/main.rs Registers the new socks4_handler module for the binary crate.
src/lib.rs Registers the new socks4_handler module for the library crate.
src/config/types/server.rs Adds ServerProxyConfig::Socks4 { dns_enabled } and display formatting.
src/config/types/client.rs Adds ClientProxyConfig::Socks4 { dns_enabled } and protocol name mapping.
examples/socks4_basic.yaml Provides a sample YAML config using type: socks4.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cfal
Copy link
Owner

cfal commented Feb 10, 2026

thanks for the PR! seems reasonable to support socks4/4a. some feedback:

  • this should be part of socks_handler.rs - it should know how to handle 4 or 5
  • dns_enabled is unnecessary, let's just always support it. we should simply return a NetLocation with a hostname and let the normal copy loop handle it

@HellLord77
Copy link
Author

  1. should it be transparent as mixed proxy? or a config to enable only 4/5/both servers? it should be noted that socks4 does not support any kind of auth, so a mixed handler might cause confusion (the USERID field could be implemented as a token auth, but not sure if that is the correct use)
  2. dns_enabled should at least be necessary in client, in case user wants to tunnel through remote sokcs4 only server

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

Successfully merging this pull request may close these issues.

3 participants