Maint: move misplaced writeOpenvpnConf in openvpn
This commit is contained in:
18
internal/openvpn/config.go
Normal file
18
internal/openvpn/config.go
Normal 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()
|
||||||
|
}
|
||||||
@@ -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()
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user