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
280
280
}
281
281
282
282
func getProxyRequest (bufConn onet.BufConn ) (string , error ) {
283
+ // We try to identify the used proxy protocols based on the first byte received.
283
284
firstByte , err := bufConn .Peek (1 )
284
285
if err != nil {
285
286
return "" , fmt .Errorf ("reading header failed: %w" , err )
286
287
}
287
288
288
289
switch firstByte [0 ] {
289
290
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.
292
293
case socks .AtypIPv4 , socks .AtypDomainName , socks .AtypIPv6 :
293
294
logger .Debug ("Proxy protocol detected: Shadowsocks" )
294
295
return proxy .ParseShadowsocks (bufConn )
295
296
297
+ // SOCKS5: The first character represents the protocol version (05). See
298
+ // https://datatracker.ietf.org/doc/html/rfc1928#autoid-4.
296
299
case 0x05 :
297
300
logger .Debug ("Proxy protocol detected: SOCKS5" )
298
301
return proxy .ParseSocks (bufConn )
299
302
303
+ // HTTP CONNECT: The first character of the "CONNECT" method ("C").
300
304
case 0x43 :
301
305
logger .Debug ("Proxy protocol detected: HTTP CONNECT" )
302
306
return proxy .ParseHTTP (bufConn )
You can’t perform that action at this time.
0 commit comments