FD Control Protocol
This feature is mainly used for developing Android proxy apps.
The Hysteria client supports sending the file descriptor (fd) of outbound QUIC connections to any process listening on fdControlUnixSocket.
Note: fdControlUnixSocket is currently only effective for outbound QUIC connections. Third-party Android clients using this feature will need to handle additional DNS resolution requests for the Hysteria server domain, or make sure that the server option in the Hysteria client config is an IP address, not a domain.
Roles
- Server: The third-party process listening on fdControlUnixSocket, e.g., the main process of an Android app.
- Client: The Hysteria client process.
Server Implementation
- Listen to a path-based Unix Socket, which must be of type SOCK_STREAM.
- Use accept(2)to accept connections initiated by the client.
- Receive a single fdsent by the client viarecvmsg(2).
- Process the fdreceived in step 3 (e.g., by callingVpnService.protect()) and then close thefd.
- Respond to the client with a single byte, notifying the client to continue operations. It is advised to respond with '\x01'under normal conditions; other values are currently undefined.
- Close the connection established in step 2 - each connection only processes one fd.