mirror of
https://github.com/davegallant/vpngate.git
synced 2025-11-25 19:04:17 +00:00
* Update golangci/golangci-lint-action action to v9 * Bump golangci-lint to 2.6.2 * Refactor to pass golangcli-lint * Fix tests --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Dave Gallant <dave.gallant@gmail.com> Co-authored-by: Dave Gallant <davegallant@proton.me>
29 lines
652 B
Go
29 lines
652 B
Go
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
|
|
}
|