Mux (Yamux)
[!NOTE] This document is partially generated by AI.
The Mux (Multiplexer) protocol allows multiple logical streams to be multiplexed over a single underlying physical connection (like a single TCP connection). yuhaiin uses Yamux for this purpose.
Network Support
Section titled “Network Support”- TCP: Supported (Stream-based).
- UDP: Not supported. Mux is designed to manage multiple streams over a single reliable transport.
Configuration (Dual Role)
Section titled “Configuration (Dual Role)”In both outbound and inbound scenarios, the mux block uses a single primary setting:
Configuration Fields
Section titled “Configuration Fields”concurrency(int): The maximum number of concurrent streams allowed on the underlying connection.- Recommendation: Values between
4and16are common. higher values allow more simultaneous sessions but may increase memory usage.
- Recommendation: Values between
Example Configuration
Section titled “Example Configuration”{ "mux": { "concurrency": 8 }}Developer Details
Section titled “Developer Details”Benefits
Section titled “Benefits”Yamux provides flow control and keep-alive features, making it ideal for maintaining stable connections over unreliable networks. It can be paired with protocols like Shadowsocks or Trojan to add multiplexing capabilities.
Implementation
Section titled “Implementation”yuhaiin uses the hashicorp/yamux library. The implementation is located in pkg/net/proxy/mux.