Improve: udp NAT type
This commit is contained in:
@ -59,7 +59,7 @@ type ProxyAdapter interface {
|
||||
Name() string
|
||||
Type() AdapterType
|
||||
DialContext(ctx context.Context, metadata *Metadata) (Conn, error)
|
||||
DialUDP(metadata *Metadata) (PacketConn, net.Addr, error)
|
||||
DialUDP(metadata *Metadata) (PacketConn, error)
|
||||
SupportUDP() bool
|
||||
MarshalJSON() ([]byte, error)
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package constant
|
||||
import (
|
||||
"encoding/json"
|
||||
"net"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Socks addr type
|
||||
@ -70,6 +71,17 @@ func (m *Metadata) RemoteAddress() string {
|
||||
return net.JoinHostPort(m.String(), m.DstPort)
|
||||
}
|
||||
|
||||
func (m *Metadata) UDPAddr() *net.UDPAddr {
|
||||
if m.NetWork != UDP || m.DstIP == nil {
|
||||
return nil
|
||||
}
|
||||
port, _ := strconv.Atoi(m.DstPort)
|
||||
return &net.UDPAddr{
|
||||
IP: m.DstIP,
|
||||
Port: port,
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Metadata) String() string {
|
||||
if m.Host != "" {
|
||||
return m.Host
|
||||
|
Reference in New Issue
Block a user