mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 03:32:33 +08:00
fix: tuic server return error udp address
This commit is contained in:
parent
534282839c
commit
f1be9b3f4a
|
@ -465,6 +465,11 @@ func NewAddress(metadata *C.Metadata) Address {
|
|||
}
|
||||
|
||||
func NewAddressNetAddr(addr net.Addr) (Address, error) {
|
||||
if addr, ok := addr.(interface{ AddrPort() netip.AddrPort }); ok {
|
||||
if addrPort := addr.AddrPort(); addrPort.IsValid() { // sing's M.Socksaddr maybe return an invalid AddrPort if it's a DomainName
|
||||
return NewAddressAddrPort(addrPort), nil
|
||||
}
|
||||
}
|
||||
addrStr := addr.String()
|
||||
if addrPort, err := netip.ParseAddrPort(addrStr); err == nil {
|
||||
return NewAddressAddrPort(addrPort), nil
|
||||
|
|
|
@ -44,10 +44,13 @@ func handleUDPToLocal(packet C.UDPPacket, pc N.EnhancePacketConn, key string, oA
|
|||
_fromUDPAddr := *fromUDPAddr
|
||||
fromUDPAddr = &_fromUDPAddr // make a copy
|
||||
if fromAddr, ok := netip.AddrFromSlice(fromUDPAddr.IP); ok {
|
||||
if fAddr.IsValid() && (oAddr.Unmap() == fromAddr.Unmap()) {
|
||||
fromUDPAddr.IP = fAddr.Unmap().AsSlice()
|
||||
} else {
|
||||
fromUDPAddr.IP = fromAddr.Unmap().AsSlice()
|
||||
fromAddr = fromAddr.Unmap()
|
||||
if fAddr.IsValid() && (oAddr.Unmap() == fromAddr) {
|
||||
fromAddr = fAddr.Unmap()
|
||||
}
|
||||
fromUDPAddr.IP = fromAddr.AsSlice()
|
||||
if fromAddr.Is4() {
|
||||
fromUDPAddr.Zone = "" // only ipv6 can have the zone
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user