1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-27 22:36:12 -04:00
v2fly/common/net/network.go

32 lines
553 B
Go
Raw Normal View History

2015-10-30 10:56:46 -04:00
package net
2016-01-15 08:34:33 -05:00
import (
"strings"
)
2015-10-30 10:56:46 -04:00
const (
TCPNetwork = Network("tcp")
UDPNetwork = Network("udp")
)
type Network string
2016-01-15 08:34:33 -05: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 10:56:46 -04:00
}