chore(internal/provider/utils): unexport functions

This commit is contained in:
Quentin McGaw
2022-05-07 17:10:28 +00:00
parent 0ef7b66047
commit da8c104ebd
7 changed files with 12 additions and 35 deletions

View File

@@ -1,15 +1,13 @@
package utils
import (
"errors"
"fmt"
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/vpn"
)
func GetPort(selection settings.ServerSelection,
func getPort(selection settings.ServerSelection,
defaultOpenVPNTCP, defaultOpenVPNUDP, defaultWireguard uint16) (port uint16) {
switch selection.VPN {
case vpn.Wireguard:
@@ -41,24 +39,3 @@ func checkDefined(portName string, port uint16) {
message := fmt.Sprintf("no default %s port is defined!", portName)
panic(message)
}
var ErrInvalidPort = errors.New("invalid port number")
// CheckPortAllowed for custom port used for OpenVPN.
func CheckPortAllowed(port uint16, tcp bool,
allowedTCP, allowedUDP []uint16) (err error) {
allowedPorts := allowedUDP
protocol := constants.UDP
if tcp {
allowedPorts = allowedTCP
protocol = constants.TCP
}
for _, allowedPort := range allowedPorts {
if port == allowedPort {
return nil
}
}
return fmt.Errorf("%w: %d for protocol %s",
ErrInvalidPort, port, protocol)
}