Redir
[!NOTE] This document is partially generated by AI.
Redir is a traditional transparent proxying method used primarily on Linux systems. It is functionally similar to TProxy but handles packet redirection slightly differently. In yuhaiin, it is an inbound-only protocol.
Network Support
Section titled “Network Support”- TCP: Supported (Intercepted and proxied).
- UDP: Supported (Intercepted and proxied).
- NAT Type: Full-Cone NAT.
Inbound Configuration
Section titled “Inbound Configuration”The redir configuration is extremely simple:
Configuration Fields
Section titled “Configuration Fields”host(string): The address and port where the redirection listener will bind (e.g.,0.0.0.0:60081).
Listener Configuration
Section titled “Listener Configuration”A Redir inbound must be paired with a tcpudp listener.
Example Configuration
Section titled “Example Configuration”{ "name": "Linux-Redir", "enabled": true, "tcpudp": { "host": "127.0.0.1:60081" }, "redir": { "host": "127.0.0.1:60081" }}Developer Details
Section titled “Developer Details”Mechanism
Section titled “Mechanism”Redir uses destination NAT (DNAT) rules in iptables to redirect traffic to a local port. The yuhaiin listener then uses the getsockopt syscall with SO_ORIGINAL_DST to retrieve the intended destination address.
Support
Section titled “Support”Like TProxy, Redir is primarily intended for Linux environments.
Implementation
Section titled “Implementation”Detailed implementation can be found in pkg/net/proxy/redir.