gnunet: update defaults, integrate with netifd and fw3

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
Daniel Golle
2016-04-19 02:11:06 +02:00
parent 4dc6595bb7
commit 72a164f63b
5 changed files with 215 additions and 26 deletions
+51
View File
@@ -0,0 +1,51 @@
#!/bin/sh
# gnunet.sh - GNUnet proto for netifd
# Copyright (c) 2016 OpenWrt.org
[ -n "$INCLUDE_ONLY" ] || {
. /lib/functions.sh
. /lib/functions/network.sh
. ../netifd-proto.sh
init_proto "$@"
}
proto_gnunet_setup() {
local cfg="$1"
local iface="$2"
local ipv4_addr ipv6_addr prefix ipaddr ip6addr
local configfile="/var/run/gnunet/gnunet.conf"
local gnunet_iftype
for gnit in dns exit vpn; do
local i1="$(gnunet-config -c $configfile -s $gnit -o IFNAME 2>/dev/null)"
local i2="$(gnunet-config -c $configfile -s $gnit -o TUN_IFNAME 2>/dev/null)"
[ "$i1" = "$iface" -o "$i2" = "$iface" ] && gnunet_iftype="$gnit"
done
if [ -z "$iface" -o -z "$gnunet_iftype" ]; then
proto_setup_failed "$cfg"
return
fi
proto_init_update "$iface" 1
ipaddr="$(gnunet-config -c $configfile -s $gnunet_iftype -o IPV4ADDR 2>/dev/null)"
ipmask="$(gnunet-config -c $configfile -s $gnunet_iftype -o IPV4MASK 2>/dev/null)"
ip6addr="$(gnunet-config -c $configfile -s $gnunet_iftype -o IPV6ADDR 2>/dev/null)"
ip6prefix="$(gnunet-config -c $configfile -s $gnunet_iftype -o IPV6PREFIX 2>/dev/null)"
[ -n "$ipaddr" ] && proto_add_ipv4_address "$ipaddr" "$ipmask"
[ -n "$ip6addr" ] && proto_add_ipv6_address "$ip6addr" "$ip6prefix"
proto_send_update "$cfg"
}
proto_gnunet_teardown() {
return
}
[ -n "$INCLUDE_ONLY" ] || {
add_protocol gnunet
}