1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-07-01 11:35:23 +00:00
This commit is contained in:
Darien Raymond 2017-11-06 22:42:16 +01:00
parent 57648c145c
commit 4761139fbc
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
3 changed files with 5 additions and 1 deletions

View File

@ -41,14 +41,17 @@ func UDPDestination(address Address, port Port) Destination {
} }
} }
// NetAddr returns the network address in this Destination in string form.
func (d Destination) NetAddr() string { func (d Destination) NetAddr() string {
return d.Address.String() + ":" + d.Port.String() return d.Address.String() + ":" + d.Port.String()
} }
// String returns the strings form of this Destination.
func (d Destination) String() string { func (d Destination) String() string {
return d.Network.URLPrefix() + ":" + d.NetAddr() return d.Network.URLPrefix() + ":" + d.NetAddr()
} }
// IsValid returns true if this Destination is valid.
func (d Destination) IsValid() bool { func (d Destination) IsValid() bool {
return d.Network != Network_Unknown return d.Network != Network_Unknown
} }

View File

@ -1,4 +1,4 @@
// Package net contains common network utilities. // Package net is a drop-in replacement to Golang's net package, with some more functionalities.
package net package net
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg net -path Net //go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg net -path Net

View File

@ -2,6 +2,7 @@ package net
import "net" import "net"
// DialTCP is an injectable function. Default to net.DialTCP
var DialTCP = net.DialTCP var DialTCP = net.DialTCP
var DialUDP = net.DialUDP var DialUDP = net.DialUDP
var DialUnix = net.DialUnix var DialUnix = net.DialUnix