Feature: SOCKS4/SOCKS4A Inbound Compatible Support (#1491)

This commit is contained in:
xᴊᴀsᴏɴʟʏᴜ
2021-07-18 16:09:09 +08:00
committed by GitHub
parent 46f4f84442
commit a461c2306a
5 changed files with 241 additions and 11 deletions

View File

@ -9,6 +9,7 @@ import (
C "github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/listener/http"
"github.com/Dreamacro/clash/listener/socks"
"github.com/Dreamacro/clash/transport/socks4"
"github.com/Dreamacro/clash/transport/socks5"
)
@ -58,10 +59,12 @@ func handleConn(conn net.Conn, in chan<- C.ConnContext, cache *cache.Cache) {
return
}
if head[0] == socks5.Version {
socks.HandleSocks(bufConn, in)
return
switch head[0] {
case socks4.Version:
socks.HandleSocks4(bufConn, in)
case socks5.Version:
socks.HandleSocks5(bufConn, in)
default:
http.HandleConn(bufConn, in, cache)
}
http.HandleConn(bufConn, in, cache)
}