linuxserver / docker-wireguard

GNU General Public License v3.0
2.9k stars 360 forks source link

Template peer info appended to the server config #345

Open nonk123 opened 2 months ago

nonk123 commented 2 months ago

linuxserver.io



Description:

[Peer] blocks inside wg0.conf used to be hardcoded. But there are very specific usecases where this might not be desirable. So, these blocks are now templated.

Benefits of this PR and context:

Closes #335.

How Has This Been Tested?

Running this command produced equivalent configuration files before and after the changes made, except the friendly_name = line:

docker run -d \
  --name=wireguard \
  --cap-add=NET_ADMIN \
  --cap-add=SYS_MODULE \
  -e PUID=1000 \
  -e PGID=1000 \
  -e TZ=Europe/Moscow \
  -e SERVERPORT=51820 \
  -e PEERS=TheA,TheB,TheC \
  -e INTERNAL_SUBNET=10.13.13.0 `#optional` \
  -e ALLOWEDIPS=0.0.0.0/0 `#optional` \
  -e PERSISTENTKEEPALIVE_PEERS=TheC \
  -e LOG_CONFS=true `#optional` \
  -p 51820:51820/udp \
  -v wg-thing:/config \
  -v /lib/modules:/lib/modules `#optional` \
  --sysctl="net.ipv4.conf.all.src_valid_mark=1" \
  --restart unless-stopped \
  lscr.io/linuxserver/wireguard:latest

Here's a diff with some dummy keys:

4c4
< PrivateKey = SKO8MxSnzOCPiNoq/HIvyATfnksEINWKXk4IC4Kp3mk=
---
> PrivateKey = iIh6dFt4IJ3DwKp8GvZh2+DUWwUWp2IJD/sYAART/ks=
9,11c9,11
< # peer_TheA
< PublicKey = dS3HgHgvrFmjKlPlcB8juERrTHu2WlL5kSipLODgaDk=
< PresharedKey = zRC7UcvqIWIIsVchmtsSAYC4Qa1G+OPLXdBMHUUulS0=
---
> # friendly_name = peer_TheA
> PublicKey = 3+zJGVJp+Pmtw5aKXg5hH00X79vmV7FV7yoioB3mvE0=
> PresharedKey = OeE/fo4SI4KYwrSATVDViba50If7t635aZFcTeCWBMk=
15,17c15,17
< # peer_TheB
< PublicKey = mUEENNG9zXmq8RO4qdHkcbkO0h2mSYT1ewbyOebQVgQ=
< PresharedKey = svDHI0L1NpVYwrpsNguxJW0+bqNzXFMCp/fCd6QBD2s=
---
> # friendly_name = peer_TheB
> PublicKey = B13Es6dp2QtcNlUi5yxKZQHCkl7n0rMzgosBKCKyBXE=
> PresharedKey = mOrHbrB4NdoOjgZIxXy/UmwBhtK1kfen6lXdIesJgSk=
21,23c21,23
< # peer_TheC
< PublicKey = NgrQMdiotUWc3KP9xgTHur8KEoCvILTq0mIO78e8fkA=
< PresharedKey = /a7lxaQFOGiI+sC72dIghwHsSAfpCdc/btTweM6LK20=
---
> # friendly_name = peer_TheC
> PublicKey = 5SF4exknx+na5gPpGf9KAkgVy806npfRmKob9eg4wBE=
> PresharedKey = yDoiF2IVwCZRMNqQcudjDw2nwdKfKMRjrsM1qdlwczE=

Source / References:

See: #335.

LinuxServer-CI commented 2 months ago

I am a bot, here is the pushed image/manifest for this PR:

ghcr.io/linuxserver/lspipepr-wireguard:1.0.20210914-r4-pkg-3d758f73-dev-ed2bf04cf979160318638a83d3f494d50a2ba497-pr-345

Pingachguk commented 2 months ago

русские есть?

LinuxServer-CI commented 2 months ago

I am a bot, here is the pushed image/manifest for this PR:

ghcr.io/linuxserver/lspipepr-wireguard:1.0.20210914-r4-pkg-256aa340-dev-bc415a4d17c4e39620762696e92607229549f15e-pr-345

LinuxServer-CI commented 1 month ago

I am a bot, here is the pushed image/manifest for this PR:

ghcr.io/linuxserver/lspipepr-wireguard:1.0.20210914-r4-pkg-4ea10a38-dev-1c6786aa6ab32c36f91a41606ba6cff1f75ad7c1-pr-345

LinuxServer-CI commented 6 days ago

I am a bot, here is the pushed image/manifest for this PR:

ghcr.io/linuxserver/lspipepr-wireguard:1.0.20210914-r4-pkg-5cdc355d-dev-9af07c2a1c620be62196b43bcc5b1c00082f3f55-pr-345