blob: 8883f4246ceb7479d06b9baab7603d4405714fb2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
}
|