fix: tuic server return error udp address

This commit is contained in:
wwqgtxx
2023-05-11 22:45:27 +08:00
parent 534282839c
commit f1be9b3f4a
2 changed files with 12 additions and 4 deletions

View File

@ -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