Maint: utils.FilterByProtocol function

This commit is contained in:
Quentin McGaw (desktop)
2021-08-23 20:16:29 +00:00
parent f1a82d9d9c
commit f1a6594474
13 changed files with 101 additions and 22 deletions

View File

@@ -11,3 +11,15 @@ func GetProtocol(selection configuration.ServerSelection) (protocol string) {
}
return constants.UDP
}
func FilterByProtocol(selection configuration.ServerSelection,
serverTCP, serverUDP bool) (filtered bool) {
switch selection.VPN {
case constants.Wireguard:
return !serverUDP
default: // OpenVPN
wantTCP := selection.OpenVPN.TCP
wantUDP := !wantTCP
return (wantTCP && !serverTCP) || (wantUDP && !serverUDP)
}
}