File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -280,23 +280,27 @@ func (h *tcpHandler) Handle(ctx context.Context, clientConn transport.StreamConn
280280}
281281
282282func getProxyRequest (bufConn onet.BufConn ) (string , error ) {
283+ // We try to identify the used proxy protocols based on the first byte received.
283284 firstByte , err := bufConn .Peek (1 )
284285 if err != nil {
285286 return "" , fmt .Errorf ("reading header failed: %w" , err )
286287 }
287288
288289 switch firstByte [0 ] {
289290
290- // Shadowsocks address types follow the SOCKS5 address format:
291- // See https://shadowsocks.org/doc/what-is-shadowsocks.html#addressing.
291+ // Shadowsocks: The first character represents the address type. Note that Shadowsocks address types
292+ // follow the SOCKS5 address format. See https://shadowsocks.org/doc/what-is-shadowsocks.html#addressing.
292293 case socks .AtypIPv4 , socks .AtypDomainName , socks .AtypIPv6 :
293294 logger .Debug ("Proxy protocol detected: Shadowsocks" )
294295 return proxy .ParseShadowsocks (bufConn )
295296
297+ // SOCKS5: The first character represents the protocol version (05). See
298+ // https://datatracker.ietf.org/doc/html/rfc1928#autoid-4.
296299 case 0x05 :
297300 logger .Debug ("Proxy protocol detected: SOCKS5" )
298301 return proxy .ParseSocks (bufConn )
299302
303+ // HTTP CONNECT: The first character of the "CONNECT" method ("C").
300304 case 0x43 :
301305 logger .Debug ("Proxy protocol detected: HTTP CONNECT" )
302306 return proxy .ParseHTTP (bufConn )
You can’t perform that action at this time.
0 commit comments