hotfix(config): split common VPN options per VPN type

- Split `VPN_ENDPOINT_IP` in `OPENVPN_ENDPOINT_IP` and `WIREGUARD_ENDPOINT_IP`
- Split `VPN_ENDPOINT_PORT` in `OPENVPN_ENDPOINT_PORT` and `WIREGUARD_ENDPOINT_PORT`
- Fixes bad usage of Wireguard config file endpoint for OpenVPN #2347
This commit is contained in:
Quentin McGaw
2024-07-27 10:42:01 +00:00
parent 73832d8b49
commit 36c8da7ea7
6 changed files with 14 additions and 12 deletions

View File

@@ -76,10 +76,10 @@ LABEL \
ENV VPN_SERVICE_PROVIDER=pia \ ENV VPN_SERVICE_PROVIDER=pia \
VPN_TYPE=openvpn \ VPN_TYPE=openvpn \
# Common VPN options # Common VPN options
VPN_ENDPOINT_IP= \
VPN_ENDPOINT_PORT= \
VPN_INTERFACE=tun0 \ VPN_INTERFACE=tun0 \
# OpenVPN # OpenVPN
OPENVPN_ENDPOINT_IP= \
OPENVPN_ENDPOINT_PORT= \
OPENVPN_PROTOCOL=udp \ OPENVPN_PROTOCOL=udp \
OPENVPN_USER= \ OPENVPN_USER= \
OPENVPN_PASSWORD= \ OPENVPN_PASSWORD= \
@@ -93,6 +93,8 @@ ENV VPN_SERVICE_PROVIDER=pia \
OPENVPN_PROCESS_USER=root \ OPENVPN_PROCESS_USER=root \
OPENVPN_CUSTOM_CONFIG= \ OPENVPN_CUSTOM_CONFIG= \
# Wireguard # Wireguard
WIREGUARD_ENDPOINT_IP= \
WIREGUARD_ENDPOINT_PORT= \
WIREGUARD_CONF_SECRETFILE=/run/secrets/wg0.conf \ WIREGUARD_CONF_SECRETFILE=/run/secrets/wg0.conf \
WIREGUARD_PRIVATE_KEY= \ WIREGUARD_PRIVATE_KEY= \
WIREGUARD_PRIVATE_KEY_SECRETFILE=/run/secrets/wireguard_private_key \ WIREGUARD_PRIVATE_KEY_SECRETFILE=/run/secrets/wireguard_private_key \

View File

@@ -196,8 +196,8 @@ func (o *OpenVPNSelection) read(r *reader.Reader) (err error) {
return err return err
} }
o.CustomPort, err = r.Uint16Ptr("VPN_ENDPOINT_PORT", o.CustomPort, err = r.Uint16Ptr("OPENVPN_ENDPOINT_PORT",
reader.RetroKeys("PORT", "OPENVPN_PORT")) reader.RetroKeys("PORT", "OPENVPN_PORT", "VPN_ENDPOINT_PORT"))
if err != nil { if err != nil {
return err return err
} }

View File

@@ -385,8 +385,8 @@ func (ss *ServerSelection) read(r *reader.Reader,
vpnProvider, vpnType string) (err error) { vpnProvider, vpnType string) (err error) {
ss.VPN = vpnType ss.VPN = vpnType
ss.TargetIP, err = r.NetipAddr("VPN_ENDPOINT_IP", ss.TargetIP, err = r.NetipAddr("OPENVPN_ENDPOINT_IP",
reader.RetroKeys("OPENVPN_TARGET_IP")) reader.RetroKeys("OPENVPN_TARGET_IP", "VPN_ENDPOINT_IP"))
if err != nil { if err != nil {
return err return err
} }

View File

@@ -151,12 +151,12 @@ func (w WireguardSelection) toLinesNode() (node *gotree.Node) {
} }
func (w *WireguardSelection) read(r *reader.Reader) (err error) { func (w *WireguardSelection) read(r *reader.Reader) (err error) {
w.EndpointIP, err = r.NetipAddr("VPN_ENDPOINT_IP", reader.RetroKeys("WIREGUARD_ENDPOINT_IP")) w.EndpointIP, err = r.NetipAddr("WIREGUARD_ENDPOINT_IP", reader.RetroKeys("VPN_ENDPOINT_IP"))
if err != nil { if err != nil {
return err return err
} }
w.EndpointPort, err = r.Uint16Ptr("VPN_ENDPOINT_PORT", reader.RetroKeys("WIREGUARD_ENDPOINT_PORT")) w.EndpointPort, err = r.Uint16Ptr("WIREGUARD_ENDPOINT_PORT", reader.RetroKeys("VPN_ENDPOINT_PORT"))
if err != nil { if err != nil {
return err return err
} }

View File

@@ -65,9 +65,9 @@ func (s *Source) Get(key string) (value string, isSet bool) {
return strPtrToStringIsSet(s.lazyLoadWireguardConf().Addresses) return strPtrToStringIsSet(s.lazyLoadWireguardConf().Addresses)
case "wireguard_public_key": case "wireguard_public_key":
return strPtrToStringIsSet(s.lazyLoadWireguardConf().PublicKey) return strPtrToStringIsSet(s.lazyLoadWireguardConf().PublicKey)
case "vpn_endpoint_ip": case "wireguard_endpoint_ip":
return strPtrToStringIsSet(s.lazyLoadWireguardConf().EndpointIP) return strPtrToStringIsSet(s.lazyLoadWireguardConf().EndpointIP)
case "vpn_endpoint_port": case "wireguard_endpoint_port":
return strPtrToStringIsSet(s.lazyLoadWireguardConf().EndpointPort) return strPtrToStringIsSet(s.lazyLoadWireguardConf().EndpointPort)
} }

View File

@@ -77,9 +77,9 @@ func (s *Source) Get(key string) (value string, isSet bool) {
} // else continue to read from individual secret file } // else continue to read from individual secret file
case "wireguard_public_key": case "wireguard_public_key":
return strPtrToStringIsSet(s.lazyLoadWireguardConf().PublicKey) return strPtrToStringIsSet(s.lazyLoadWireguardConf().PublicKey)
case "vpn_endpoint_ip": case "wireguard_endpoint_ip":
return strPtrToStringIsSet(s.lazyLoadWireguardConf().EndpointIP) return strPtrToStringIsSet(s.lazyLoadWireguardConf().EndpointIP)
case "vpn_endpoint_port": case "wireguard_endpoint_port":
return strPtrToStringIsSet(s.lazyLoadWireguardConf().EndpointPort) return strPtrToStringIsSet(s.lazyLoadWireguardConf().EndpointPort)
} }