v2ray-core/common/net/network.go

32 lines
553 B
Go
Raw Normal View History

2015-10-30 14:56:46 +00:00
package net
2016-01-15 13:34:33 +00:00
import (
"strings"
)
2015-10-30 14:56:46 +00:00
const (
TCPNetwork = Network("tcp")
UDPNetwork = Network("udp")
)
type Network string
2016-01-15 13:34:33 +00:00
type NetworkList []Network
func NewNetworkList(networks []string) NetworkList {
list := NetworkList(make([]Network, len(networks)))
for idx, network := range networks {
list[idx] = Network(strings.ToLower(strings.TrimSpace(network)))
}
return list
}
func (this *NetworkList) HasNetwork(network Network) bool {
for _, value := range *this {
if string(value) == string(network) {
return true
}
}
return false
2015-10-30 14:56:46 +00:00
}