#!/bin/sh

# shellcheck disable=SC1091

. /lib/functions/guard.sh
guard "uhttpd"

# insert a random part into commonname (Freifunk Berlin - <random>)
# this should help us to avoid different certificates with same
# commonname/issuer id
uci set uhttpd.defaults.commonname="Freifunk Berlin - $(dd if=/dev/urandom bs=4 count=1 | hexdump -e '1/1 "%02x"')"
# do force redirect to https for encrypted web interface
uci set uhttpd.main.redirect_https=1

# Disable filtering requests from RFC1918 IP addresses.
# This is a DNS rebinding countermeasure that we don't want,
# since we use the 10.0.0.0/8 space for OLSR meshing.
uci set uhttpd.main.rfc1918_filter=0

uci commit

/etc/init.d/uhttpd reload
