From 564cc2b0bc428e37bbebf6e9abb51a030ae4a096 Mon Sep 17 00:00:00 2001 From: "Quentin McGaw (desktop)" Date: Mon, 26 Jul 2021 16:30:51 +0000 Subject: [PATCH] Maint: move misplaced writeOpenvpnConf in openvpn --- internal/openvpn/config.go | 18 ++++++++++++++++++ internal/openvpn/portforwarded.go | 14 -------------- 2 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 internal/openvpn/config.go diff --git a/internal/openvpn/config.go b/internal/openvpn/config.go new file mode 100644 index 00000000..8cab2aac --- /dev/null +++ b/internal/openvpn/config.go @@ -0,0 +1,18 @@ +package openvpn + +import ( + "os" + "strings" +) + +func (l *Loop) writeOpenvpnConf(lines []string) error { + file, err := os.OpenFile(l.targetConfPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644) + if err != nil { + return err + } + _, err = file.WriteString(strings.Join(lines, "\n")) + if err != nil { + return err + } + return file.Close() +} diff --git a/internal/openvpn/portforwarded.go b/internal/openvpn/portforwarded.go index 083bb162..82e59d73 100644 --- a/internal/openvpn/portforwarded.go +++ b/internal/openvpn/portforwarded.go @@ -4,8 +4,6 @@ import ( "context" "net" "net/http" - "os" - "strings" "github.com/qdm12/gluetun/internal/openvpn/state" "github.com/qdm12/gluetun/internal/provider" @@ -39,15 +37,3 @@ func (l *Loop) portForward(ctx context.Context, providerConf.PortForward(ctx, client, l.pfLogger, gateway, l.fw, syncState) } - -func (l *Loop) writeOpenvpnConf(lines []string) error { - file, err := os.OpenFile(l.targetConfPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644) - if err != nil { - return err - } - _, err = file.WriteString(strings.Join(lines, "\n")) - if err != nil { - return err - } - return file.Close() -}