gluon/package/gluon-status-page/luasrc/lib/gluon/upgrade/500-status-page
David Bauer 5b068d7c47
treewide: rename local_client zone (#2115)
This renames the local_client zone to loc_client, as local_clint exceeds
the maximum zone length allowed for firewall3, which is 11 bytes.

This worked previously due to firewall3 using unsafe string operations.
Now creation of the chain fails (latest OpenWrt master).
2020-09-13 05:24:33 +02:00

43 lines
796 B
Lua
Executable File

#!/usr/bin/lua
local uci = require('simple-uci').cursor()
local function get_mem_total()
for line in io.lines('/proc/meminfo') do
local match = line:match('^MemTotal:%s+(%d+)')
if match then
return tonumber(match)
end
end
end
local max_requests = 32
if get_mem_total() < 48*1024 then
max_requests = 16
end
uci:section('uhttpd', 'uhttpd', 'main', {
listen_http = { '0.0.0.0:80', '[::]:80' },
listen_https = {},
home = '/lib/gluon/status-page/www',
max_requests = max_requests,
})
uci:save('uhttpd')
for _, zone in ipairs({'mesh', 'loc_client'}) do
uci:section('firewall', 'rule', zone .. '_http', {
src = zone,
dest_port = '80',
proto = 'tcp',
target = 'ACCEPT',
})
end
-- ToDo remove in v2022.x
uci:delete('firewall', 'local_client_http')
uci:save('firewall')