#!/usr/bin/lua

local uci = require('simple-uci').cursor()
local util = require 'gluon.util'


local max_requests = 32
if util.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

uci:save('firewall')
