diff --git a/proxy/http/server.go b/proxy/http/server.go index e66f5493..7c20e20f 100644 --- a/proxy/http/server.go +++ b/proxy/http/server.go @@ -5,7 +5,7 @@ import ( "net" "net/http" - "github.com/Dreamacro/clash/adapters/inbound" + adapters "github.com/Dreamacro/clash/adapters/inbound" "github.com/Dreamacro/clash/log" "github.com/Dreamacro/clash/tunnel" ) @@ -56,7 +56,7 @@ func (l *HttpListener) Address() string { func handleConn(conn net.Conn) { br := bufio.NewReader(conn) request, err := http.ReadRequest(br) - if err != nil { + if err != nil || !request.URL.IsAbs() { conn.Close() return } diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index 77e81058..d98ec40a 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -115,6 +115,11 @@ func (t *Tunnel) handleConn(localConn C.ServerAdapter) { defer localConn.Close() metadata := localConn.Metadata() + if !metadata.Valid() { + log.Warnln("[Metadata] not valid: %#v", metadata) + return + } + if t.needLookupIP(metadata) { host, exist := t.resolver.IPToHost(*metadata.IP) if exist { @@ -138,11 +143,6 @@ func (t *Tunnel) handleConn(localConn C.ServerAdapter) { } } - if !metadata.Valid() { - log.Warnln("[Metadata] not valid: %#v", metadata) - return - } - remoConn, err := proxy.Generator(metadata) if err != nil { log.Warnln("Proxy[%s] connect [%s --> %s] error: %s", proxy.Name(), metadata.SourceIP.String(), metadata.String(), err.Error())