Fix: should not trust address of http.Client (#1616)

This commit is contained in:
Kr328
2021-09-13 23:46:39 +08:00
committed by GitHub
parent d49b38b00f
commit beb88cc46f
2 changed files with 9 additions and 3 deletions

View File

@ -9,6 +9,7 @@ import (
"github.com/Dreamacro/clash/adapter/inbound"
C "github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/transport/socks5"
)
func newClient(source net.Addr, in chan<- C.ConnContext) *http.Client {
@ -25,9 +26,14 @@ func newClient(source net.Addr, in chan<- C.ConnContext) *http.Client {
return nil, errors.New("unsupported network " + network)
}
dstAddr := socks5.ParseAddr(address)
if dstAddr == nil {
return nil, socks5.ErrAddressNotSupported
}
left, right := net.Pipe()
in <- inbound.NewHTTP(address, source, right)
in <- inbound.NewHTTP(dstAddr, source, right)
return left, nil
},