Skip to content

Commit 2f13815

Browse files
committed
feat: add server-info command to lookup server details from metadata API
1 parent 0af6e60 commit 2f13815

File tree

3 files changed

+320
-300
lines changed

3 files changed

+320
-300
lines changed

README.md

Lines changed: 54 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,11 @@
4747
- Supports running as systemd unit (natively and as podman container)
4848
- Supports roaming clients
4949

50-
> **Note**
51-
>
52-
> For old OpenVPN based container's documentation,
53-
> See [here](https://github.com/tprasadtp/protonvpn-docker/tree/release/v5).
54-
5550
## Container Images
5651

57-
> **Warning**
52+
> [!WARNING]
5853
>
59-
> * [gVisor](https://gvisor.dev) runtime is **NOT** supported!
60-
> * cgroup v1 API is not supported.
54+
> [gVisor](https://gvisor.dev) and cgroup v1 runtime is **NOT** supported!
6155
6256
Images are published at [ghcr.io/tprasadtp/protonwire][ghcr].
6357

@@ -66,15 +60,16 @@ Images are published at [ghcr.io/tprasadtp/protonwire][ghcr].
6660
- If using Debian 11 (Buster) or later, Raspberry Pi OS (Buster) or later, Fedora, ArchLinux, Linux Mint 20.x or later, RHEL 9 or later, Alma Linux 9 or later, CentOS 9 Stream, Ubuntu 20.04 or later have the required kernel module built-in.
6761
- Kernel versions 5.6 or later.
6862
- If **NONE** of the above conditions can be satisfied, install WireGuard. Your distribution might already package DKMS module or provide signed kernels with WireGuard built-in. Visit https://www.wireguard.com/install/ for more info.
69-
> **Note**
70-
>
71-
> If running as a container, Wireguard **MUST** be installed on the host, **not** the container.
72-
7363
- To check current kernel version run,
7464
```bash
7565
uname -r
7666
```
7767

68+
> [!IMPORTANT]
69+
>
70+
> If running as a container, Wireguard **MUST** be installed on the host, **not** the container.
71+
72+
7873
## Generating WireGuard Private Key
7974

8075
- Log in to ProtonVPN and go to **Downloads****WireGuard configuration**.
@@ -136,7 +131,7 @@ Though server name like `NL#1`(or `NL-1`) is supported it is not recommended.
136131
137132
## KillSwitch
138133
139-
> **Warning**
134+
> [!WARNING]
140135
>
141136
> This feature is experimental and is **NOT** covered by semver compatibility guarantees.
142137
@@ -165,7 +160,7 @@ or: protonwire [OPTIONS...] c|connect [SERVER]
165160
or: protonwire [OPTIONS...] d|disconnect
166161
or: protonwire [OPTIONS...] check
167162
or: protonwire [OPTIONS...] disable-killswitch
168-
or: protonwire [OPTIONS...] help
163+
or: protonwire [OPTIONS...] server-info [SERVER]
169164
170165
Options:
171166
-k, --private-key FILE|KEY Wireguard private key or
@@ -178,7 +173,7 @@ Options:
178173
--check-interval INT IP check interval in seconds (default 60)
179174
--check-url URL IP check endpoint URL
180175
--skip-dns-config Skip configuring DNS.
181-
(Useful for Kubernetes and Nomad)
176+
(Useful for Kubernetes and Consul)
182177
--kill-switch Enable killswitch (Experimental)
183178
--p2p Verify if specified server supports P2P
184179
--streaming Verify if specified server supports streaming
@@ -201,7 +196,7 @@ Environment:
201196
WIREGUARD_PRIVATE_KEY WireGuard private key or file
202197
PROTONVPN_SERVER ProtonVPN server
203198
IPCHECK_INTERVAL Custom IP check interval in seconds (default 60)
204-
IPCHECK_URL IP check endpoint URL (must be secure)
199+
IPCHECK_URL IP check endpoint URL (must be https://)
205200
SKIP_DNS_CONFIG Set to '1' to skip configuring DNS
206201
KILL_SWITCH Set to '1' to enable killswitch (Experimental)
207202
DEBUG Set to '1' to enable debug logs
@@ -216,12 +211,6 @@ Same can be used as liveness probe and readiness probe for Kubernetes.
216211
217212
## Docker Compose
218213
219-
> **Note**
220-
>
221-
> Because docker does not provide a reliable way to bring up containers in an ordered
222-
> manner and lacks `sd_notify` support for containers(see bugs like #178),
223-
> it is recommended to use [podman](#podman) with systemd.
224-
225214
If entire stack is in a single compose file, then `network_mode: service:protonwire` on the services which should be routed via VPN. If the VPN stack is **NOT** in same compose file use `network_mode: container:<protonwire-container-name>`. Use [`podman-compose`](https://github.com/containers/podman-compose) for use with podman.
226215
227216
As an example, run caddy web-server, proxying https://ip.me, via VPN using the compose config given below. Once the stack is up, visiting the http://localhost:8000, or `curl -s http://localhost:8000` should show VPN's country and IP address.
@@ -278,7 +267,7 @@ services:
278267
<!--diana::dynamic:protonwire-sample-compose-file:end-->
279268

280269

281-
> **Note**
270+
> [!IMPORTANT]
282271
>
283272
> - It is **essential** to expose/publish port(s) _on protonwire container_, instead of application container.
284273
> - **SHOULD NOT** run the container as privileged. Adding capability `CAP_NET_ADMIN` **AND** defined `sysctls` should be sufficient.
@@ -325,18 +314,6 @@ This section covers running containers via podman. But for deployments use [podm
325314
ghcr.io/tprasadtp/protonwire:7
326315
```
327316
328-
> **Note**
329-
>
330-
> * This example publishes container port 8000 to host port 8000.
331-
> You **MUST** change these to match your application container(s).
332-
> * To publish additional ports from other containers using this VPN
333-
> (usually done via argument `--publish <host-port>:<container-port>`),
334-
> it **MUST** be done on _protonwire_ container.
335-
> * `--sysctl` flags are important! without these, container cannot
336-
> create/manage WireGuard interface.
337-
> * `mode=600` in secret mount is important, as script refuses to use
338-
> private key with insecure permissions.
339-
340317
- Create app(s) sharing network namespace with `protonwire` container. As an example, we are using caddy
341318
to proxy website which shows IP info. Replace these with your application container(s) like [pyload](https://github.com/pyload/pyload#docker-images), [firefox](https://docs.linuxserver.io/images/docker-firefox) etc.
342319
@@ -353,6 +330,19 @@ to proxy website which shows IP info. Replace these with your application contai
353330
354331
- Verify that application containers are using VPN by visiting http://<hostname or IP>:8000.
355332
333+
> [!IMPORTANT]
334+
>
335+
> * The above example publishes container port 8000 to host port 8000.
336+
> You **MUST** change these to match your application container(s).
337+
> * To publish additional ports from other containers using this VPN
338+
> (usually done via argument `--publish <host-port>:<container-port>`),
339+
> it **MUST** be done on _protonwire_ container.
340+
> * `--sysctl` flags are important! without these, container cannot
341+
> create/manage WireGuard interface.
342+
> * `mode=600` in secret mount is important, as script refuses to use
343+
> private key with insecure permissions.
344+
345+
356346
## Running podman containers with systemd
357347
358348
This is a bit more involved than just running a podman/docker run command.
@@ -363,7 +353,7 @@ to start only when protonwire is up **and** healthy.
363353
- Dependency ordering during upgrades.
364354
- Use well known systemctl to see status of containers.
365355
366-
> **Warning**
356+
> [!IMPORTANT]
367357
>
368358
> - This feature is experimental and is **NOT** covered by semver compatibility guarantees.
369359
> - Only podman version 4.5 or later is supported due to missing.
@@ -507,7 +497,7 @@ WantedBy=default.target
507497
```
508498
<!--diana::dynamic:protonwire-container-unit-file:end-->
509499
510-
> **Note**
500+
> [!IMPORTANT]
511501
>
512502
> * This example publishes container port 8000 to host port 8000.
513503
> You **MUST** change these to match your application container(s).
@@ -661,12 +651,6 @@ Visit http://[host IP or localhost]:8000 in your browser and it should show VPN'
661651
</a>
662652
</p>
663653

664-
> **Note**
665-
>
666-
> Because docker does not provide a reliable way to bring up containers in an ordered
667-
> manner and lacks `sd_notify` support for containers(see bugs like #178),
668-
> it is recommended to use [podman](#podman) with systemd.
669-
670654
- Pull docker image (if required)
671655
```bash
672656
docker pull ghcr.io/tprasadtp/protonwire:latest
@@ -686,14 +670,14 @@ Visit http://[host IP or localhost]:8000 in your browser and it should show VPN'
686670
--mount type=bind,src=<absolute-path-to-key-file>,dst=/etc/protonwire/private-key,readonly \
687671
ghcr.io/tprasadtp/protonwire:latest
688672
```
689-
> **Warning**
690-
>
691-
> - To publish additional ports from other containers using this VPN, it **MUST** be done
692-
> on the `protonwire` container!
693-
> - `--sysctl` and `--cap-add` flags are important! without these, container cannot create
694-
> or manage WireGuard interfaces or routing.
695-
> - docker rootless should also work just fine for most users, but is considered experimental.
696673

674+
> [!IMPORTANT]
675+
>
676+
> - To publish additional ports from other containers using this VPN, it **MUST** be done
677+
> on the `protonwire` container!
678+
> - `--sysctl` and `--cap-add` flags are important! without these, container cannot create
679+
> or manage WireGuard interfaces or routing.
680+
> - docker rootless should also work just fine for most users, but is considered experimental.
697681

698682
- To use VPN in other container(s), use `--net=container:protonwire` flag.
699683
For example, we can run caddy to proxy `https://ip.me/` via VPN. Visiting http://localhost:8000, or `curl http://localhost:8000` should show VPN's country and IP address.
@@ -711,10 +695,6 @@ For example, we can run caddy to proxy `https://ip.me/` via VPN. Visiting http:/
711695
--to https://ip.me:443
712696
```
713697
714-
> **Note**
715-
>
716-
> There are no port mappings done here! It should be done on the VPN container!
717-
718698
## Dependencies
719699
720700
Following dependencies are **in addition** to WireGuard support in Kernel.
@@ -786,7 +766,7 @@ if running as systemd unit outside of containers.
786766
sudo protonwire check
787767
```
788768
789-
> **Note**
769+
> [!TIP]
790770
>
791771
> Add `--debug` flag to see debug logs.
792772
@@ -795,21 +775,25 @@ if running as systemd unit outside of containers.
795775
Provides rich systemd integration. Connected server kill-switch state is displayed with
796776
`systemctl status protonwire`. For running containers as systemd unit see [podman-systemd-integration](#podman-systemd-integration)
797777
798-
<pre><font color="#B8BB26"><b>vagrant@debian-minimal</b></font>:<font color="#83A598"><b>~</b></font>$ systemctl status protonwire --no-pager
799-
<font color="#B8BB26"><b>●</b></font> protonwire.service - ProtonVPN Wireguard Client
800-
Loaded: loaded (/usr/local/lib/systemd/system/protonwire.service; disabled; vendor preset: enabled)
801-
Active: <font color="#B8BB26"><b>active (running)</b></font> since Wed 2023-04-12 21:17:31 UTC; 2min 47s ago
778+
<pre><font color="#26A269">prasad@fedora</font>:<font color="#26A269">~/Git/protonvpn-docker</font>$ systemctl status protonwire
779+
<font color="#26A269"><b>●</b></font> protonwire.service - ProtonVPN Wireguard Client
780+
Loaded: loaded (/usr/local/lib/systemd/system/protonwire.service; <font color="#26A269"><b>enabled</b></font>; preset: <font color="#D7D75F"><b>disabled</b></font>)
781+
Drop-In: /etc/systemd/system/protonwire.service.d
782+
└─10-protonwire-private-key.conf
783+
/usr/lib/systemd/system/service.d
784+
└─10-timeout-abort.conf
785+
Active: <font color="#26A269"><b>active (running)</b></font> since Fri 2024-02-16 22:19:58 CET; 2min 40s ago
802786
Docs: man:protonwire(1)
803787
https://github.com/tprasadtp/protonvpn-docker
804-
Main PID: 7298 (protonwire)
805-
Status: &quot;Connected to nl-free-127.protonvpn.net (via 185.107.56.83, with KillSwitch)&quot;
806-
IP: 36.4K in, 11.6K out
807-
Tasks: 2 (limit: 2336)
808-
Memory: 2.3M
809-
CPU: 2.302s
788+
Main PID: 13815 (protonwire)
789+
Status: &quot;<font color="#2AA1B3"><b>Connected to node-nl-03.protonvpn.net (as 89.39.107.205, with KillSwitch)</b></font>&quot;
790+
IP: 24.3K in, 8.4K out
791+
Tasks: 2 (limit: 4623)
792+
Memory: 3.8M
793+
CPU: 2.546s
810794
CGroup: /system.slice/protonwire.service
811-
├─7298 /bin/bash /usr/local/bin/protonwire connect --systemd --logfmt journald
812-
└─8236 sleep 60
795+
├─<font color="#8A8A8A">13815 /bin/bash /usr/local/bin/protonwire connect --systemd --logfmt journald</font>
796+
└─<font color="#8A8A8A">14188 sleep 60</font>
813797
</pre>
814798
815799
### Requirements
@@ -866,9 +850,6 @@ Provides rich systemd integration. Connected server kill-switch state is display
866850
sudo systemctl start protonwire
867851
```
868852
- Stop VPN service via
869-
> **Warning**
870-
>
871-
> Units bound to protonwire unit will also be stopped.
872853

873854
```bash
874855
sudo systemctl stop protonwire
@@ -880,6 +861,7 @@ Provides rich systemd integration. Connected server kill-switch state is display
880861
```
881862

882863
- To check logs, use `journalctl -u protonwire`.
864+
883865
- Disable VPN service via
884866
```bash
885867
sudo systemctl disable --now protonwire
@@ -896,7 +878,7 @@ Provides rich systemd integration. Connected server kill-switch state is display
896878

897879
## systemd-resolved Split Horizon DNS
898880

899-
> **Note**
881+
> [!IMPORTANT]
900882
>
901883
> Requires systemd version 244 or later.
902884

@@ -924,7 +906,7 @@ This setup ensures that service depending on VPN will be **ONLY** started when `
924906

925907
If system package already provides a systemd unit file for the service, use [drop-in][] units to configure dependencies.
926908

927-
> **Note**
909+
> [!IMPORTANT]
928910
>
929911
> Don't forget to run `sudo systemctl daemon-reload` upon updating/installing unit files.
930912

docs/faq.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@ This typically happens on a older machine or NAS/embedded devices
2020
as Wireguard support might not be present in the kernel.
2121
Please visit https://www.wireguard.com/install/ or contact device manufacturer.
2222

23+
## Using systemd credentials
24+
25+
- Create drop-in unit directory
26+
27+
```
28+
sudo mkdir -p /etc/systemd/system/protonwire.service.d
29+
```
30+
31+
- Create encrypted credentials
32+
```
33+
sudo sh -c 'systemd-ask-password -n | (printf "[Service]\n" && systemd-creds encrypt --name=protonwire-private-key -p - -) > /etc/systemd/system/protonwire.service.d/10-protonwire-private-key.conf'
34+
```
35+
36+
- Reload systemd
37+
38+
```
39+
sudo systemctl daemon-reload
40+
```
41+
2342
## How to check if an address is being routed via VPN via CLI
2443
2544
- Run `ip route get <ip-address>`
@@ -201,7 +220,7 @@ You can use any of the following services for verification. They **MUST RETURN O
201220
* https://icanhazip.com/
202221
* https://checkip.amazonaws.com/
203222

204-
> **Warning**
223+
> [!WARNING]
205224
>
206225
> Do not use ip.me as health-check endpoint, as they seem to do
207226
> user agent whitelisting and return html page, when user agent

0 commit comments

Comments
 (0)