Skip to content

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.

  • TCP: Supported natively.
  • UDP: Supported natively.
    • NAT Type: Full-Cone NAT.
    • Note: Supports SOCKS5 UDP Associate method.

To connect to a remote SOCKS5 server, use the following fields in the socks5 protocol block:

  • user (string): Authentication username. (If the server requires it).
  • password (string): Authentication password.
  • udp (bool): If set to true, yuhaiin will attempt to use SOCKS5 UDP Associate to tunnel UDP traffic.

A SOCKS5 outbound usually starts with a simple layer to define the server’s IP and port.


yuhaiin can act as a SOCKS5 server to provide proxy services to local or remote apps.

  • 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.

The SOCKS5 server must be paired with a listener (usually tcpudp) to define the interface and port it binds to.

{
"name": "My-SOCKS5-Out",
"protocols": [
{ "simple": { "host": "1.2.3.4", "port": 1080 } },
{ "socks5": { "user": "admin", "password": "password", "udp": true } }
]
}
{
"name": "SOCKS5-Server",
"enabled": true,
"tcpudp": { "host": "127.0.0.1:1080" },
"socks5": { "user": "guest", "password": "guest-password", "udp": true }
}

The SOCKS5 implementation supports No Authentication and Username/Password methods. It also supports UDP Associate.

Located in pkg/net/proxy/socks5. It handles both the handshake logic and the framing for data transmission.