mirror of
https://github.com/qdm12/gluetun.git
synced 2025-12-11 13:56:50 -06:00
28 lines
727 B
Go
28 lines
727 B
Go
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.Protocol == constants.TCP {
|
|
return constants.TCP
|
|
}
|
|
return constants.UDP
|
|
}
|
|
|
|
func filterByProtocol(selection settings.ServerSelection,
|
|
serverTCP, serverUDP bool,
|
|
) (filtered bool) {
|
|
switch selection.VPN {
|
|
case vpn.Wireguard:
|
|
return !serverUDP
|
|
default: // OpenVPN
|
|
wantTCP := selection.OpenVPN.Protocol == constants.TCP
|
|
wantUDP := !wantTCP
|
|
return (wantTCP && !serverTCP) || (wantUDP && !serverUDP)
|
|
}
|
|
}
|