From f3692cd47f3d5889a40f71eb905b1af8d083e1f4 Mon Sep 17 00:00:00 2001 From: "Quentin McGaw (desktop)" Date: Thu, 27 Jan 2022 14:12:25 +0000 Subject: [PATCH] feat(mullvad): `OWNED` to `OWNED_ONLY` --- Dockerfile | 2 +- .../sources/env/serverselection.go | 22 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 83f2c909..d0034aec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -100,7 +100,7 @@ ENV VPNSP=pia \ SERVER_HOSTNAME= \ # # Mullvad only: ISP= \ - OWNED=no \ + OWNED_ONLY=no \ # # Private Internet Access only: PIA_ENCRYPTION= \ PORT_FORWARDING=off \ diff --git a/internal/configuration/sources/env/serverselection.go b/internal/configuration/sources/env/serverselection.go index aac95dba..2264c4d9 100644 --- a/internal/configuration/sources/env/serverselection.go +++ b/internal/configuration/sources/env/serverselection.go @@ -59,9 +59,9 @@ func (r *Reader) readServerSelection(vpnProvider, vpnType string) ( } // Mullvad only - ss.OwnedOnly, err = envToBoolPtr("OWNED") + ss.OwnedOnly, err = r.readOwnedOnly() if err != nil { - return ss, fmt.Errorf("environment variable OWNED: %w", err) + return ss, err } // VPNUnlimited and ProtonVPN only @@ -113,3 +113,21 @@ func readOpenVPNTargetIP() (ip net.IP, err error) { return ip, nil } + +func (r *Reader) readOwnedOnly() (ownedOnly *bool, err error) { + // Retro-compatibility + ownedOnly, err = envToBoolPtr("OWNED") + if err != nil { + r.onRetroActive("OWNED", "OWNED_ONLY") + return nil, fmt.Errorf("environment variable OWNED: %w", err) + } else if ownedOnly != nil { + r.onRetroActive("OWNED", "OWNED_ONLY") + return ownedOnly, nil + } + + ownedOnly, err = envToBoolPtr("OWNED_ONLY") + if err != nil { + return nil, fmt.Errorf("environment variable OWNED_ONLY: %w", err) + } + return ownedOnly, nil +}