SOCKS5
[!NOTE] This document is partially generated by AI.
The SOCKS5 protocol is a versatile proxy protocol that supports various types of traffic and authentication. In yuhaiin, it is supported as both an outbound and an inbound protocol.
Network Support
Section titled “Network Support”- TCP: Supported natively.
- UDP: Supported natively.
- NAT Type: Full-Cone NAT.
- Note: Supports SOCKS5 UDP Associate method.
Client Configuration (Outbound)
Section titled “Client Configuration (Outbound)”To connect to a remote SOCKS5 server, use the following fields in the socks5 protocol block:
Configuration Fields
Section titled “Configuration Fields”user(string): Authentication username. (If the server requires it).password(string): Authentication password.udp(bool): If set totrue,yuhaiinwill attempt to use SOCKS5 UDP Associate to tunnel UDP traffic.
Protocol Chain Context
Section titled “Protocol Chain Context”A SOCKS5 outbound usually starts with a simple layer to define the server’s IP and port.
Server Configuration (Inbound)
Section titled “Server Configuration (Inbound)”yuhaiin can act as a SOCKS5 server to provide proxy services to local or remote apps.
Configuration Fields
Section titled “Configuration Fields”user(string): (Optional) The username that clients must provide to connect.password(string): (Optional) The password for client authentication.udp(bool): Enables or disables the server’s ability to handle UDP traffic via SOCKS5.
Listener Configuration
Section titled “Listener Configuration”The SOCKS5 server must be paired with a listener (usually tcpudp) to define the interface and port it binds to.
Example Configuration
Section titled “Example Configuration”Outbound Example
Section titled “Outbound Example”{ "name": "My-SOCKS5-Out", "protocols": [ { "simple": { "host": "1.2.3.4", "port": 1080 } }, { "socks5": { "user": "admin", "password": "password", "udp": true } } ]}Inbound Example
Section titled “Inbound Example”{ "name": "SOCKS5-Server", "enabled": true, "tcpudp": { "host": "127.0.0.1:1080" }, "socks5": { "user": "guest", "password": "guest-password", "udp": true }}Developer Details
Section titled “Developer Details”Implementation
Section titled “Implementation”The SOCKS5 implementation supports No Authentication and Username/Password methods. It also supports UDP Associate.
Package
Section titled “Package”Located in pkg/net/proxy/socks5. It handles both the handshake logic and the framing for data transmission.