From da8520e202604f64106c38e8e2adaa6f164d499b Mon Sep 17 00:00:00 2001 From: Tim Wilkinson Date: Sun, 24 Sep 2023 20:40:28 -0700 Subject: [PATCH] Supernode improvements (#945) * Supernode tunnels are always "perfect" * Move Super Mesh button onto mesh page --- files/usr/lib/lua/aredn/nav/user/23supermesh.lua | 8 -------- files/usr/local/bin/olsrd-config | 3 ++- files/www/cgi-bin/advancedconfig | 11 ++++------- files/www/cgi-bin/mesh | 8 +++++++- 4 files changed, 13 insertions(+), 17 deletions(-) delete mode 100755 files/usr/lib/lua/aredn/nav/user/23supermesh.lua diff --git a/files/usr/lib/lua/aredn/nav/user/23supermesh.lua b/files/usr/lib/lua/aredn/nav/user/23supermesh.lua deleted file mode 100755 index 31315317..00000000 --- a/files/usr/lib/lua/aredn/nav/user/23supermesh.lua +++ /dev/null @@ -1,8 +0,0 @@ -if nixio.fs.stat("/tmp/dnsmasq.d/supernode.conf") then - local ip = read_all("/tmp/dnsmasq.d/supernode.conf"):match("^#(%S+)") - if ip then - return { href = "http://" .. ip .. "/cgi-bin/mesh", display = "Super Mesh", hint = "See what is on the supernode mesh" } - end -elseif uci.cursor():get("aredn", "@supernode[0]", "enable") == "1" then - return { href = "/cgi-bin/mesh", display = "Super Mesh", hint = "See what is on the supernode mesh" } -end diff --git a/files/usr/local/bin/olsrd-config b/files/usr/local/bin/olsrd-config index be639fea..94c51c77 100755 --- a/files/usr/local/bin/olsrd-config +++ b/files/usr/local/bin/olsrd-config @@ -349,7 +349,8 @@ if #tunnels > 0 then print([[Interface]] .. tuns) print([[{]]) print([[ Ip4Broadcast 255.255.255.255]]) - if not tun_weight or tun_weight < 1 then + local is_supernode = cursor:get("aredn", "@supernode[0]", "enable") == "1" + if not tun_weight or tun_weight < 1 or is_supernode then print([[ Mode "ether"]]) elseif tun_weight > 1 then print([[ LinkQualityMult default ]] .. (1 / tun_weight)) diff --git a/files/www/cgi-bin/advancedconfig b/files/www/cgi-bin/advancedconfig index 4912aed0..63eaf290 100755 --- a/files/www/cgi-bin/advancedconfig +++ b/files/www/cgi-bin/advancedconfig @@ -269,7 +269,8 @@ local settings = { type = "string", desc = "Tunnel Weight specifies the cost of using a tunnel. The higher the number, the less likely a tunnel is used.

aredn.@tunnel[0].weight", default = "1", - needreboot= true + needreboot= true, + condition = "not isSupernode()" }, { category = "Tunnel Options", @@ -581,12 +582,8 @@ function supportsVLANChange() return false end -function canBeSupernode() - local board = aredn.hardware.get_board_type() - if board == "mikrotik,hap-ac2" or board == "qemu-standard-pc-i440fx-piix-1996" then - return true - end - return false +function isSupernode() + return cursor_get("aredn", "@supernode[0]", "enable") == "1" end -- callbacks diff --git a/files/www/cgi-bin/mesh b/files/www/cgi-bin/mesh index 834717bf..039ff59a 100755 --- a/files/www/cgi-bin/mesh +++ b/files/www/cgi-bin/mesh @@ -511,7 +511,13 @@ else html.print("  ") html.print("") end - +if nixio.fs.stat("/tmp/dnsmasq.d/supernode.conf") then + local ip = read_all("/tmp/dnsmasq.d/supernode.conf"):match("^#(%S+)") + if ip then + html.print("  ") + html.print("") + end +end html.print("  ") html.print("") html.print("  ")