chore(settings): remove now unused helpers/messages.go
This commit is contained in:
@@ -1,29 +0,0 @@
|
|||||||
package helpers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ChoicesOrString(choices []string) string {
|
|
||||||
return strings.Join(
|
|
||||||
choices[:len(choices)-1], ", ") +
|
|
||||||
" or " + choices[len(choices)-1]
|
|
||||||
}
|
|
||||||
|
|
||||||
func PortChoicesOrString(ports []uint16) (s string) {
|
|
||||||
switch len(ports) {
|
|
||||||
case 0:
|
|
||||||
return "there is no allowed port"
|
|
||||||
case 1:
|
|
||||||
return "allowed port is " + fmt.Sprint(ports[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
s = "allowed ports are "
|
|
||||||
portStrings := make([]string, len(ports))
|
|
||||||
for i := range ports {
|
|
||||||
portStrings[i] = fmt.Sprint(ports[i])
|
|
||||||
}
|
|
||||||
s += ChoicesOrString(portStrings)
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
@@ -4,9 +4,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/configuration/settings/helpers"
|
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gosettings"
|
"github.com/qdm12/gosettings"
|
||||||
|
"github.com/qdm12/gosettings/validate"
|
||||||
"github.com/qdm12/gotree"
|
"github.com/qdm12/gotree"
|
||||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||||
)
|
)
|
||||||
@@ -77,12 +77,12 @@ func (w WireguardSelection) validate(vpnProvider string) (err error) {
|
|||||||
allowed = []uint16{53, 80, 123, 443, 1194, 65142}
|
allowed = []uint16{53, 80, 123, 443, 1194, 65142}
|
||||||
}
|
}
|
||||||
|
|
||||||
if helpers.IsOneOf(*w.EndpointPort, allowed...) {
|
err = validate.IsOneOf(*w.EndpointPort, allowed...)
|
||||||
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
return fmt.Errorf("%w: %d for VPN service provider %s; %s",
|
return fmt.Errorf("%w: for VPN service provider %s: %w",
|
||||||
ErrWireguardEndpointPortNotAllowed, w.EndpointPort, vpnProvider,
|
ErrWireguardEndpointPortNotAllowed, vpnProvider, err)
|
||||||
helpers.PortChoicesOrString(allowed))
|
|
||||||
default: // Providers not supporting Wireguard
|
default: // Providers not supporting Wireguard
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user