Add initial support and docs for Windows (#132)

- Add initial support for Windows
- Update docs
- Fix issue with openvpn 2.6 data-ciphers
This commit is contained in:
Dave Gallant
2024-07-28 21:09:57 -04:00
committed by GitHub
parent 885f73db1c
commit 3e819c5c55
7 changed files with 47 additions and 67 deletions

View File

@@ -2,11 +2,10 @@ package vpn
import (
"os"
"runtime"
"github.com/davegallant/vpngate/pkg/exec"
"github.com/juju/errors"
"github.com/nxadm/tail"
"github.com/rs/zerolog/log"
)
// Connect to a specified OpenVPN configuration
@@ -17,17 +16,11 @@ func Connect(configPath string) error {
}
defer os.Remove(tmpLogFile.Name())
go func() {
// Tail the temporary openvpn log file
t, err := tail.TailFile(tmpLogFile.Name(), tail.Config{Follow: true})
if err != nil {
log.Error().Msgf("%s", err)
}
for line := range t.Lines {
log.Debug().Msg(line.Text)
}
}()
executable := "openvpn"
if runtime.GOOS == "windows" {
executable = "C:\\Program Files\\OpenVPN\\bin\\openvpn.exe"
}
_, err = exec.Run("openvpn", ".", "--verb", "4", "--log", tmpLogFile.Name(), "--config", configPath)
err = exec.Run(executable, ".", "--verb", "4", "--config", configPath, "--data-ciphers", "AES-128-CBC")
return err
}