Files
gluetun/internal/provider/utils/protocol.go

27 lines
683 B
Go
Raw Normal View History

package utils
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/vpn"
)
func getProtocol(selection settings.ServerSelection) (protocol string) {
if selection.VPN == vpn.OpenVPN && *selection.OpenVPN.TCP {
return constants.TCP
}
return constants.UDP
}
2021-08-23 20:16:29 +00:00
func filterByProtocol(selection settings.ServerSelection,
2021-08-23 20:16:29 +00:00
serverTCP, serverUDP bool) (filtered bool) {
switch selection.VPN {
case vpn.Wireguard:
2021-08-23 20:16:29 +00:00
return !serverUDP
default: // OpenVPN
wantTCP := *selection.OpenVPN.TCP
2021-08-23 20:16:29 +00:00
wantUDP := !wantTCP
return (wantTCP && !serverTCP) || (wantUDP && !serverUDP)
}
}