Generate new keys on every new connection.
Signed-off-by: Nick Hainke <vincent@systemli.org>
delete_wg_interface() {
ip link del dev "$1"
+ [ -f "/tmp/run/wgserver/$1.key" ] && rm "/tmp/run/wgserver/$1.key"
+ [ -f "/tmp/run/wgserver/$1.pub" ] && rm "/tmp/run/wgserver/$1.pub"
}
check_wg_neighbors() {
option base_v4prefix '10.0.0.1/24'
option wg_key '/root/wg.key'
option wg_pub '/root/wg.pub'
+ option wg_tmp_key '1'
option timeout_handshake '600'
gw_key=$(uci get wgserver.@server[0].wg_key)
gw_pub=$(uci get wgserver.@server[0].wg_pub)
+
+ if [ $(uci get wgserver.@server[0].wg_tmp_key) -eq 1]; then
+ [ -d "/tmp/run/wgserver" ] || mkdir -p /tmp/run/wgserver
+ gw_key="/tmp/run/wgserver/${ifname}.key"
+ gw_pub="/tmp/run/wgserver/${ifname}.pub"
+ wg genkey | tee $gw_key | wg pubkey > $gw_pub
+ fi
wg_server_pubkey=$(cat $gw_pub)
# create wg tunnel