Skip to content

Commit 67ca600

Browse files
committed
allow using preshared keys
1 parent bd37d9c commit 67ca600

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ expected values are set by default, most with dummy default values.
7373
The endpoint of the VPN provider's WireGuard server.
7474
- `WIREGUARD_VPN_PUBLIC_KEY`:
7575
The public key of the VPN provider's WireGuard peer.
76+
- `WIREGUARD_VPN_PPRESHARED_KEY`:
77+
The preshared key of the VPN provider's WireGuard peer. Set to - to disable.
7678
- `WIREGUARD_ALLOWED_IPS`:
7779
Comma-separated list of IP addresses that may be contacted using the
7880
WireGuard interface. For a namespaced VPN, where the goal is to force all

bin/namespaced-wireguard-vpn-interface

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,21 @@ case "$1" in
99
up)
1010
ip link add "$WIREGUARD_NAME" mtu $WIREGUARD_INITIAL_MTU type wireguard || die
1111

12-
wg set "$WIREGUARD_NAME" \
13-
private-key <(echo "$WIREGUARD_PRIVATE_KEY") \
14-
peer "$WIREGUARD_VPN_PUBLIC_KEY" \
15-
endpoint "$WIREGUARD_ENDPOINT" \
16-
allowed-ips "$WIREGUARD_ALLOWED_IPS" || die
12+
if [ "$WIREGUARD_VPN_PRESHARED_KEY" == "-" ]
13+
then
14+
wg set "$WIREGUARD_NAME" \
15+
private-key <(echo "$WIREGUARD_PRIVATE_KEY") \
16+
peer "$WIREGUARD_VPN_PUBLIC_KEY" \
17+
endpoint "$WIREGUARD_ENDPOINT" \
18+
allowed-ips "$WIREGUARD_ALLOWED_IPS" || die
19+
else
20+
wg set "$WIREGUARD_NAME" \
21+
private-key <(echo "$WIREGUARD_PRIVATE_KEY") \
22+
peer "$WIREGUARD_VPN_PUBLIC_KEY" \
23+
preshared-key <(echo "$WIREGUARD_VPN_PRESHARED_KEY") \
24+
endpoint "$WIREGUARD_ENDPOINT" \
25+
allowed-ips "$WIREGUARD_ALLOWED_IPS" || die
26+
fi
1727

1828
ip link set "$WIREGUARD_NAME" netns "$NETNS_NAME" || die
1929

conf/namespaced-wireguard-vpn.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ WIREGUARD_ENDPOINT=1.2.3.4:56789
1313
# Public key of the VPN WireGuard peer
1414
WIREGUARD_VPN_PUBLIC_KEY=abcdFAKEefghFAKEijklFAKEmnopFAKEqrstFAKEuvw=
1515

16+
# Preshared key of the VPN WireGuard peer, set to - to disable
17+
WIREGUARD_VPN_PRESHARED_KEY=-
18+
1619
# Comma-separated list of allowed IP addresses for the VPN WireGuard interface
1720
WIREGUARD_ALLOWED_IPS=0.0.0.0/0,::0/0
1821

0 commit comments

Comments
 (0)