qdm12 / gluetun

VPN client in a thin Docker container for multiple VPN providers, written in Go, and using OpenVPN or Wireguard, DNS over TLS, with a few proxy servers built-in.
https://hub.docker.com/r/qmcgaw/gluetun
MIT License
7.52k stars 355 forks source link

Feature request: add custom port options for Purevpn #1725

Open zbloss opened 1 year ago

zbloss commented 1 year ago

Is this urgent?

No

Host OS

Kubernetes v1.27

CPU arch

x86_64

VPN service provider

PureVPN

What are you using to run the container

Kubernetes

What is the version of Gluetun

Running version v3.35.0 built on 2023-06-28T13:06:38.000Z (commit 44bc60b)

What's the problem 🤔

When trying to deploy a kubernetes deployment with this image I'm getting an error in the VPN_ENDPOINT_PORT environment variable. It appears to be getting set as maybe the pod or node tcp ip address rather than just "8888"?

I have also tried manually overriding VPN_ENDPOINT_PORT as "8888" but it is not getting set from the deployment manifest.

Share your logs

========================================
========================================
=============== gluetun ================
========================================
=========== Made with ❤️ by ============
======= https://github.com/qdm12 =======
========================================
========================================
Running version v3.35.0 built on 2023-06-28T13:06:38.000Z (commit 44bc60b)
🔧 Need help? https://github.com/qdm12/gluetun/discussions/new
🐛 Bug? https://github.com/qdm12/gluetun/issues/new
✨ New feature? https://github.com/qdm12/gluetun/issues/new
☕ Discussion? https://github.com/qdm12/gluetun/discussions/new
💻 Email? quentin.mcgaw@gmail.com
💰 Help me? https://www.paypal.me/qmcgaw https://github.com/sponsors/qdm12
2023-07-03T19:00:05-04:00 ERROR reading from environment variables: VPN provider: server selection: environment variable VPN_ENDPOINT_PORT: strconv.ParseUint: parsing "tcp://10.152.183.217:8888": invalid syntax
2023-07-03T19:00:05-04:00 INFO Shutdown successful

Share your configuration

--- deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: openvpn
  namespace: media
spec:
  selector:
    matchLabels:
      app: openvpn
  template:
    metadata:
      labels:
        app: "openvpn"
        sidecar.istio.io/inject: "false"
    spec:
      containers:
        - name: "openvpn"
          image: "qmcgaw/gluetun:v3.35.0"
          resources:
            limits:
              memory: "250Mi"
              cpu: "100m"
          ports:
            - containerPort: 57270
            - name: httpproxy
              containerPort: 8888
            - name: shadowsocks
              containerPort: 8388
            - name: controller
              containerPort: 8000
            - name: pprof
              containerPort: 6060
          envFrom:
          - secretRef:
              name: gluetun-secret 
          env:
            - name: TZ
              value: "America/New_York"
            - name: "VPN_SERVICE_PROVIDER"
              value: "purevpn"
            - name: "SERVER_COUNTRIES"
              value: "Netherlands,Germany,Belgium,Canada,Austria,France,Italy,Norway,Sweden,Switzerland"
            - name: "FIREWALL_OUTBOUND_SUBNETS"
              value: "192.168.86.0/24"
            - name: "FIREWALL_DEBUG"
              value: "on"
            - name: "FIREWALL_INPUT_PORTS"
              value: "9091"
          securityContext:
            privileged: true
            capabilities:
              add:
                - NET_ADMIN
--- gluetun-secret.yaml
apiVersion: v1
data:
  OPENVPN_PASSWORD: REDACTED
  OPENVPN_USER: REDACTED
kind: Secret
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Secret","metadata":{"annotations":{},"name":"gluetun-secret","namespace":"media"},"stringData":{"OPENVPN_PASSWORD":"CwkhkoWMdiLnQM","OPENVPN_USER":"purevpn0s12534363"},"type":"Opaque"}
  creationTimestamp: "2023-07-03T22:14:43Z"
  name: gluetun-secret
  namespace: media
  resourceVersion: "14572740"
  uid: acacc07b-be72-48e8-a40c-25c70508ff8e
type: Opaque
zbloss commented 1 year ago

Setting all three of these environment variables gives me a new error. The new error says that setting a custom vpn endpoint port for purevpn is not allowed

            - name: "VPN_ENDPOINT_PORT"
              value: "8888"
            - name: "OPENVPN_PORT"
              value: "8888"
            - name: "PORT"
              value: "8888"
