Change: use uint16 for Metadata SrcPort and DstPort

This commit is contained in:
Dreamacro
2023-08-03 23:20:40 +08:00
parent 47b6eb1700
commit c0e51f8556
13 changed files with 63 additions and 58 deletions

View File

@ -3,6 +3,7 @@ package outboundgroup
import (
"fmt"
"net"
"strconv"
"time"
C "github.com/Dreamacro/clash/constant"
@ -16,18 +17,19 @@ func addrToMetadata(rawAddress string) (addr *C.Metadata, err error) {
}
ip := net.ParseIP(host)
p, _ := strconv.ParseUint(port, 10, 16)
if ip == nil {
addr = &C.Metadata{
Host: host,
DstIP: nil,
DstPort: port,
DstPort: C.Port(p),
}
return
} else if ip4 := ip.To4(); ip4 != nil {
addr = &C.Metadata{
Host: "",
DstIP: ip4,
DstPort: port,
DstPort: C.Port(p),
}
return
}
@ -35,7 +37,7 @@ func addrToMetadata(rawAddress string) (addr *C.Metadata, err error) {
addr = &C.Metadata{
Host: "",
DstIP: ip,
DstPort: port,
DstPort: C.Port(p),
}
return
}