mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-01-07 09:53:58 +08:00
fix: sniffer port whitelist error
This commit is contained in:
parent
4aeac0e227
commit
0368bb4180
@ -49,6 +49,8 @@ func (sd *SnifferDispatcher) TCPSniff(conn net.Conn, metadata *C.Metadata) {
|
|||||||
for _, portRange := range *sd.portRanges {
|
for _, portRange := range *sd.portRanges {
|
||||||
if !portRange.Contains(uint16(port)) {
|
if !portRange.Contains(uint16(port)) {
|
||||||
return
|
return
|
||||||
|
} else {
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"container/list"
|
"container/list"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/Dreamacro/clash/listener/tun/ipstack/commons"
|
||||||
"net"
|
"net"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -30,7 +31,6 @@ import (
|
|||||||
C "github.com/Dreamacro/clash/constant"
|
C "github.com/Dreamacro/clash/constant"
|
||||||
providerTypes "github.com/Dreamacro/clash/constant/provider"
|
providerTypes "github.com/Dreamacro/clash/constant/provider"
|
||||||
"github.com/Dreamacro/clash/dns"
|
"github.com/Dreamacro/clash/dns"
|
||||||
"github.com/Dreamacro/clash/listener/tun/ipstack/commons"
|
|
||||||
"github.com/Dreamacro/clash/log"
|
"github.com/Dreamacro/clash/log"
|
||||||
T "github.com/Dreamacro/clash/tunnel"
|
T "github.com/Dreamacro/clash/tunnel"
|
||||||
|
|
||||||
@ -924,27 +924,28 @@ func parseSniffer(snifferRaw SnifferRaw) (*Sniffer, error) {
|
|||||||
Force: snifferRaw.Force,
|
Force: snifferRaw.Force,
|
||||||
}
|
}
|
||||||
|
|
||||||
ports := []utils.Range[uint16]{}
|
var ports []utils.Range[uint16]
|
||||||
if len(snifferRaw.Ports) == 0 {
|
if len(snifferRaw.Ports) == 0 {
|
||||||
ports = append(ports, *utils.NewRange[uint16](0, 65535))
|
ports = append(ports, *utils.NewRange[uint16](0, 65535))
|
||||||
} else {
|
} else {
|
||||||
for _, portRange := range snifferRaw.Ports {
|
for _, portRange := range snifferRaw.Ports {
|
||||||
portRaws := strings.Split(portRange, "-")
|
portRaws := strings.Split(portRange, "-")
|
||||||
|
p, err := strconv.ParseUint(portRaws[0], 10, 16)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("%s format error", portRange)
|
||||||
|
}
|
||||||
|
|
||||||
|
start := uint16(p)
|
||||||
if len(portRaws) > 1 {
|
if len(portRaws) > 1 {
|
||||||
p, err := strconv.ParseUint(portRaws[0], 10, 16)
|
p, err = strconv.ParseUint(portRaws[1], 10, 16)
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("%s format error", portRange)
|
|
||||||
}
|
|
||||||
|
|
||||||
start := uint16(p)
|
|
||||||
|
|
||||||
p, err = strconv.ParseUint(portRaws[0], 10, 16)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("%s format error", portRange)
|
return nil, fmt.Errorf("%s format error", portRange)
|
||||||
}
|
}
|
||||||
|
|
||||||
end := uint16(p)
|
end := uint16(p)
|
||||||
ports = append(ports, *utils.NewRange(start, end))
|
ports = append(ports, *utils.NewRange(start, end))
|
||||||
|
} else {
|
||||||
|
ports = append(ports, *utils.NewRange(start, start))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user