Browse Source

fix sniff http ipv6 address

comwrg 7 years ago
parent
commit
e52b387483
1 changed files with 7 additions and 2 deletions
  1. 7 2
      common/protocol/http/sniff.go

+ 7 - 2
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
+			}
 		}
 	}