Self hosted WireGuard VPN tunnel manager

Demo

# 1. Run this on the host you want to use as your VPN server. Assume the host has IP 1.2.3.4
~
❯ vpnathome tunnel davidhome 192.168.200.1/24
davidhome.vpnathome.com:udp/51820 -> 1.2.3.4:udp/51820

~
❯ vpnathome tunnel davidwork 192.168.201.1/24
davidwork.vpnathome.com:udp/51821 -> 1.2.3.4:udp/51821

~
❯ vpnathome -l
davidhome.vpnathome.com:udp/51820 -> 1.2.3.4:udp/51820
  192.168.200.1/24 assignments:
  192.168.200.1: localhost
davidwork.vpnathome.com:udp/51821 -> 1.2.3.4:udp/51821
  192.168.201.1/24 assignments:
  192.168.201.1: localhost

~
❯ vpnathome peer davidhome david
private key: YC6nVWXwXCz1L583HDMIDDU4TB1rAOjzjmyAAZNEwWc=
public key: YYOgeb4b/zJyMpdkUDe0hZo9/2DpajLXo5qivcq6djQ=
ip: 192.168.200.2/24

~
❯ vpnathome peer davidwork david
private key: wKcky0PdNFJ/jDfRLKjPKCT+v0aSK09nyzpcFNr+G3U=
public key: yaA4ra/dyZ042JkSUiZ35kKrNz95/zDtO/Rp8J9WoT0=
ip: 192.168.201.2/24

~
❯ vpnathome peer davidwork john
private key: 6DRSWbT2aoRJIDwg/g1I+0X3CyQsnu+dp+gajXoPmHI=
public key: gPki8fNnETWqswh1VJeD4vUqlwid2l1HTOADQivmvAQ=
ip: 192.168.201.3/24

~
❯ vpnathome -l
davidhome.vpnathome.com:udp/51820 -> 1.2.3.4:udp/51820
  192.168.200.1/24 assignments:
  192.168.200.1: localhost
  192.168.200.2: david
davidwork.vpnathome.com:udp/51821 -> 1.2.3.4:udp/51821
  192.168.201.1/24 assignments:
  192.168.201.1: localhost
  192.168.201.2: david
  192.168.201.3: john

# 2. Now the clients, david and john, can connect to the WireGuard server hosted at 1.2.3.4
#    by pointing their WireGuard client at davidhome.vpnathome.com:udp/51820 or davidwork.vpnathome.com:udp/51821
#    appropriately

# 3. When the VPN server has a change of public IP address (e.g. the new IP is 2.3.4.5),
#    it can update the reference hosted at vpnathome.com. This could be performed by a cron job every 10 minutes.
~
❯ vpnathome updateip

~
❯ vpnathome -l
davidhome.vpnathome.com:udp/51820 -> 2.3.4.5:udp/51820
  192.168.200.1/24 assignments:
  192.168.200.1: localhost
  192.168.200.2: david
davidwork.vpnathome.com:udp/51821 -> 2.3.4.5:udp/51821
  192.168.201.1/24 assignments:
  192.168.201.1: localhost
  192.168.201.2: david
  192.168.201.3: john