mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-18 23:33:51 +01:00
- Adjusted headerSize calculation to reflect the correct size based on field definitions. - Changed HostLength and PortLength types from uint8 to byte. - Updated PROTOCOL.md to reflect the new header size and structure.
1.4 KiB
1.4 KiB
Stream proxy protocol
This package implements a small header-based handshake that allows an authenticated client to request forwarding to a (host, port) destination.
Header
The on-wire header is a fixed-size binary blob:
Version(8 bytes)HostLength(1 byte)Host(255 bytes, NUL padded)PortLength(1 byte)Port(5 bytes, NUL padded)Checksum(4 bytes, big-endian CRC32)
Total: headerSize = 8 + 1 + 255 + 1 + 5 + 4 = 273 bytes.
Checksum is crc32.ChecksumIEEE(header[0:headerSize-4]).
See StreamRequestHeader.
TCP behavior
- Client establishes a TLS connection to the stream server.
- Client sends exactly one header as a handshake.
- After the handshake, both sides proxy raw TCP bytes between client and destination.
Server reads the header using io.ReadFull to avoid dropping bytes.
See NewTCPClient() and (*TCPServer).redirect().
UDP-over-DTLS behavior
- Client establishes a DTLS connection to the stream server.
- Client sends exactly one header as a handshake.
- After the handshake, both sides proxy raw UDP datagrams:
- client → destination: DTLS payload is written to destination
UDPConn - destination → client: destination payload is written back to the DTLS connection
- client → destination: DTLS payload is written to destination
Responses do not include a header.