mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 19:56:51 +08:00
fix: http sniffer skip ip
This commit is contained in:
parent
f7162f7f99
commit
6b6921f090
|
@ -3,6 +3,7 @@ package sniffer
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
C "github.com/Dreamacro/clash/constant"
|
C "github.com/Dreamacro/clash/constant"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -88,7 +89,11 @@ func SniffHTTP(b []byte) (*string, error) {
|
||||||
host, _, err := net.SplitHostPort(rawHost)
|
host, _, err := net.SplitHostPort(rawHost)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if addrError, ok := err.(*net.AddrError); ok && strings.Contains(addrError.Err, "missing port") {
|
if addrError, ok := err.(*net.AddrError); ok && strings.Contains(addrError.Err, "missing port") {
|
||||||
host = rawHost
|
if host, _, err = net.SplitHostPort(net.JoinHostPort(rawHost, "80")); err == nil {
|
||||||
|
if net.ParseIP(host) != nil {
|
||||||
|
return nil, fmt.Errorf("host is ip")
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user