Skip to content

Commit

Permalink
stubby: add webui (Freetz#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
flosch-dev authored and er13 committed Aug 17, 2019
1 parent 2bf9ad7 commit db9c10c
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 0 deletions.
11 changes: 11 additions & 0 deletions make/getdns/files/.language
@@ -0,0 +1,11 @@
languages
{ de en }
default
{ en }
files
{
etc/default.getdns/getdns.def
etc/default.getdns/getdns_conf.def
etc/init.d/rc.getdns
usr/lib/cgi-bin/getdns.cgi
}
2 changes: 2 additions & 0 deletions make/getdns/files/root/etc/default.getdns/getdns.cfg
@@ -0,0 +1,2 @@
export GETDNS_ENABLED="no"
export GETDNS_LOGLEVEL='4'
5 changes: 5 additions & 0 deletions make/getdns/files/root/etc/default.getdns/getdns.def
@@ -0,0 +1,5 @@
CAPTION='$(lang de:"Stubby Konfiguration" en:"Stubby configuration")'
DESCRIPTION='$(lang de:"getdns - stubby Konfiguration" en:"getdns - stubby configuration")'
CONFIG_FILE='/tmp/flash/getdns/getdns.yml'
CONFIG_SAVE='modsave flash; /mod/etc/init.d/rc.getdns restart'
CONFIG_TYPE='text'
23 changes: 23 additions & 0 deletions make/getdns/files/root/etc/default.getdns/getdns_conf
@@ -0,0 +1,23 @@
#!/bin/sh


cat <<EOF
resolution_type: GETDNS_RESOLUTION_STUB
dns_transport_list:
- GETDNS_TRANSPORT_TLS
tls_authentication: GETDNS_AUTHENTICATION_REQUIRED
tls_query_padding_blocksize: 128
edns_client_subnet_private : 1
round_robin_upstreams: 1
idle_timeout: 10000
listen_addresses:
- 127.0.0.1@11153
upstream_recursive_servers:
- address_data: 8.8.8.8
tls_auth_name: "dns.google"
- address_data: 8.8.4.4
tls_auth_name: "dns.google"
- address_data: 46.182.19.48
tls_auth_name: "dns2.digitalcourage.de"
EOF
9 changes: 9 additions & 0 deletions make/getdns/files/root/etc/default.getdns/getdns_conf.def
@@ -0,0 +1,9 @@
CAPTION='$(lang de:"Konfiguration" en:"Configuration")'

DESCRIPTION='$(lang de:"Stubby Konfiguration in YAML <a href=\"https://getdnsapi.net/documentation/manpages/stubby/\">Stubby Configuration</a>" en:"Stubby config YAML <a href=\"https://getdnsapi.net/documentation/manpages/stubby/\">Stubby Configuration</a>")'

CONFIG_FILE='/tmp/flash/getdns/getdns.yml'
CONFIG_SAVE='modsave flash; if pidof stubby > /dev/null; then echo ""; /mod/etc/init.d/rc.getdns restart; fi'
CONFIG_TYPE='text'

TEXT_ROWS=25
51 changes: 51 additions & 0 deletions make/getdns/files/root/etc/init.d/rc.getdns
@@ -0,0 +1,51 @@
#!/bin/sh

DAEMON=getdns
DAEMON_LONG_NAME="Stubby"
DAEMON_CONFIG=/tmp/flash/$DAEMON/$DAEMON.yml
CONF_NAME=getdns
DAEMON_BIN=stubby

. /etc/init.d/modlibrc

start() {
modlib_startdaemon $DAEMON_BIN -C $DAEMON_CONFIG -g -v $GETDNS_LOGLEVEL
}

case $1 in
""|load)
[ ! -d "/tmp/flash/$DAEMON" ] && mkdir -p /tmp/flash/$DAEMON
[ ! -e "$DAEMON_CONFIG" ] && /mod/etc/default.$DAEMON/getdns_conf > $DAEMON_CONFIG

modreg file $DAEMON config '$(lang de:"Konfiguration" en:"Configuration")' 1 "getdns_conf"
[ -r /etc/options.cfg ] && . /etc/options.cfg
modreg cgi $DAEMON $DAEMON_LONG_NAME
modreg daemon $DAEMON

modlib_start $GETDNS_ENABLED
;;
unload)
modunreg daemon $DAEMON
modunreg cgi $DAEMON
modunreg file $DAEMON
modlib_stop
;;
start)
modlib_start
;;
stop)
modlib_stop
;;
restart)
modlib_restart
;;
status)
modlib_status
;;
*)
echo "Usage: $0 [load|unload|start|stop|restart|status]" 1>&2
exit 1
;;
esac

exit 0
24 changes: 24 additions & 0 deletions make/getdns/files/root/usr/lib/cgi-bin/getdns.cgi
@@ -0,0 +1,24 @@
#!/bin/sh

. /usr/lib/libmodcgi.sh
check "$GETDNS_LOGLEVEL" 0:loglevel_c0 1:loglevel_c1 2:loglevel_c2 3:loglevel_c3 5:loglevel_c5 6:loglevel_c6 7:loglevel_c7 "*":loglevel_c4

sec_begin '$(lang de:"Starttyp" en:"Start type")' sec_start
cgi_print_radiogroup_service_starttype "enabled" "$GETDNS_ENABLED" "" "" 0
sec_end

sec_begin 'Stubby daemon'

cat << EOT
Log level:<br>
<input id="loglevel0" type="radio" name="loglevel" value="0"$loglevel_c0_chk><label for="loglevel0">EMERG - System is unusable</label></br>
<input id="loglevel1" type="radio" name="loglevel" value="1"$loglevel_c1_chk><label for="loglevel1">ALERT - Action must be taken immediately</label></br>
<input id="loglevel2" type="radio" name="loglevel" value="2"$loglevel_c2_chk><label for="loglevel2">CRIT - Critical conditions</label></br>
<input id="loglevel3" type="radio" name="loglevel" value="3"$loglevel_c3_chk><label for="loglevel3">ERROR - Error conditions</label></br>
<input id="loglevel4" type="radio" name="loglevel" value="4"$loglevel_c4_chk><label for="loglevel4">WARN - Warning conditions</label></br>
<input id="loglevel5" type="radio" name="loglevel" value="5"$loglevel_c5_chk><label for="loglevel5">NOTICE - Normal, but significant, condition</label></br>
<input id="loglevel6" type="radio" name="loglevel" value="6"$loglevel_c6_chk><label for="loglevel6">INFO - Informational message</label></br>
<input id="loglevel7" type="radio" name="loglevel" value="7"$loglevel_c7_chk><label for="loglevel7">DEBUG - Debug-level message</label></br>
EOT

sec_end

0 comments on commit db9c10c

Please sign in to comment.