device-observatory: add new package

Shows network/wireless activity on a local website
to increase awareness for privacy and security matters.

Signed-off-by: Moritz Warning <moritzwarning@web.de>
This commit is contained in:
Moritz Warning
2018-05-17 23:44:10 +02:00
committed by Karl Palsson
parent 8b37cf3b06
commit 0d2948b660
3 changed files with 128 additions and 0 deletions
@@ -0,0 +1,26 @@
config setup
list dev 'wlan0'
list mdev 'mon0'
option mac_db '/usr/share/device-observatory/macdb.txt'
option port_db '/etc/services'
# Optional JSON output into file
# option json_output '/tmp/device-observatory.json'
# Time after which a device is removed from the record
option device_timeout 3600
# Create monitoring interface mon0 based on physical interface wifi phy0.
# See 'iw dev' output for a list of interfaces.
list create_monitor 'mon0'
# Track router itself as device
option track_localhost 0
# Set to 0 to disable webserver
option webserver_port 8080
# Not needed, all necessary files are included
# option webserver_path '/www'
@@ -0,0 +1,66 @@
#!/bin/sh /etc/rc.common
START=90
USE_PROCD=1
PROG=/usr/bin/device-observatory
OPTS=""
boot() {
local dev="$(uci get -q device-observatory.@setup[0].dev | cut -d ' ' -f 1)"
# Wait for interface to be up
ubus -t 15 wait_for network.interface network.${dev:-localhost} 2>/dev/null
rc_procd start_service
}
xappend() {
local name="$2" value="$1"
OPTS="$OPTS --${name//_/-} ${value//'/\\'}"
}
append_opts() {
local name value cfg="$1"; shift
for name in $*; do
config_get value "$cfg" "$name"
[ -n "$value" ] && xappend "$value" "$name"
done
}
append_opts_list() {
local name cfg="$1"; shift
for name in $*; do
config_list_foreach "$cfg" "$name" xappend "$name"
done
}
create_monitor_interface() {
local ifce="$1" n=$(echo -n "$1" | tail -c 1)
if [ ! -d "/sys/class/net/$ifce/" ]; then
iw phy "phy$n" interface add "$ifce" type monitor
ip link set dev "$ifce" up
fi
}
start_instance() {
local cfg="$1"
OPTS=""
config_list_foreach "$cfg" "create_monitor" create_monitor_interface "create_monitor"
append_opts_list "$cfg" dev mdev
append_opts "$cfg" mac_db port_db json_output device_timeout webserver_port webserver_path track_localhost
procd_open_instance
procd_set_param command $PROG $OPTS
procd_set_param stderr 1
procd_set_param stdout 0
procd_close_instance
}
start_service() {
config_load 'device-observatory'
config_foreach start_instance 'setup'
}