Support remote syslogging (#971)

This commit is contained in:
Tim Wilkinson 2023-12-06 12:19:18 -08:00 committed by GitHub
parent 44f7f43abb
commit 09ed681311
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 16 deletions

View File

@ -3,6 +3,9 @@ config 'system'
option 'timezone' '<time_zone>' option 'timezone' '<time_zone>'
option 'description' '<description_node>' option 'description' '<description_node>'
option 'compat_version' '<compat_version>' option 'compat_version' '<compat_version>'
option 'log_ip' '<remote_log_ip>'
option 'log_port' '<remote_log_port>'
option 'log_proto' '<remote_log_proto>'
config 'timeserver' 'ntp' config 'timeserver' 'ntp'
list 'server' '<ntp_server>' list 'server' '<ntp_server>'

View File

@ -217,6 +217,20 @@ else
cfg.lan_dhcp = 1 cfg.lan_dhcp = 1
end end
-- handle possible remote syslog
local remote_log = c:get("aredn", "@remotelog[0]", "url") or ""
local proto, ip, port = remote_log:match("^(.+)://(%d+%.%d+%.%d+%.%d+):(%d+)$")
port = tonumber(port)
if proto and (proto == "tcp" or proto == "udp") and (port > 0 and port < 65536) and validate_ip(ip) then
cfg.remote_log_ip = ip
cfg.remote_log_port = port
cfg.remote_log_proto = proto
else
deleteme.remote_log_ip = true
deleteme.remote_log_port = true
deleteme.remote_log_proto = true
end
-- verify that we have all the variables we need -- verify that we have all the variables we need
for file in nixio.fs.glob("/etc/config.mesh/*") for file in nixio.fs.glob("/etc/config.mesh/*")
do do

View File

@ -146,8 +146,8 @@ local settings = {
type = "string", type = "string",
desc = "<b>Maximum packet size</b> in bytes sent over WiFi (256 to 1500)<br><br><small>aredn.@lqm[0].mtu</small>", desc = "<b>Maximum packet size</b> in bytes sent over WiFi (256 to 1500)<br><br><small>aredn.@lqm[0].mtu</small>",
default = "1500", default = "1500",
postcallback = "changeMTU()", needreboot = true,
needreboot = true nodesetup = true
}, },
{ {
category = "Link Quality Settings", category = "Link Quality Settings",
@ -171,8 +171,8 @@ local settings = {
type = "boolean", type = "boolean",
desc = "<b>Allow other MESH nodes to use my WAN</b> - not recommended and OFF by default<br><br><small>aredn.@wan[0].olsrd_gw</small>", desc = "<b>Allow other MESH nodes to use my WAN</b> - not recommended and OFF by default<br><br><small>aredn.@wan[0].olsrd_gw</small>",
default = "0", default = "0",
postcallback = "changeWANGW()", needreboot = true,
needreboot = true nodesetup = true
}, },
{ {
category = "WAN Settings", category = "WAN Settings",
@ -180,8 +180,8 @@ local settings = {
type = "boolean", type = "boolean",
desc = "<b>Allow my LAN devices to access my WAN</b> - ON by default<br><br><small>aredn.@wan[0].lan_dhcp_route</small>", desc = "<b>Allow my LAN devices to access my WAN</b> - ON by default<br><br><small>aredn.@wan[0].lan_dhcp_route</small>",
default = "1", default = "1",
postcallback = "changeWANGW()", needreboot = true,
needreboot = true nodesetup = true
}, },
{ {
category = "WAN Settings", category = "WAN Settings",
@ -189,8 +189,8 @@ local settings = {
type = "boolean", type = "boolean",
desc = "<b>Provide default route to LAN devices</b> even when WAN access is disabled<br><br><small>aredn.@wan[0].lan_dhcp_defaultroute</small>", desc = "<b>Provide default route to LAN devices</b> even when WAN access is disabled<br><br><small>aredn.@wan[0].lan_dhcp_defaultroute</small>",
default = "0", default = "0",
postcallback = "changeWANGW()", needreboot = true,
needreboot = true nodesetup = true
}, },
{ {
category = "WAN Settings", category = "WAN Settings",
@ -201,7 +201,8 @@ local settings = {
condition = "supportsVLANChange()", condition = "supportsVLANChange()",
current = "currentWANVLAN()", current = "currentWANVLAN()",
postcallback = "changeWANVLAN()", postcallback = "changeWANVLAN()",
needreboot = true needreboot = true,
nodesetup = true
}, },
{ {
category = "WAN Settings", category = "WAN Settings",
@ -316,6 +317,16 @@ local settings = {
desc = "<b>IPERF Enable</b> allows the included iperf3 client/server<br><br><small>aredn.@iperf[0].enable</small>", desc = "<b>IPERF Enable</b> allows the included iperf3 client/server<br><br><small>aredn.@iperf[0].enable</small>",
default = "1" default = "1"
}, },
{
category = "Remote Logging",
key = "aredn.@remotelog[0].url",
type = "string",
desc = "<b>Remote logging URL</b> for the remote syslog machine. Must be formatted as <i>protocol://ipaddress:port</i><br><br><small>aredn.@remotelog[0].url</small>",
default = "",
needreboot = true,
nodesetup = true,
precallback = "validate_rsyslog()"
},
{ {
category = "Map Paths", category = "Map Paths",
key = "aredn.@map[0].maptiles", key = "aredn.@map[0].maptiles",
@ -751,15 +762,16 @@ function changeWANVLAN()
end end
f:close() f:close()
end end
os.execute("/usr/local/bin/node-setup -a mesh")
end end
function changeWANGW() function validate_rsyslog()
os.execute("/usr/local/bin/node-setup -a mesh") if newval ~= "" then
end local proto, ip, port = newval:match("^(.+)://(%d+%.%d+%.%d+%.%d+):(%d+)$")
if not proto or not (proto == "tcp" or proto == "udp") then
function changeMTU() msg("Badly formatted remote logging URL")
os.execute("/usr/local/bin/node-setup -a mesh") newval = ""
end
end
end end
-- read_postdata -- read_postdata
@ -812,6 +824,9 @@ do
if setting.postcallback then if setting.postcallback then
loadstring(setting.postcallback)() loadstring(setting.postcallback)()
end end
if setting.nodesetup then
os.execute("/usr/local/bin/node-setup -a mesh")
end
if setting.needreboot then if setting.needreboot then
io.open("/tmp/reboot-required", "w"):close() io.open("/tmp/reboot-required", "w"):close()
end end