Maint: move misplaced writeOpenvpnConf in openvpn

This commit is contained in:
Quentin McGaw (desktop)
2021-07-26 16:30:51 +00:00
parent 49885c63c4
commit 564cc2b0bc
2 changed files with 18 additions and 14 deletions

View File

@@ -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()
}

View File

@@ -4,8 +4,6 @@ import (
"context" "context"
"net" "net"
"net/http" "net/http"
"os"
"strings"
"github.com/qdm12/gluetun/internal/openvpn/state" "github.com/qdm12/gluetun/internal/openvpn/state"
"github.com/qdm12/gluetun/internal/provider" "github.com/qdm12/gluetun/internal/provider"
@@ -39,15 +37,3 @@ func (l *Loop) portForward(ctx context.Context,
providerConf.PortForward(ctx, client, l.pfLogger, providerConf.PortForward(ctx, client, l.pfLogger,
gateway, l.fw, syncState) 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()
}