Skip to content

Commit ca08c54

Browse files
awlxGoliathLabsgoligogrische
authored
Upstream vpn package again (#38)
* Updated: checkout action * Update Makefile * Updated: checkout action ffka-gluon-web-usb-wan-hotplug: i18n/de.po: fix typo (#13) ffmuc-gluon-mesh-vpn-wireguard-vxlan: add package (#6) Co-authored-by: Annika Wickert <[email protected]> Co-authored-by: krombel <[email protected]> Co-authored-by: Martin Weinelt <[email protected]> Co-authored-by: lqb <[email protected]> Co-authored-by: lqb <[email protected]> Co-authored-by: Julian Labus <[email protected]> Co-authored-by: Tristan Helmich <[email protected]> Co-authored-by: goligo <[email protected]> Update Makefile * Wonder how that worked * Remove reverse synchronization of gluon.mesh_vpn.enabled * Renamed ffmuc-gluon-mesh-vpn-wireguard-vxlan to ffmuc-mesh-vpn-wireguard-vxlan * Only add ip6tables rule, if not set already For each reconnection checkuplink was adding an additional entry to the INPUT chain in ip6tables. In case a node does not have WAN connection, but accidentally enabled mesh over VPN, this adding 1440 rules per day or about 40k rules within a month. * Adapted checkuplink for changes nslookup output in OpenWrt 22.03 In OpenWrt 22.03 the output of nslookup as a colon after "Address", so it was not matched correctly by our regular expression. * Add mesh-vpn to BATMAN, as Gluon does not do it anymore Gluon v2022.1 has been refactored in a way, that a mesh-vpn interface is no longer in the network configuration and no longer added to BATMAN automatically, so we now add it explicitly in our script. * Revert "Add mesh-vpn to BATMAN, as Gluon does not do it anymore" This reverts commit fd5f1c7. * Add mtu() to wireguard provider API Required by recent upstream changes: freifunk-gluon/gluon@7c81897 * Add compatibility variable for enabling mesh vpn * Add wireguard_pubkey.sh to be more compatible Required as part of gluon-mesh-vpn-core: https://github.com/freifunk-gluon/gluon/blob/v2022.1/package/gluon-mesh-vpn-core/files/lib/netifd/proto/gluon_wireguard.sh#L32 * Fix broken grep This fixes the broken grep to find the batctl gw --------- Co-authored-by: Felix Golatofski <[email protected]> Co-authored-by: goligo <[email protected]> Co-authored-by: Grische <[email protected]>
1 parent b2864f5 commit ca08c54

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
name: Lua
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v1
11+
- uses: actions/checkout@v2
1212
- name: Install Dependencies
1313
run: sudo apt-get install lua-check
1414
- name: Lint Lua

ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink

+8-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ check_address_family() {
2525
# Check if we have a default route for v6 if not fallback to v4
2626
defgw=$(ip -6 route show table 1 | grep 'default via')
2727
if [ "$?" -eq "0" ]; then
28-
local ipv6="$(gluon-wan nslookup $gateway | grep 'Address [0-9]' | egrep -o '([a-f0-9:]+:+)+[a-f0-9]+')"
28+
local ipv6="$(gluon-wan nslookup $gateway | grep 'Address:\? [0-9]' | egrep -o '([a-f0-9:]+:+)+[a-f0-9]+')"
2929
echo [$ipv6]$(echo $peer_endpoint | egrep -oe :[0-9]+$)
3030
else
31-
local ipv4="$(gluon-wan nslookup $gateway | grep 'Address [0-9]' | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")"
31+
local ipv4="$(gluon-wan nslookup $gateway | grep 'Address:\? [0-9]' | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")"
3232
echo $ipv4$(echo $peer_endpoint | egrep -oe :[0-9]+$)
3333
fi
3434

@@ -52,7 +52,7 @@ if [ "$(uci get wireguard.mesh_vpn.enabled)" == "true" ] || [ "$(uci get wiregua
5252
# Check connectivity to supernode
5353
wget http://[$(wg | grep fe80 | awk '{split($3,A,"/")};{print A[1]}')%$MESH_VPN_IFACE]/ --timeout=5 -O/dev/null -q
5454
if [ "$?" -eq "0" ]; then
55-
GWMAC=$(batctl gwl | grep \* | awk '{print $2}')
55+
GWMAC=$(batctl gwl | awk '/[*]/{print $2}')
5656
batctl ping -c 5 $GWMAC &> /dev/null
5757
if [ "$?" -eq "0" ]; then
5858
CONNECTED=1
@@ -107,7 +107,11 @@ if [ "$(uci get wireguard.mesh_vpn.enabled)" == "true" ] || [ "$(uci get wiregua
107107

108108
# We need to allow incoming vxlan traffic on mesh iface
109109
sleep 10
110-
ip6tables -I INPUT 1 -i $MESH_VPN_IFACE -m udp -p udp --dport 8472 -j ACCEPT
110+
RULE="-i $MESH_VPN_IFACE -m udp -p udp --dport 8472 -j ACCEPT"
111+
ip6tables -C INPUT $RULE
112+
if [ $? -ne 0 ]; then
113+
ip6tables -I INPUT 1 $RULE
114+
fi
111115

112116
# Bring up VXLAN
113117
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
/usr/bin/wg show wg_mesh_vpn public-key

ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/upgrade/400-mesh-vpn-wireguard

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ end)
1717

1818
local mesh_enabled = uci:get_bool('gluon', 'mesh_vpn', 'enabled') -- default
1919
or uci:get_bool('fastd', 'mesh_vpn', 'enabled') --migration
20+
or not uci:get_bool('network', 'wg_mesh', 'disabled') --compatiblity with upstream
2021
or wg_enabled -- specific config
2122

2223
uci:section("wireguard", "wireguard", "mesh_vpn", {

ffmuc-mesh-vpn-wireguard-vxlan/luasrc/usr/lib/lua/gluon/mesh-vpn/provider/wireguard.lua

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ local vpn_core = require 'gluon.mesh-vpn'
77
local M = {}
88

99
function M.public_key()
10-
return util.trim(util.exec('/usr/bin/wg show wg_mesh_vpn public-key'))
10+
local key = util.trim(util.exec("/lib/gluon/mesh-vpn/wireguard_pubkey.sh"))
11+
12+
if key == '' then
13+
key = nil
14+
end
15+
16+
return key
1117
end
1218

1319
function M.enable(val)
@@ -33,4 +39,8 @@ function M.set_limit(ingress_limit, egress_limit)
3339
uci:save('simple-tc')
3440
end
3541

42+
function M.mtu()
43+
return site.mesh_vpn.wireguard.mtu()
44+
end
45+
3646
return M

0 commit comments

Comments
 (0)