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
8.11k stars 374 forks source link

Bug: cannot use custom provider with PIA port forwarding code #2147

Closed Carl-Elkhoury closed 3 months ago

Carl-Elkhoury commented 8 months ago

Is this urgent?

No

Host OS

Ubuntu Jammy

CPU arch

x86_64

VPN service provider

Private Internet Access

What are you using to run the container

Portainer

What is the version of Gluetun

Running version latest built on 2024-03-07T12:32:25.391Z (commit 3254fc8)

What's the problem 🤔

As Wireguard isn't officially supported for PIA, I was able to run my PIA wireguard configuration via custom service provider which works great. I was trying to add port forwarding by setting VPN_PORT_FORWARDING_PROVIDER to private internet access as written in the wiki here that states: Choose the custom port forwarding code to use. This is useful when using the custom provider with Wireguard.

When I do I get error "panic: server name cannot be empty" (see logs below) When I try to add the server name, it seems like it is not an accepted parameter under custom provider: "VPN settings: provider settings: server selection: for VPN service provider custom: the server name specified is not valid: one or more values is set but there is no possible value available"

Would you know what I am doing wrong?

Thank you for the help! Love your work on gluetun, this service is awesome

Share your logs (at least 10 lines)

LOG1:

2024-03-08T18:59:30Z INFO [port forwarding] starting
panic: server name cannot be empty
goroutine 21 [running]:
github.com/qdm12/gluetun/internal/provider/privateinternetaccess.(*Provider).PortForward(0xc001a86918?, {0x109c7e0?, 0xc000194730?}, {{0x7ea4ae8e01b8, 0xc00010ebe0}, {{0x0, 0xffff0a148e01}, 0xc000010018}, 0xc001e9e450, {0x0, ...}})
    github.com/qdm12/gluetun/internal/provider/privateinternetaccess/portforward.go:33 +0x82e
github.com/qdm12/gluetun/internal/portforward/service.(*Service).Start(0xc0000c6a90, {0x109c7e0, 0xc000194730})
    github.com/qdm12/gluetun/internal/portforward/service/start.go:31 +0x391
github.com/qdm12/gluetun/internal/portforward.(*Loop).run(0xc00014d400, {0x109c7e0, 0xc000194730}, 0x0?, 0x0?, 0xc00007fbc0, 0x0?)
    github.com/qdm12/gluetun/internal/portforward/loop.go:119 +0x8e4
created by github.com/qdm12/gluetun/internal/portforward.(*Loop).Start in goroutine 8
    github.com/qdm12/gluetun/internal/portforward/loop.go:71 +0x219

LOG2:

2024-03-08T19:00:51Z INFO [routing] default route found: interface eth0, gateway 172.18.0.1, assigned IP 172.18.0.2 and family v4
2024-03-08T19:00:51Z INFO [routing] local ethernet link found: eth0
2024-03-08T19:00:51Z INFO [routing] local ipnet found: 172.18.0.0/16
2024-03-08T19:00:51Z INFO [firewall] enabling...
2024-03-08T19:00:51Z INFO [firewall] enabled successfully
2024-03-08T19:00:51Z INFO [storage] merging by most recent 17820 hardcoded servers and 17820 servers read from /gluetun/servers.json
2024-03-08T19:00:51Z ERROR VPN settings: provider settings: server selection: for VPN service provider custom: the server name specified is not valid: one or more values is set but there is no possible value available

Share your configuration

services:
  gluetun:
    image: qmcgaw/gluetun
    cap_add:
      - NET_ADMIN
    volumes:
      - /root/gluetun:/gluetun
    environment:
      - VPN_SERVICE_PROVIDER=custom
      - VPN_TYPE=wireguard
      - VPN_ENDPOINT_IP=XXXX
      - VPN_ENDPOINT_PORT=XXX
      - WIREGUARD_PUBLIC_KEY=XXXX
      - WIREGUARD_PRIVATE_KEY=XXXX
      - WIREGUARD_ADDRESSES=XXXX
      - WIREGUARD_ALLOWED_IPS=XXXX
      - VPN_PORT_FORWARDING_PROVIDER="private internet access"
      - VPN_PORT_FORWARDING=on
      - SERVER_NAMES=XXX
      - GID= 0
      - UID= 0
WestonSemones commented 8 months ago

I also encountered this issue today. I similarly am using docker compose, Private Internet Access and running the latest version.

qdm12 commented 7 months ago

Yep I didn't foresee this usage. I pushed 72e2e4b82c481090d8287f7c8e4dc50d3de6a540 where now the server name required for port forwarding (for TLS name verification of PIA's API web server) is set from the first value of SERVER_NAMES if it is set. Can you please try it and see if it works? So for example set SERVER_NAMES=adelaide401 for the au-adelaide-pf.privacy.network server. You can lookup the server name matching your desired server in https://github.com/qdm12/gluetun/blob/master/internal/storage/servers.json if needed. If this works, I'll add extra checks to enforce SERVER_NAMES is set if using pia as the port forwarding code.

carmatana commented 6 months ago

Hello

I am trying to connect to PIA with wireguard

I have:

gluetun: container_name: gluetun image: qmcgaw/gluetun:latest cap_add:

The config file is in /gluetun/wireguard/wg0.conf with:

[Interface] Address = 10.16.223.98 PrivateKey = XXXXX DNS = 10.0.0.243 [Peer] PersistentKeepalive = 25 PublicKey = XXXXXX AllowedIPs = 0.0.0.0/0 Endpoint = 178.249.214.49:1337

And for the logs I can see that gluetun is correctly reading that file because it is using that endpoint

I am receiving the following message:

2024-05-10T01:56:22Z INFO [wireguard] Wireguard setup is complete. Note Wireguard is a silent protocol and it may or may not work, without giving any error message. Typically i/o timeout errors indicate the Wireguard connection is not working.

And after that a lot of timeout errors and restarts

I went into the container console to check if there is connection to internet (ping google.com) and there is not.

What am I missing ?

Thanks for the attention

qdm12 commented 3 months ago

Let's continue the conversation on (still unresolved) #2320 regarding PIA & Wireguard. Thanks!

github-actions[bot] commented 3 months ago

Closed issues are NOT monitored, so commenting here is likely to be not seen. If you think this is still unresolved and have more information to bring, please create another issue.

This is an automated comment setup because @qdm12 is the sole maintainer of this project which became too popular to monitor issues closed.

qdm12 commented 3 months ago

Note #2320 is now resolved, and the wiki (PIA's page) updated on how to do this!