1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-27 14:26:11 -04:00

doc for network

This commit is contained in:
v2ray 2016-02-06 11:09:53 +01:00
parent 0b20d6fbf3
commit b53fddf229

View File

@ -5,10 +5,14 @@ import (
) )
const ( const (
// TCPNetwork represents the TCP network.
TCPNetwork = Network("tcp") TCPNetwork = Network("tcp")
// UDPNetwork represents the UDP network.
UDPNetwork = Network("udp") UDPNetwork = Network("udp")
) )
// Network represents a communication network on internet.
type Network serial.StringLiteral type Network serial.StringLiteral
func (this Network) AsList() *NetworkList { func (this Network) AsList() *NetworkList {
@ -16,8 +20,10 @@ func (this Network) AsList() *NetworkList {
return &list return &list
} }
// NetworkList is a list of Networks.
type NetworkList []Network type NetworkList []Network
// NewNetworkList construsts a NetWorklist from the given StringListeralList.
func NewNetworkList(networks serial.StringLiteralList) NetworkList { func NewNetworkList(networks serial.StringLiteralList) NetworkList {
list := NetworkList(make([]Network, networks.Len())) list := NetworkList(make([]Network, networks.Len()))
for idx, network := range networks { for idx, network := range networks {
@ -26,6 +32,7 @@ func NewNetworkList(networks serial.StringLiteralList) NetworkList {
return list return list
} }
// HashNetwork returns true if the given network is in this NetworkList.
func (this *NetworkList) HasNetwork(network Network) bool { func (this *NetworkList) HasNetwork(network Network) bool {
for _, value := range *this { for _, value := range *this {
if string(value) == string(network) { if string(value) == string(network) {