mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-12-28 21:15:46 -05:00
fix destination from addr
This commit is contained in:
@@ -17,8 +17,15 @@ type Destination interface {
|
||||
IsUDP() bool // True if destination is reachable via UDP
|
||||
}
|
||||
|
||||
func TCPDestinationFromAddr(addr *net.TCPAddr) Destination {
|
||||
return TCPDestination(IPAddress(addr.IP), Port(addr.Port))
|
||||
func DestinationFromAddr(addr net.Addr) Destination {
|
||||
switch addr := addr.(type) {
|
||||
case *net.TCPAddr:
|
||||
return TCPDestination(IPAddress(addr.IP), Port(addr.Port))
|
||||
case *net.UDPAddr:
|
||||
return UDPDestination(IPAddress(addr.IP), Port(addr.Port))
|
||||
default:
|
||||
panic("Unknown address type.")
|
||||
}
|
||||
}
|
||||
|
||||
// TCPDestination creates a TCP destination with given address
|
||||
@@ -26,10 +33,6 @@ func TCPDestination(address Address, port Port) Destination {
|
||||
return &tcpDestination{address: address, port: port}
|
||||
}
|
||||
|
||||
func UDPDestinationFromAddr(addr *net.UDPAddr) Destination {
|
||||
return UDPDestination(IPAddress(addr.IP), Port(addr.Port))
|
||||
}
|
||||
|
||||
// UDPDestination creates a UDP destination with given address
|
||||
func UDPDestination(address Address, port Port) Destination {
|
||||
return &udpDestination{address: address, port: port}
|
||||
|
||||
Reference in New Issue
Block a user