Maint: move Openvpn package files

- Move internal/openvpn/config/*.go to internal/openvpn/
- Move internal/openvpn/setup.go to internal/vpn/openvpn.go
This commit is contained in:
Quentin McGaw (desktop)
2021-08-19 13:31:12 +00:00
parent d4ca5cf257
commit 105d81c018
13 changed files with 20 additions and 21 deletions

View File

@@ -22,7 +22,7 @@ import (
"github.com/qdm12/gluetun/internal/healthcheck" "github.com/qdm12/gluetun/internal/healthcheck"
"github.com/qdm12/gluetun/internal/httpproxy" "github.com/qdm12/gluetun/internal/httpproxy"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
openvpnconfig "github.com/qdm12/gluetun/internal/openvpn/config" "github.com/qdm12/gluetun/internal/openvpn"
"github.com/qdm12/gluetun/internal/portforward" "github.com/qdm12/gluetun/internal/portforward"
"github.com/qdm12/gluetun/internal/publicip" "github.com/qdm12/gluetun/internal/publicip"
"github.com/qdm12/gluetun/internal/routing" "github.com/qdm12/gluetun/internal/routing"
@@ -145,7 +145,7 @@ func _main(ctx context.Context, buildInfo models.BuildInformation,
httpClient := &http.Client{Timeout: clientTimeout} httpClient := &http.Client{Timeout: clientTimeout}
// Create configurators // Create configurators
alpineConf := alpine.New() alpineConf := alpine.New()
ovpnConf := openvpnconfig.New( ovpnConf := openvpn.New(
logger.NewChild(logging.Settings{Prefix: "openvpn configurator: "}), logger.NewChild(logging.Settings{Prefix: "openvpn configurator: "}),
cmder, puid, pgid) cmder, puid, pgid)
dnsCrypto := dnscrypto.New(httpClient, "", "") dnsCrypto := dnscrypto.New(httpClient, "", "")

View File

@@ -1,4 +1,4 @@
package config package openvpn
import ( import (
"io" "io"

View File

@@ -1,4 +1,4 @@
package config package openvpn
import ( import (
"os" "os"

View File

@@ -1,4 +1,4 @@
package config package openvpn
import ( import (
"strings" "strings"

View File

@@ -1,4 +1,4 @@
package config package openvpn
import ( import (
"testing" "testing"

View File

@@ -1,4 +1,4 @@
package config package openvpn
import ( import (
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"

View File

@@ -1,4 +1,4 @@
package config package openvpn
import ( import (
"context" "context"

View File

@@ -1,4 +1,4 @@
package config package openvpn
import ( import (
"context" "context"

View File

@@ -1,4 +1,4 @@
package config package openvpn
import ( import (
"context" "context"

View File

@@ -1,4 +1,4 @@
package config package openvpn
import ( import (
"context" "context"

View File

@@ -10,7 +10,7 @@ import (
"github.com/qdm12/gluetun/internal/firewall" "github.com/qdm12/gluetun/internal/firewall"
"github.com/qdm12/gluetun/internal/loopstate" "github.com/qdm12/gluetun/internal/loopstate"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/openvpn/config" "github.com/qdm12/gluetun/internal/openvpn"
"github.com/qdm12/gluetun/internal/portforward" "github.com/qdm12/gluetun/internal/portforward"
"github.com/qdm12/gluetun/internal/publicip" "github.com/qdm12/gluetun/internal/publicip"
"github.com/qdm12/gluetun/internal/routing" "github.com/qdm12/gluetun/internal/routing"
@@ -35,7 +35,7 @@ type Loop struct {
buildInfo models.BuildInformation buildInfo models.BuildInformation
versionInfo bool versionInfo bool
// Configurators // Configurators
openvpnConf config.Interface openvpnConf openvpn.Interface
fw firewallConfigurer fw firewallConfigurer
routing routing.VPNGetter routing routing.VPNGetter
portForward portforward.StartStopper portForward portforward.StartStopper
@@ -65,7 +65,7 @@ const (
func NewLoop(vpnSettings configuration.VPN, func NewLoop(vpnSettings configuration.VPN,
providerSettings configuration.Provider, providerSettings configuration.Provider,
allServers models.AllServers, openvpnConf config.Interface, allServers models.AllServers, openvpnConf openvpn.Interface,
fw firewallConfigurer, routing routing.VPNGetter, fw firewallConfigurer, routing routing.VPNGetter,
portForward portforward.StartStopper, portForward portforward.StartStopper,
publicip publicip.Looper, dnsLooper dns.Looper, publicip publicip.Looper, dnsLooper dns.Looper,

View File

@@ -1,4 +1,4 @@
package openvpn package vpn
import ( import (
"context" "context"
@@ -8,7 +8,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration" "github.com/qdm12/gluetun/internal/configuration"
"github.com/qdm12/gluetun/internal/firewall" "github.com/qdm12/gluetun/internal/firewall"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/openvpn/config" "github.com/qdm12/gluetun/internal/openvpn"
"github.com/qdm12/gluetun/internal/openvpn/custom" "github.com/qdm12/gluetun/internal/openvpn/custom"
"github.com/qdm12/gluetun/internal/provider" "github.com/qdm12/gluetun/internal/provider"
) )
@@ -20,10 +20,10 @@ var (
errFirewall = errors.New("failed allowing VPN connection through firewall") errFirewall = errors.New("failed allowing VPN connection through firewall")
) )
// Setup sets OpenVPN up using the configurators and settings given. // setupOpenVPN sets OpenVPN up using the configurators and settings given.
// It returns a serverName for port forwarding (PIA) and an error if it fails. // It returns a serverName for port forwarding (PIA) and an error if it fails.
func Setup(ctx context.Context, fw firewall.VPNConnectionSetter, func setupOpenVPN(ctx context.Context, fw firewall.VPNConnectionSetter,
openvpnConf config.Interface, providerConf provider.Provider, openvpnConf openvpn.Interface, providerConf provider.Provider,
openVPNSettings configuration.OpenVPN, providerSettings configuration.Provider) ( openVPNSettings configuration.OpenVPN, providerSettings configuration.Provider) (
serverName string, err error) { serverName string, err error) {
var connection models.OpenVPNConnection var connection models.OpenVPNConnection

View File

@@ -5,7 +5,6 @@ import (
"time" "time"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/openvpn"
"github.com/qdm12/gluetun/internal/provider" "github.com/qdm12/gluetun/internal/provider"
) )
@@ -27,7 +26,7 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) {
providerConf := provider.New(providerSettings.Name, allServers, time.Now) providerConf := provider.New(providerSettings.Name, allServers, time.Now)
serverName, err := openvpn.Setup(ctx, l.fw, l.openvpnConf, providerConf, VPNSettings.OpenVPN, providerSettings) serverName, err := setupOpenVPN(ctx, l.fw, l.openvpnConf, providerConf, VPNSettings.OpenVPN, providerSettings)
if err != nil { if err != nil {
l.crashed(ctx, err) l.crashed(ctx, err)
continue continue