feat(vpn): VPN_ENDPOINT_IP
- Deprecate `OPENVPN_TARGET_IP` - Deprecate `WIREGUARD_ENDPOINT_IP`
This commit is contained in:
@@ -68,6 +68,8 @@ LABEL \
|
|||||||
org.opencontainers.image.description="VPN swiss-knife like client to tunnel to multiple VPN servers using OpenVPN, IPtables, DNS over TLS, Shadowsocks, an HTTP proxy and Alpine Linux"
|
org.opencontainers.image.description="VPN swiss-knife like client to tunnel to multiple VPN servers using OpenVPN, IPtables, DNS over TLS, Shadowsocks, an HTTP proxy and Alpine Linux"
|
||||||
ENV VPNSP=pia \
|
ENV VPNSP=pia \
|
||||||
VPN_TYPE=openvpn \
|
VPN_TYPE=openvpn \
|
||||||
|
# Common VPN options
|
||||||
|
VPN_ENDPOINT_IP= \
|
||||||
# OpenVPN
|
# OpenVPN
|
||||||
OPENVPN_PROTOCOL=udp \
|
OPENVPN_PROTOCOL=udp \
|
||||||
OPENVPN_USER= \
|
OPENVPN_USER= \
|
||||||
@@ -80,7 +82,6 @@ ENV VPNSP=pia \
|
|||||||
OPENVPN_CIPHER= \
|
OPENVPN_CIPHER= \
|
||||||
OPENVPN_AUTH= \
|
OPENVPN_AUTH= \
|
||||||
OPENVPN_PROCESS_USER= \
|
OPENVPN_PROCESS_USER= \
|
||||||
OPENVPN_TARGET_IP= \
|
|
||||||
OPENVPN_IPV6=off \
|
OPENVPN_IPV6=off \
|
||||||
OPENVPN_CUSTOM_CONFIG= \
|
OPENVPN_CUSTOM_CONFIG= \
|
||||||
OPENVPN_INTERFACE=tun0 \
|
OPENVPN_INTERFACE=tun0 \
|
||||||
@@ -90,7 +91,6 @@ ENV VPNSP=pia \
|
|||||||
WIREGUARD_PRESHARED_KEY= \
|
WIREGUARD_PRESHARED_KEY= \
|
||||||
WIREGUARD_PUBLIC_KEY= \
|
WIREGUARD_PUBLIC_KEY= \
|
||||||
WIREGUARD_ADDRESS= \
|
WIREGUARD_ADDRESS= \
|
||||||
WIREGUARD_ENDPOINT_IP= \
|
|
||||||
WIREGUARD_ENDPOINT_PORT= \
|
WIREGUARD_ENDPOINT_PORT= \
|
||||||
WIREGUARD_INTERFACE=wg0 \
|
WIREGUARD_INTERFACE=wg0 \
|
||||||
# VPN server filtering
|
# VPN server filtering
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func (r *Reader) readServerSelection(vpnProvider, vpnType string) (
|
|||||||
ss settings.ServerSelection, err error) {
|
ss settings.ServerSelection, err error) {
|
||||||
ss.VPN = vpnType
|
ss.VPN = vpnType
|
||||||
|
|
||||||
ss.TargetIP, err = readOpenVPNTargetIP()
|
ss.TargetIP, err = r.readOpenVPNTargetIP()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ss, err
|
return ss, err
|
||||||
}
|
}
|
||||||
@@ -99,16 +99,23 @@ var (
|
|||||||
ErrInvalidIP = errors.New("invalid IP address")
|
ErrInvalidIP = errors.New("invalid IP address")
|
||||||
)
|
)
|
||||||
|
|
||||||
func readOpenVPNTargetIP() (ip net.IP, err error) {
|
func (r *Reader) readOpenVPNTargetIP() (ip net.IP, err error) {
|
||||||
s := os.Getenv("OPENVPN_TARGET_IP")
|
envKey := "OPENVPN_TARGET_IP"
|
||||||
|
s := os.Getenv(envKey) // Retro-compatibility
|
||||||
if s == "" {
|
if s == "" {
|
||||||
return nil, nil
|
envKey = "VPN_ENDPOINT_IP"
|
||||||
|
s = os.Getenv(envKey)
|
||||||
|
if s == "" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
r.onRetroActive("OPENVPN_TARGET_IP", "VPN_ENDPOINT_IP")
|
||||||
}
|
}
|
||||||
|
|
||||||
ip = net.ParseIP(s)
|
ip = net.ParseIP(s)
|
||||||
if ip == nil {
|
if ip == nil {
|
||||||
return nil, fmt.Errorf("environment variable OPENVPN_TARGET_IP: %w: %s",
|
return nil, fmt.Errorf("environment variable %s: %w: %s",
|
||||||
ErrInvalidIP, s)
|
envKey, ErrInvalidIP, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ip, nil
|
return ip, nil
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
func (r *Reader) readWireguardSelection() (
|
func (r *Reader) readWireguardSelection() (
|
||||||
selection settings.WireguardSelection, err error) {
|
selection settings.WireguardSelection, err error) {
|
||||||
selection.EndpointIP, err = readWireguardEndpointIP()
|
selection.EndpointIP, err = r.readWireguardEndpointIP()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return selection, err
|
return selection, err
|
||||||
}
|
}
|
||||||
@@ -29,16 +29,28 @@ func (r *Reader) readWireguardSelection() (
|
|||||||
|
|
||||||
var ErrIPAddressParse = errors.New("cannot parse IP address")
|
var ErrIPAddressParse = errors.New("cannot parse IP address")
|
||||||
|
|
||||||
func readWireguardEndpointIP() (endpointIP net.IP, err error) {
|
func (r *Reader) readWireguardEndpointIP() (endpointIP net.IP, err error) {
|
||||||
s := os.Getenv("WIREGUARD_ENDPOINT_IP")
|
const currentKey = "VPN_ENDPOINT_IP"
|
||||||
|
key := "WIREGUARD_ENDPOINT_IP"
|
||||||
|
s := os.Getenv(key) // Retro-compatibility
|
||||||
if s == "" {
|
if s == "" {
|
||||||
return nil, nil
|
key = currentKey
|
||||||
|
s = os.Getenv(key)
|
||||||
|
if s == "" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if key != currentKey {
|
||||||
|
r.onRetroActive(key, currentKey)
|
||||||
|
}
|
||||||
|
|
||||||
endpointIP = net.ParseIP(s)
|
endpointIP = net.ParseIP(s)
|
||||||
if endpointIP == nil {
|
if endpointIP == nil {
|
||||||
return nil, fmt.Errorf("environment variable WIREGUARD_ENDPOINT_IP: %w: %s",
|
return nil, fmt.Errorf("environment variable %s: %w: %s",
|
||||||
ErrIPAddressParse, s)
|
key, ErrIPAddressParse, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
return endpointIP, nil
|
return endpointIP, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user