diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 32d5ed05..3ee8adf3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,7 +8,7 @@ jobs: name: Lua runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Install Dependencies run: sudo apt-get install lua-check - name: Lint Lua diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink index 537107f8..79331777 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink +++ b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink @@ -25,10 +25,10 @@ check_address_family() { # Check if we have a default route for v6 if not fallback to v4 defgw=$(ip -6 route show table 1 | grep 'default via') if [ "$?" -eq "0" ]; then - local ipv6="$(gluon-wan nslookup $gateway | grep 'Address [0-9]' | egrep -o '([a-f0-9:]+:+)+[a-f0-9]+')" + local ipv6="$(gluon-wan nslookup $gateway | grep 'Address:\? [0-9]' | egrep -o '([a-f0-9:]+:+)+[a-f0-9]+')" echo [$ipv6]$(echo $peer_endpoint | egrep -oe :[0-9]+$) else - local ipv4="$(gluon-wan nslookup $gateway | grep 'Address [0-9]' | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")" + local ipv4="$(gluon-wan nslookup $gateway | grep 'Address:\? [0-9]' | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")" echo $ipv4$(echo $peer_endpoint | egrep -oe :[0-9]+$) fi @@ -52,7 +52,7 @@ if [ "$(uci get wireguard.mesh_vpn.enabled)" == "true" ] || [ "$(uci get wiregua # Check connectivity to supernode wget http://[$(wg | grep fe80 | awk '{split($3,A,"/")};{print A[1]}')%$MESH_VPN_IFACE]/ --timeout=5 -O/dev/null -q if [ "$?" -eq "0" ]; then - GWMAC=$(batctl gwl | grep \* | awk '{print $2}') + GWMAC=$(batctl gwl | awk '/[*]/{print $2}') batctl ping -c 5 $GWMAC &> /dev/null if [ "$?" -eq "0" ]; then CONNECTED=1 @@ -107,7 +107,11 @@ if [ "$(uci get wireguard.mesh_vpn.enabled)" == "true" ] || [ "$(uci get wiregua # We need to allow incoming vxlan traffic on mesh iface sleep 10 - ip6tables -I INPUT 1 -i $MESH_VPN_IFACE -m udp -p udp --dport 8472 -j ACCEPT + RULE="-i $MESH_VPN_IFACE -m udp -p udp --dport 8472 -j ACCEPT" + ip6tables -C INPUT $RULE + if [ $? -ne 0 ]; then + ip6tables -I INPUT 1 $RULE + fi # Bring up VXLAN ip link add mesh-vpn type vxlan id "$(lua -e 'print(tonumber(require("gluon.util").domain_seed_bytes("gluon-mesh-vpn-vxlan", 3), 16))')" local $(interface_linklocal "$MESH_VPN_IFACE") remote $(uci get wireguard.peer_$PEER.link_address) dstport 8472 dev $MESH_VPN_IFACE diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/mesh-vpn/wireguard_pubkey.sh b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/mesh-vpn/wireguard_pubkey.sh new file mode 100644 index 00000000..8c3d57ca --- /dev/null +++ b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/mesh-vpn/wireguard_pubkey.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +/usr/bin/wg show wg_mesh_vpn public-key diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/upgrade/400-mesh-vpn-wireguard b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/upgrade/400-mesh-vpn-wireguard index ffd471c9..8f1adfc6 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/upgrade/400-mesh-vpn-wireguard +++ b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/upgrade/400-mesh-vpn-wireguard @@ -17,6 +17,7 @@ end) local mesh_enabled = uci:get_bool('gluon', 'mesh_vpn', 'enabled') -- default or uci:get_bool('fastd', 'mesh_vpn', 'enabled') --migration + or not uci:get_bool('network', 'wg_mesh', 'disabled') --compatiblity with upstream or wg_enabled -- specific config uci:section("wireguard", "wireguard", "mesh_vpn", { diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/usr/lib/lua/gluon/mesh-vpn/provider/wireguard.lua b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/usr/lib/lua/gluon/mesh-vpn/provider/wireguard.lua index 0c47d256..d54f651f 100644 --- a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/usr/lib/lua/gluon/mesh-vpn/provider/wireguard.lua +++ b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/usr/lib/lua/gluon/mesh-vpn/provider/wireguard.lua @@ -7,7 +7,13 @@ local vpn_core = require 'gluon.mesh-vpn' local M = {} function M.public_key() - return util.trim(util.exec('/usr/bin/wg show wg_mesh_vpn public-key')) + local key = util.trim(util.exec("/lib/gluon/mesh-vpn/wireguard_pubkey.sh")) + + if key == '' then + key = nil + end + + return key end function M.enable(val) @@ -33,4 +39,8 @@ function M.set_limit(ingress_limit, egress_limit) uci:save('simple-tc') end +function M.mtu() + return site.mesh_vpn.wireguard.mtu() +end + return M