mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-06-26 09:25:23 +00:00
32 lines
553 B
Go
32 lines
553 B
Go
package net
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
TCPNetwork = Network("tcp")
|
|
UDPNetwork = Network("udp")
|
|
)
|
|
|
|
type Network string
|
|
|
|
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
|
|
}
|