fix: udp panic when server return a domain name

This commit is contained in:
wwqgtxx
2023-05-27 13:43:41 +08:00
parent 4971b9d804
commit 73140ab826
3 changed files with 25 additions and 19 deletions

View File

@ -205,15 +205,16 @@ func (m *Metadata) Pure() *Metadata {
return m
}
func (m *Metadata) AddrPort() netip.AddrPort {
port, _ := strconv.ParseUint(m.DstPort, 10, 16)
return netip.AddrPortFrom(m.DstIP.Unmap(), uint16(port))
}
func (m *Metadata) UDPAddr() *net.UDPAddr {
if m.NetWork != UDP || !m.DstIP.IsValid() {
return nil
}
port, _ := strconv.ParseUint(m.DstPort, 10, 16)
return &net.UDPAddr{
IP: m.DstIP.AsSlice(),
Port: int(port),
}
return net.UDPAddrFromAddrPort(m.AddrPort())
}
func (m *Metadata) String() string {