From e52b387483d66e50edbbdb56b6d37a6264c35b42 Mon Sep 17 00:00:00 2001 From: comwrg Date: Mon, 10 Dec 2018 20:37:17 +0800 Subject: [PATCH] fix sniff http ipv6 address --- common/protocol/http/sniff.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/protocol/http/sniff.go b/common/protocol/http/sniff.go index 6aadb48f..d3d189ab 100644 --- a/common/protocol/http/sniff.go +++ b/common/protocol/http/sniff.go @@ -3,6 +3,7 @@ package http import ( "bytes" "errors" + "net" "strings" "v2ray.com/core/common" @@ -77,8 +78,12 @@ func SniffHTTP(b []byte) (*SniffHeader, error) { key := strings.ToLower(string(parts[0])) value := strings.ToLower(string(bytes.Trim(parts[1], " "))) if key == "host" { - domain := strings.Split(value, ":") - sh.host = strings.TrimSpace(domain[0]) + host, _, err := net.SplitHostPort(value) + if err != nil { + sh.host = value + } else { + sh.host = host + } } }