refactor: udp
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"net"
|
||||
"net/netip"
|
||||
"strconv"
|
||||
|
||||
M "github.com/sagernet/sing/common/metadata"
|
||||
)
|
||||
|
||||
// Socks addr type
|
||||
@@ -170,6 +172,18 @@ func (m *Metadata) UDPAddr() *net.UDPAddr {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Metadata) Socksaddr() M.Socksaddr {
|
||||
port, _ := strconv.ParseUint(m.DstPort, 10, 16)
|
||||
if m.Host != "" {
|
||||
return M.Socksaddr{
|
||||
Fqdn: m.Host,
|
||||
Port: uint16(port),
|
||||
}
|
||||
} else {
|
||||
return M.SocksaddrFromAddrPort(m.DstIP, uint16(port))
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Metadata) String() string {
|
||||
if m.Host != "" {
|
||||
return m.Host
|
||||
|
||||
Reference in New Issue
Block a user