Skip to content

Commit 9b171ca

Browse files
hickeyaanon4
andcommitted
feat: discover zone name from /etc/config.mesh (#36)
The zone name has traditionally been discovered by interogating /etc/config/services. The AREDN firmware is removing this file in favor of /etc/config.mesh/_setup.services.{dmz|nat}. This fix updates the location where the zone name is discovered. Signed-off-by: Gerard Hickey <[email protected]> Co-authored-by: Tim Wilkinson <[email protected]>
1 parent 3ef31dc commit 9b171ca

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/data/www/cgi-bin/meshchatlib.lua

+14-6
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,19 @@ function node_name()
5656
end
5757

5858
function zone_name()
59-
for line in io.lines("/etc/config/services")
60-
do
61-
local zone = line:match(":8080/meshchat|tcp|(.+)")
62-
if zone then
63-
return zone
59+
local dmz_mode = uci.cursor("/etc/config.mesh"):get("aredn", "@dmz[0]", "mode")
60+
local servfile = "/etc/config.mesh/_setup.services.nat"
61+
-- LAN mode is not set to NAT
62+
if dmz_mode ~= "0" then
63+
servfile = "/etc/config.mesh/_setup.services.dmz"
64+
end
65+
if nixio.fs.access(servfile) then
66+
for line in io.lines(servfile)
67+
do
68+
local zone = line:match("^(.*)|.*|.*|.*|.*|meshchat$")
69+
if zone then
70+
return zone
71+
end
6472
end
6573
end
6674
return "MeshChat"
@@ -220,5 +228,5 @@ function node_list()
220228
end
221229

222230
function str_escape(str)
223-
return str:gsub("%(", "%%("):gsub("%)", "%%)"):gsub("%%", "%%%%"):gsub("%.", "%%."):gsub("%+", "%%+"):gsub("-", "%%-"):gsub("%*", "%%*"):gsub("%[", "%%["):gsub("%?", "%%?"):gsub("%^", "%%^"):gsub("%$", "%%$")
231+
return str:gsub("%(", "%%("):gsub("%)", "%%)"):gsub("%%", "%%%%"):gsub("%.", "%%."):gsub("%+", "%%+"):gsub("-", "%%-"):gsub("%*", "%%*"):gsub("%[", "%%["):gsub("%?", "%%?"):gsub("%^", "%%^"):gsub("%$", "%%$")
224232
end

0 commit comments

Comments
 (0)