mirror of
https://github.com/qdm12/gluetun.git
synced 2026-07-25 11:56:24 +02:00
chore(updater): move updater packages to pkg/updaters/<name>
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gluetun/internal/constants/vpn"
|
||||
"github.com/qdm12/gluetun/pkg/updaters/constants"
|
||||
)
|
||||
|
||||
func (l *Loop) cleanup() {
|
||||
@@ -49,9 +49,9 @@ func (l *Loop) cleanup() {
|
||||
|
||||
func getVPNInterface(settings settings.VPN) string {
|
||||
switch settings.Type {
|
||||
case vpn.OpenVPN:
|
||||
case constants.OpenVPN:
|
||||
return settings.OpenVPN.Interface
|
||||
case vpn.Wireguard:
|
||||
case constants.Wireguard:
|
||||
return settings.Wireguard.Interface
|
||||
default:
|
||||
panic("invalid VPN type: " + settings.Type)
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
portforward "github.com/qdm12/gluetun/internal/portforward"
|
||||
"github.com/qdm12/gluetun/internal/provider"
|
||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||
umodels "github.com/qdm12/gluetun/pkg/updaters/models"
|
||||
)
|
||||
|
||||
type Firewall interface {
|
||||
@@ -46,7 +47,7 @@ type Provider interface {
|
||||
OpenVPNConfig(connection models.Connection, settings settings.OpenVPN, ipv6Supported bool) (lines []string)
|
||||
Name() string
|
||||
FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error)
|
||||
servers []umodels.Server, err error)
|
||||
}
|
||||
|
||||
type PortForwarder interface {
|
||||
@@ -57,7 +58,7 @@ type PortForwarder interface {
|
||||
}
|
||||
|
||||
type Storage interface {
|
||||
FilterServers(provider string, selection settings.ServerSelection) (servers []models.Server, err error)
|
||||
FilterServers(provider string, selection settings.ServerSelection) (servers []umodels.Server, err error)
|
||||
}
|
||||
|
||||
type NetLinker interface {
|
||||
|
||||
@@ -2,8 +2,8 @@ package vpn
|
||||
|
||||
import (
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gluetun/internal/constants/vpn"
|
||||
"github.com/qdm12/gluetun/internal/netlink"
|
||||
"github.com/qdm12/gluetun/pkg/updaters/constants"
|
||||
)
|
||||
|
||||
func (l *Loop) isIPv6Used(settings settings.VPN) bool {
|
||||
@@ -11,14 +11,14 @@ func (l *Loop) isIPv6Used(settings settings.VPN) bool {
|
||||
return false
|
||||
}
|
||||
switch settings.Type {
|
||||
case vpn.AmneziaWg:
|
||||
case constants.AmneziaWg:
|
||||
for _, prefix := range settings.AmneziaWg.Wireguard.Addresses {
|
||||
if prefix.Addr().Is6() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
case vpn.OpenVPN:
|
||||
case constants.OpenVPN:
|
||||
link, err := l.netLinker.LinkByName(settings.OpenVPN.Interface)
|
||||
if err != nil {
|
||||
l.logger.Warnf("assuming IPv6 is not supported, cannot get OpenVPN link by name: %v", err)
|
||||
@@ -35,7 +35,7 @@ func (l *Loop) isIPv6Used(settings settings.VPN) bool {
|
||||
}
|
||||
}
|
||||
return false
|
||||
case vpn.Wireguard:
|
||||
case constants.Wireguard:
|
||||
for _, prefix := range settings.Wireguard.Addresses {
|
||||
if prefix.Addr().Is6() {
|
||||
return true
|
||||
|
||||
+5
-5
@@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/vpn"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
uconstants "github.com/qdm12/gluetun/pkg/updaters/constants"
|
||||
"github.com/qdm12/log"
|
||||
)
|
||||
|
||||
@@ -34,15 +34,15 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) {
|
||||
var err error
|
||||
subLogger := l.logger.New(log.SetComponent(settings.Type))
|
||||
switch settings.Type {
|
||||
case vpn.AmneziaWg:
|
||||
case uconstants.AmneziaWg:
|
||||
vpnInterface = settings.AmneziaWg.Wireguard.Interface
|
||||
vpnRunner, connection, err = setupAmneziaWg(ctx, l.netLinker, l.fw,
|
||||
providerConf, settings, l.ipv6SupportLevel, subLogger)
|
||||
case vpn.OpenVPN:
|
||||
case uconstants.OpenVPN:
|
||||
vpnInterface = settings.OpenVPN.Interface
|
||||
vpnRunner, connection, err = setupOpenVPN(ctx, l.fw,
|
||||
l.openvpnConf, providerConf, settings, l.ipv6SupportLevel, l.cmder, subLogger)
|
||||
case vpn.Wireguard:
|
||||
case uconstants.Wireguard:
|
||||
vpnInterface = settings.Wireguard.Interface
|
||||
vpnRunner, connection, err = setupWireguard(ctx, l.netLinker, l.fw,
|
||||
providerConf, settings, l.ipv6SupportLevel, subLogger)
|
||||
@@ -56,7 +56,7 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) {
|
||||
tunnelUpData := tunnelUpData{
|
||||
upCommand: *settings.UpCommand,
|
||||
pmtud: tunnelUpPMTUDData{
|
||||
enabled: settings.Type != vpn.Wireguard || *settings.Wireguard.MTU == 0,
|
||||
enabled: settings.Type != uconstants.Wireguard || *settings.Wireguard.MTU == 0,
|
||||
vpnType: settings.Type,
|
||||
network: connection.Protocol,
|
||||
ipv6: l.isIPv6Used(settings),
|
||||
|
||||
@@ -9,12 +9,12 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/vpn"
|
||||
"github.com/qdm12/gluetun/internal/netlink"
|
||||
"github.com/qdm12/gluetun/internal/pmtud"
|
||||
pconstants "github.com/qdm12/gluetun/internal/pmtud/constants"
|
||||
"github.com/qdm12/gluetun/internal/pmtud/tcp"
|
||||
"github.com/qdm12/gluetun/internal/version"
|
||||
uconstants "github.com/qdm12/gluetun/pkg/updaters/constants"
|
||||
"github.com/qdm12/log"
|
||||
)
|
||||
|
||||
@@ -36,7 +36,7 @@ type tunnelUpPMTUDData struct {
|
||||
// enabled is notably false if the user specifies a custom MTU.
|
||||
enabled bool
|
||||
// vpnType is used to find the maximum VPN header overhead.
|
||||
// It can be [vpn.Wireguard] or [vpn.OpenVPN].
|
||||
// It can be [constants.Wireguard] or [constants.OpenVPN].
|
||||
vpnType string
|
||||
// network is used to find the network level header overhead.
|
||||
// It can be [constants.UDP] or [constants.TCP].
|
||||
@@ -53,7 +53,7 @@ type tunnelUpPMTUDData struct {
|
||||
|
||||
func (l *Loop) onTunnelUp(ctx, loopCtx context.Context, data tunnelUpData) {
|
||||
switch vpnType := l.GetSettings().Type; vpnType {
|
||||
case vpn.Wireguard, vpn.AmneziaWg:
|
||||
case uconstants.Wireguard, uconstants.AmneziaWg:
|
||||
l.logger.Infof("%s setup is complete. "+
|
||||
"Note %s is a silent protocol and it may or may not work, without giving any error message. "+
|
||||
"Typically i/o timeout errors indicate the %s connection is not working.",
|
||||
|
||||
Reference in New Issue
Block a user