Refactor codebase

This commit is contained in:
2026-02-16 08:11:49 -05:00
parent 323709b0a1
commit bb88db92c1
9 changed files with 197 additions and 166 deletions

View File

@@ -1,28 +1,17 @@
package vpn
import (
"os"
"runtime"
"github.com/davegallant/vpngate/pkg/exec"
"github.com/juju/errors"
)
// Connect to a specified OpenVPN configuration
func Connect(configPath string) error {
tmpLogFile, err := os.CreateTemp("", "vpngate-openvpn-log-")
if err != nil {
return errors.Annotate(err, "Unable to create a temporary log file")
}
defer func() {
_ = os.Remove(tmpLogFile.Name())
}()
executable := "openvpn"
if runtime.GOOS == "windows" {
executable = "C:\\Program Files\\OpenVPN\\bin\\openvpn.exe"
}
err = exec.Run(executable, ".", "--verb", "4", "--config", configPath, "--data-ciphers", "AES-128-CBC")
return err
}
return exec.Run(executable, ".", "--verb", "4", "--config", configPath, "--data-ciphers", "AES-128-CBC")
}