chore(updater): move updater packages to pkg/updaters/<name>

This commit is contained in:
Quentin McGaw
2026-04-23 03:47:57 +00:00
parent 5b01324d5f
commit 13503b0ae0
268 changed files with 1602 additions and 1026 deletions
@@ -6,9 +6,9 @@ import (
"strings"
"github.com/qdm12/gluetun/internal/configuration/settings/helpers"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/provider/privateinternetaccess/presets"
"github.com/qdm12/gluetun/pkg/updaters/constants"
"github.com/qdm12/gosettings"
"github.com/qdm12/gosettings/reader"
"github.com/qdm12/gosettings/validate"
+5 -5
View File
@@ -7,7 +7,7 @@ import (
"strings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/constants/vpn"
"github.com/qdm12/gluetun/pkg/updaters/constants"
"github.com/qdm12/gosettings"
"github.com/qdm12/gosettings/reader"
"github.com/qdm12/gosettings/validate"
@@ -31,9 +31,9 @@ func (p *Provider) validate(vpnType string, filterChoicesGetter FilterChoicesGet
// Validate Name
var validNames []string
switch vpnType {
case vpn.AmneziaWg:
case constants.AmneziaWg:
validNames = []string{providers.Custom}
case vpn.OpenVPN:
case constants.OpenVPN:
validNames = providers.AllWithCustom()
validNames = append(validNames, "pia") // Retro-compatibility
// Remove Mullvad since it no longer supports OpenVPN as of January 15th, 2026
@@ -41,7 +41,7 @@ func (p *Provider) validate(vpnType string, filterChoicesGetter FilterChoicesGet
validNames[mullvadIndex], validNames[len(validNames)-1] = validNames[len(validNames)-1], validNames[mullvadIndex]
validNames = validNames[:len(validNames)-1]
sort.Strings(validNames)
case vpn.Wireguard:
case constants.Wireguard:
validNames = []string{
providers.Airvpn,
providers.Custom,
@@ -122,7 +122,7 @@ func (p *Provider) read(r *reader.Reader, vpnType string) (err error) {
func readVPNServiceProvider(r *reader.Reader, vpnType string) (vpnProvider string) {
vpnProvider = r.String("VPN_SERVICE_PROVIDER", reader.RetroKeys("VPNSP"))
if vpnProvider == "" {
if vpnType != vpn.Wireguard && r.Get("OPENVPN_CUSTOM_CONFIG") != nil {
if vpnType != constants.Wireguard && r.Get("OPENVPN_CUSTOM_CONFIG") != nil {
// retro compatibility
return providers.Custom
}
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"fmt"
"path/filepath"
"github.com/qdm12/gluetun/internal/publicip/api"
"github.com/qdm12/gluetun/pkg/publicip/api"
"github.com/qdm12/gosettings"
"github.com/qdm12/gosettings/reader"
"github.com/qdm12/gotree"
@@ -8,8 +8,8 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings/helpers"
"github.com/qdm12/gluetun/internal/configuration/settings/validation"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/constants/vpn"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/pkg/updaters/constants"
"github.com/qdm12/gosettings"
"github.com/qdm12/gosettings/reader"
"github.com/qdm12/gosettings/validate"
@@ -75,7 +75,7 @@ func (ss *ServerSelection) validate(vpnServiceProvider string,
filterChoicesGetter FilterChoicesGetter, warner Warner,
) (err error) {
switch ss.VPN {
case vpn.AmneziaWg, vpn.OpenVPN, vpn.Wireguard:
case constants.AmneziaWg, constants.OpenVPN, constants.Wireguard:
default:
return fmt.Errorf("VPN type is not valid: %s", ss.VPN)
}
@@ -108,7 +108,7 @@ func (ss *ServerSelection) validate(vpnServiceProvider string,
return fmt.Errorf("for VPN service provider %s: %w", vpnServiceProvider, err)
}
if ss.VPN == vpn.OpenVPN {
if ss.VPN == constants.OpenVPN {
err = ss.OpenVPN.validate(vpnServiceProvider)
if err != nil {
return fmt.Errorf("OpenVPN server selection settings: %w", err)
@@ -324,7 +324,7 @@ func (ss *ServerSelection) overrideWith(other ServerSelection) {
}
func (ss *ServerSelection) setDefaults(vpnProvider string, portForwardingEnabled bool) {
ss.VPN = gosettings.DefaultComparable(ss.VPN, vpn.OpenVPN)
ss.VPN = gosettings.DefaultComparable(ss.VPN, constants.OpenVPN)
ss.OwnedOnly = gosettings.DefaultPointer(ss.OwnedOnly, false)
ss.FreeOnly = gosettings.DefaultPointer(ss.FreeOnly, false)
ss.PremiumOnly = gosettings.DefaultPointer(ss.PremiumOnly, false)
@@ -414,7 +414,7 @@ func (ss ServerSelection) toLinesNode() (node *gotree.Node) {
node.Appendf("Port forwarding only servers: yes")
}
if ss.VPN == vpn.OpenVPN {
if ss.VPN == constants.OpenVPN {
node.AppendNode(ss.OpenVPN.toLinesNode())
} else {
node.AppendNode(ss.Wireguard.toLinesNode())
@@ -506,7 +506,7 @@ func (ss *ServerSelection) read(r *reader.Reader,
return err
}
amneziawg := ss.VPN == vpn.AmneziaWg
amneziawg := ss.VPN == constants.AmneziaWg
err = ss.Wireguard.read(r, amneziawg)
if err != nil {
return err
+2 -2
View File
@@ -5,9 +5,9 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings/helpers"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/constants/vpn"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/pprof"
"github.com/qdm12/gluetun/pkg/updaters/constants"
"github.com/qdm12/gosettings/reader"
"github.com/qdm12/gotree"
)
@@ -175,7 +175,7 @@ func (s Settings) Warnings() (warnings []string) {
}
if helpers.IsOneOf(s.VPN.Provider.Name, providers.SlickVPN) &&
s.VPN.Type == vpn.OpenVPN {
s.VPN.Type == constants.OpenVPN {
warnings = append(warnings, "OpenVPN 2.5 and 2.6 use OpenSSL 3 "+
"which prohibits the usage of weak security in today's standards. "+
s.VPN.Provider.Name+" uses weak security which is out "+
@@ -3,7 +3,7 @@ package settings
import (
"strings"
"github.com/qdm12/gluetun/internal/provider/surfshark/servers"
"github.com/qdm12/gluetun/pkg/updaters/providers/surfshark/servers"
)
func surfsharkRetroRegion(selection ServerSelection) (
@@ -3,7 +3,7 @@ package validation
import (
"sort"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/pkg/updaters/models"
)
func sortedInsert(ss []string, s string) []string {
@@ -1,7 +1,7 @@
package validation
import (
"github.com/qdm12/gluetun/internal/provider/surfshark/servers"
"github.com/qdm12/gluetun/pkg/updaters/providers/surfshark/servers"
)
// TODO remove in v4.
+9 -9
View File
@@ -3,7 +3,7 @@ package settings
import (
"fmt"
"github.com/qdm12/gluetun/internal/constants/vpn"
"github.com/qdm12/gluetun/pkg/updaters/constants"
"github.com/qdm12/gosettings"
"github.com/qdm12/gosettings/reader"
"github.com/qdm12/gosettings/validate"
@@ -35,7 +35,7 @@ type VPN struct {
// TODO v4 remove pointer for receiver (because of Surfshark).
func (v *VPN) Validate(filterChoicesGetter FilterChoicesGetter, ipv6Supported bool, warner Warner) (err error) {
// Validate Type
validVPNTypes := []string{vpn.AmneziaWg, vpn.OpenVPN, vpn.Wireguard}
validVPNTypes := []string{constants.AmneziaWg, constants.OpenVPN, constants.Wireguard}
if err = validate.IsOneOf(v.Type, validVPNTypes...); err != nil {
return fmt.Errorf("VPN type is not valid: %w", err)
}
@@ -46,17 +46,17 @@ func (v *VPN) Validate(filterChoicesGetter FilterChoicesGetter, ipv6Supported bo
}
switch v.Type {
case vpn.AmneziaWg:
case constants.AmneziaWg:
err = v.AmneziaWg.validate(v.Provider.Name, ipv6Supported)
if err != nil {
return fmt.Errorf("AmneziaWG settings: %w", err)
}
case vpn.OpenVPN:
case constants.OpenVPN:
err := v.OpenVPN.validate(v.Provider.Name)
if err != nil {
return fmt.Errorf("OpenVPN settings: %w", err)
}
case vpn.Wireguard:
case constants.Wireguard:
const amneziawg = false
err := v.Wireguard.validate(v.Provider.Name, ipv6Supported, amneziawg)
if err != nil {
@@ -97,7 +97,7 @@ func (v *VPN) OverrideWith(other VPN) {
}
func (v *VPN) setDefaults() {
v.Type = gosettings.DefaultComparable(v.Type, vpn.OpenVPN)
v.Type = gosettings.DefaultComparable(v.Type, constants.OpenVPN)
v.Provider.setDefaults()
v.AmneziaWg.setDefaults(v.Provider.Name)
v.OpenVPN.setDefaults(v.Provider.Name)
@@ -117,11 +117,11 @@ func (v VPN) toLinesNode() (node *gotree.Node) {
node.AppendNode(v.Provider.toLinesNode())
switch v.Type {
case vpn.AmneziaWg:
case constants.AmneziaWg:
node.AppendNode(v.AmneziaWg.toLinesNode())
case vpn.OpenVPN:
case constants.OpenVPN:
node.AppendNode(v.OpenVPN.toLinesNode())
case vpn.Wireguard:
case constants.Wireguard:
node.AppendNode(v.Wireguard.toLinesNode())
}
node.AppendNode(v.PMTUD.toLinesNode())