========================================
========================================
=============== gluetun ================
========================================
=========== Made with ❤️ by ============
======= https://github.com/qdm12 =======
========================================
========================================
Running version v3.35.0 built on 2023-06-28T13:06:38.000Z (commit 44bc60b)
🔧 Need help? https://github.com/qdm12/gluetun/discussions/new
🐛 Bug? https://github.com/qdm12/gluetun/issues/new
✨ New feature? https://github.com/qdm12/gluetun/issues/new
☕ Discussion? https://github.com/qdm12/gluetun/discussions/new
💻 Email? quentin.mcgaw@gmail.com
💰 Help me? https://www.paypal.me/qmcgaw https://github.com/sponsors/qdm12
2023-07-03T19:14:09-04:00 INFO [routing] default route found: interface eth0, gateway 169.254.1.1, assigned IP 10.1.248.71 and family v4
2023-07-03T19:14:09-04:00 INFO [routing] local ethernet link found: eth0
2023-07-03T19:14:09-04:00 INFO [routing] local ipnet found: 169.254.1.1/32
2023-07-03T19:14:09-04:00 INFO [routing] local ipnet found: fe80::/64
2023-07-03T19:14:19-04:00 INFO [firewall] enabling...
2023-07-03T19:14:19-04:00 DEBUG [firewall] iptables --policy INPUT DROP
2023-07-03T19:14:19-04:00 DEBUG [firewall] iptables --policy OUTPUT DROP
2023-07-03T19:14:19-04:00 DEBUG [firewall] iptables --policy FORWARD DROP
2023-07-03T19:14:19-04:00 DEBUG [firewall] ip6tables --policy INPUT DROP
2023-07-03T19:14:19-04:00 DEBUG [firewall] ip6tables --policy OUTPUT DROP
2023-07-03T19:14:19-04:00 DEBUG [firewall] ip6tables --policy FORWARD DROP
2023-07-03T19:14:19-04:00 DEBUG [firewall] iptables --append INPUT -i lo -j ACCEPT
2023-07-03T19:14:19-04:00 DEBUG [firewall] ip6tables --append INPUT -i lo -j ACCEPT
2023-07-03T19:14:19-04:00 DEBUG [firewall] iptables --append OUTPUT -o lo -j ACCEPT
2023-07-03T19:14:19-04:00 DEBUG [firewall] ip6tables --append OUTPUT -o lo -j ACCEPT
2023-07-03T19:14:19-04:00 DEBUG [firewall] iptables --append OUTPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
2023-07-03T19:14:19-04:00 DEBUG [firewall] ip6tables --append OUTPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
2023-07-03T19:14:19-04:00 DEBUG [firewall] iptables --append INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
2023-07-03T19:14:19-04:00 DEBUG [firewall] ip6tables --append INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
2023-07-03T19:14:19-04:00 DEBUG [firewall] iptables --append OUTPUT -o eth0 -s 10.1.248.71 -d 169.254.1.1/32 -j ACCEPT
2023-07-03T19:14:19-04:00 DEBUG [firewall] ip6tables --append OUTPUT -o eth0 -d ff02::1:ff/104 -j ACCEPT
2023-07-03T19:14:19-04:00 DEBUG [firewall] ip6tables --append OUTPUT -o eth0 -s fe80::9003:55ff:fe39:4f3d -d fe80::/64 -j ACCEPT
2023-07-03T19:14:19-04:00 DEBUG [firewall] ip6tables --append OUTPUT -o eth0 -d ff02::1:ff/104 -j ACCEPT
2023-07-03T19:14:19-04:00 DEBUG [firewall] iptables --append INPUT -i eth0 -d 169.254.1.1/32 -j ACCEPT
2023-07-03T19:14:19-04:00 DEBUG [firewall] ip6tables --append INPUT -i eth0 -d fe80::/64 -j ACCEPT
2023-07-03T19:14:19-04:00 INFO [firewall] enabled successfully
2023-07-03T19:14:26-04:00 INFO [storage] creating /gluetun/servers.json with 17678 hardcoded servers
2023-07-03T19:14:28-04:00 ERROR VPN settings: provider settings: server selection: OpenVPN server selection settings: custom endpoint port is not allowed: for VPN service provider purevpn
2023-07-03T19:14:28-04:00 INFO Shutdown successful
zbloss commented 1 year ago

Setting all three of the above environment variables blank appears to work for some reason.

            - name: "VPN_ENDPOINT_PORT"
              value: ""
            - name: "OPENVPN_PORT"
              value: ""
            - name: "PORT"
              value: ""

Happy to help debug before closing this issue

qdm12 commented 1 year ago

Hi there!

The first error ERROR reading from environment variables: VPN provider: server selection: environment variable VPN_ENDPOINT_PORT: strconv.ParseUint: parsing "tcp://10.152.183.217:8888": invalid syntax means something somewhere (not from Gluetun) sets the variable to tcp://10.152.183.217:8888 instead of 8888. I re-checked the code, and there's nothing wrong (Dockerfile default for VPN_ENDPOINT_PORT is the empty string too). That must be a configuration error somewhere on your side.

            - name: "VPN_ENDPOINT_PORT"
              value: "8888"
            - name: "OPENVPN_PORT"
              value: "8888"
            - name: "PORT"
              value: "8888"

Note you only need to set the most up-to-date name which is VPN_ENDPOINT_PORT, the two others are deprecated.

The Purevpn error custom endpoint port is not allowed: for VPN service provider purevpn is because I did not see you could use a custom port other than tcp 80 and udp 53. What are the other port options available, happy to add them. This custom port restriction is there to prevent the user from setting provider-unsupported port numbers and then reporting 'it doesn't work' 😉 (and then maybe digging for hours before realizing there is no server on that port)

Setting all three of the above environment variables blank appears to work for some reason.

Yes, since it will use the default Openvpn port for the provider (80 tcp or 53 udp). Aren't you mixing up the use case of VPN_ENDPOINT_PORT? 🤔

JOHAAANNS commented 1 year ago

Hi Sorry for my poor english ;)

I usually use PureVPN on the port 5656, and it works great. I recently started using Docker, and I installed Gluetun. Indeed, when I impose port 5656 with openvpn, it does not work. My internet service provider "jumps" my connection if I use the basic ports (80 or 53), suddenly, my internet box restarts, so I have to go through other ports (ex: 5656) how can I force the port?

THx ;)