Added OPENVPN_VERBOSITY environment variable
This commit is contained in:
@@ -32,6 +32,7 @@ LABEL \
|
||||
ENV VPNSP=pia \
|
||||
USER= \
|
||||
PROTOCOL=udp \
|
||||
OPENVPN_VERBOSITY=1 \
|
||||
TZ= \
|
||||
# PIA only
|
||||
PASSWORD= \
|
||||
|
||||
@@ -154,6 +154,7 @@ docker run --rm --network=container:pia alpine:3.10 wget -qO- https://ipinfo.io
|
||||
| `SHADOWSOCKS_PORT` | `8388` | `1024` to `65535` internal port for SOCKS5 proxy |
|
||||
| `SHADOWSOCKS_PASSWORD` | | Passsword to use to connect to the SOCKS5 proxy |
|
||||
| `TZ` | | Specify a timezone to use i.e. `Europe/London` |
|
||||
| `OPENVPN_VERBOSITY` | `1` | Openvpn verbosity level from 0 to 6 |
|
||||
|
||||
## Connect to it
|
||||
|
||||
|
||||
@@ -132,12 +132,12 @@ func main() {
|
||||
case "pia":
|
||||
connections, err = piaConf.GetOpenVPNConnections(allSettings.PIA.Region, allSettings.OpenVPN.NetworkProtocol, allSettings.PIA.Encryption)
|
||||
e.FatalOnError(err)
|
||||
err = piaConf.BuildConf(connections, allSettings.PIA.Encryption, uid, gid)
|
||||
err = piaConf.BuildConf(connections, allSettings.PIA.Encryption, allSettings.OpenVPN.Verbosity, uid, gid)
|
||||
e.FatalOnError(err)
|
||||
case "mullvad":
|
||||
connections, err = mullvadConf.GetOpenVPNConnections(allSettings.Mullvad.Country, allSettings.Mullvad.City, allSettings.Mullvad.ISP, allSettings.OpenVPN.NetworkProtocol, allSettings.Mullvad.Port)
|
||||
e.FatalOnError(err)
|
||||
err = mullvadConf.BuildConf(connections, uid, gid)
|
||||
err = mullvadConf.BuildConf(connections, allSettings.OpenVPN.Verbosity, uid, gid)
|
||||
e.FatalOnError(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ services:
|
||||
- VPNSP=pia
|
||||
- USER=js89ds7
|
||||
- PROTOCOL=udp
|
||||
- OPENVPN_VERBOSITY=1
|
||||
- TZ=
|
||||
|
||||
# PIA only
|
||||
|
||||
@@ -25,7 +25,7 @@ func (c *configurator) GetOpenVPNConnections(country models.MullvadCountry, city
|
||||
return connections, nil
|
||||
}
|
||||
|
||||
func (c *configurator) BuildConf(connections []models.OpenVPNConnection, uid, gid int) (err error) {
|
||||
func (c *configurator) BuildConf(connections []models.OpenVPNConnection, verbosity, uid, gid int) (err error) {
|
||||
if len(connections) == 0 {
|
||||
return fmt.Errorf("at least one connection string is expected")
|
||||
}
|
||||
@@ -37,7 +37,6 @@ func (c *configurator) BuildConf(connections []models.OpenVPNConnection, uid, gi
|
||||
"persist-tun",
|
||||
"remote-cert-tls server",
|
||||
"ping 300",
|
||||
"verb 1", // TODO env variable
|
||||
|
||||
// Mullvad specific
|
||||
// "sndbuf 524288"
|
||||
@@ -53,6 +52,7 @@ func (c *configurator) BuildConf(connections []models.OpenVPNConnection, uid, gi
|
||||
"remote-random",
|
||||
|
||||
// Modified variables
|
||||
fmt.Sprintf("verb %d", verbosity),
|
||||
fmt.Sprintf("auth-user-pass %s", constants.OpenVPNAuthConf),
|
||||
fmt.Sprintf("proto %s", string(connections[0].Protocol)),
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ const logPrefix = "Mullvad configurator"
|
||||
// Configurator contains methods to download, read and modify the openvpn configuration to connect as a client
|
||||
type Configurator interface {
|
||||
GetOpenVPNConnections(country models.MullvadCountry, city models.MullvadCity, provider models.MullvadProvider, protocol models.NetworkProtocol, customPort uint16) (connections []models.OpenVPNConnection, err error)
|
||||
BuildConf(connections []models.OpenVPNConnection, uid, gid int) (err error)
|
||||
BuildConf(connections []models.OpenVPNConnection, verbosity, uid, gid int) (err error)
|
||||
}
|
||||
|
||||
type configurator struct {
|
||||
|
||||
@@ -47,3 +47,9 @@ func (p *paramsReader) GetNetworkProtocol() (protocol models.NetworkProtocol, er
|
||||
s, err := p.envParams.GetValueIfInside("PROTOCOL", []string{"tcp", "udp"}, libparams.Default("udp"))
|
||||
return models.NetworkProtocol(s), err
|
||||
}
|
||||
|
||||
// GetOpenVPNVerbosity obtains the verbosity level for verbosity between 0 and 6
|
||||
// from the environment variable OPENVPN_VERBOSITY
|
||||
func (p *paramsReader) GetOpenVPNVerbosity() (verbosity int, err error) {
|
||||
return p.envParams.GetEnvIntRange("OPENVPN_VERBOSITY", 0, 6, libparams.Default("1"))
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ type ParamsReader interface {
|
||||
GetUser() (s string, err error)
|
||||
GetPassword() (s string, err error)
|
||||
GetNetworkProtocol() (protocol models.NetworkProtocol, err error)
|
||||
GetOpenVPNVerbosity() (verbosity int, err error)
|
||||
|
||||
// PIA getters
|
||||
GetPortForwarding() (activated bool, err error)
|
||||
|
||||
@@ -54,7 +54,7 @@ func (c *configurator) GetOpenVPNConnections(region models.PIARegion, protocol m
|
||||
return connections, nil
|
||||
}
|
||||
|
||||
func (c *configurator) BuildConf(connections []models.OpenVPNConnection, encryption models.PIAEncryption, uid, gid int) (err error) {
|
||||
func (c *configurator) BuildConf(connections []models.OpenVPNConnection, encryption models.PIAEncryption, verbosity, uid, gid int) (err error) {
|
||||
var X509CRL, certificate, cipherAlgo, authAlgo string
|
||||
if encryption == constants.PIAEncryptionNormal {
|
||||
cipherAlgo = "aes-128-cbc"
|
||||
@@ -75,7 +75,6 @@ func (c *configurator) BuildConf(connections []models.OpenVPNConnection, encrypt
|
||||
"persist-tun",
|
||||
"remote-cert-tls server",
|
||||
"ping 300", // Ping every 5 minutes to prevent a timeout error
|
||||
"verb 1", // TODO env variable
|
||||
|
||||
// PIA specific
|
||||
"reneg-sec 0",
|
||||
@@ -88,6 +87,7 @@ func (c *configurator) BuildConf(connections []models.OpenVPNConnection, encrypt
|
||||
"remote-random",
|
||||
|
||||
// Modified variables
|
||||
fmt.Sprintf("verb %d", verbosity),
|
||||
fmt.Sprintf("auth-user-pass %s", constants.OpenVPNAuthConf),
|
||||
fmt.Sprintf("proto %s", string(connections[0].Protocol)),
|
||||
fmt.Sprintf("cipher %s", cipherAlgo),
|
||||
|
||||
@@ -18,7 +18,7 @@ const logPrefix = "PIA configurator"
|
||||
type Configurator interface {
|
||||
GetOpenVPNConnections(region models.PIARegion, protocol models.NetworkProtocol,
|
||||
encryption models.PIAEncryption) (connections []models.OpenVPNConnection, err error)
|
||||
BuildConf(connections []models.OpenVPNConnection, encryption models.PIAEncryption, uid, gid int) (err error)
|
||||
BuildConf(connections []models.OpenVPNConnection, encryption models.PIAEncryption, verbosity, uid, gid int) (err error)
|
||||
GetPortForward() (port uint16, err error)
|
||||
WritePortForward(filepath models.Filepath, port uint16) (err error)
|
||||
AllowPortForwardFirewall(device models.VPNDevice, port uint16) (err error)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package settings
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/private-internet-access-docker/internal/models"
|
||||
@@ -10,6 +11,7 @@ import (
|
||||
// OpenVPN contains settings to configure the OpenVPN client
|
||||
type OpenVPN struct {
|
||||
NetworkProtocol models.NetworkProtocol
|
||||
Verbosity int
|
||||
}
|
||||
|
||||
// GetOpenVPNSettings obtains the OpenVPN settings using the params functions
|
||||
@@ -18,6 +20,10 @@ func GetOpenVPNSettings(params params.ParamsReader) (settings OpenVPN, err error
|
||||
if err != nil {
|
||||
return settings, err
|
||||
}
|
||||
settings.Verbosity, err = params.GetOpenVPNVerbosity()
|
||||
if err != nil {
|
||||
return settings, err
|
||||
}
|
||||
return settings, nil
|
||||
}
|
||||
|
||||
@@ -25,6 +31,7 @@ func (o *OpenVPN) String() string {
|
||||
settingsList := []string{
|
||||
"OpenVPN settings:",
|
||||
"Network protocol: " + string(o.NetworkProtocol),
|
||||
"Verbosity level: " + fmt.Sprintf("%d", o.Verbosity),
|
||||
}
|
||||
return strings.Join(settingsList, "\n|--")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user