Maint: move OpenVPN configurator to openvpn/config

This commit is contained in:
Quentin McGaw (desktop)
2021-08-18 20:23:50 +00:00
parent df51aa40f4
commit ecdf9396a5
6 changed files with 11 additions and 11 deletions

View File

@@ -23,6 +23,7 @@ import (
"github.com/qdm12/gluetun/internal/httpproxy" "github.com/qdm12/gluetun/internal/httpproxy"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/openvpn" "github.com/qdm12/gluetun/internal/openvpn"
openvpnconfig "github.com/qdm12/gluetun/internal/openvpn/config"
"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"
@@ -142,7 +143,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 := openvpn.NewConfigurator( ovpnConf := openvpnconfig.NewConfigurator(
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 openvpn package config
import ( import (
"io" "io"

View File

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

View File

@@ -1,11 +1,11 @@
package openvpn package config
import ( import (
"os" "os"
"strings" "strings"
) )
type ConfigWriter interface { type Writer interface {
WriteConfig(lines []string) error WriteConfig(lines []string) error
} }

View File

@@ -1,6 +1,4 @@
// Package openvpn defines interfaces to interact with openvpn package config
// and run it in a stateful loop.
package openvpn
import ( import (
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
@@ -12,7 +10,7 @@ type Configurator interface {
VersionGetter VersionGetter
AuthWriter AuthWriter
Starter Starter
ConfigWriter Writer
} }
type configurator struct { type configurator struct {

View File

@@ -10,6 +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/state" "github.com/qdm12/gluetun/internal/openvpn/state"
"github.com/qdm12/gluetun/internal/portforward" "github.com/qdm12/gluetun/internal/portforward"
"github.com/qdm12/gluetun/internal/publicip" "github.com/qdm12/gluetun/internal/publicip"
@@ -34,7 +35,7 @@ type Loop struct {
buildInfo models.BuildInformation buildInfo models.BuildInformation
versionInfo bool versionInfo bool
// Configurators // Configurators
conf Configurator conf config.Configurator
fw firewallConfigurer fw firewallConfigurer
routing routing.VPNGetter routing routing.VPNGetter
portForward portforward.StartStopper portForward portforward.StartStopper
@@ -64,7 +65,7 @@ const (
func NewLoop(openVPNSettings configuration.OpenVPN, func NewLoop(openVPNSettings configuration.OpenVPN,
providerSettings configuration.Provider, providerSettings configuration.Provider,
allServers models.AllServers, conf Configurator, allServers models.AllServers, conf config.Configurator,
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,