lede-packages-rs

git clone git://archive.git.mtrnord.blog/MTRNord/lede-packages-rs.git
Log | Files | Refs | README | LICENSE

gnunet-proto.sh (1358B)


      1 #!/bin/sh
      2 # gnunet.sh - GNUnet proto for netifd
      3 # Copyright (c) 2016 OpenWrt.org
      4 
      5 [ -n "$INCLUDE_ONLY" ] || {
      6 	. /lib/functions.sh
      7 	. /lib/functions/network.sh
      8 	. ../netifd-proto.sh
      9 	init_proto "$@"
     10 }
     11 
     12 proto_gnunet_setup() {
     13 	local cfg="$1"
     14 	local iface="$2"
     15 
     16 	local ipv4_addr ipv6_addr prefix ipaddr ip6addr
     17 
     18 	local configfile="/var/run/gnunet/gnunet.conf"
     19 	local gnunet_iftype
     20 
     21 	for gnit in dns exit vpn; do
     22 		local i1="$(gnunet-config -c $configfile -s $gnit -o IFNAME 2>/dev/null)"
     23 		local i2="$(gnunet-config -c $configfile -s $gnit -o TUN_IFNAME 2>/dev/null)"
     24 		[ "$i1" = "$iface" -o "$i2" = "$iface" ] && gnunet_iftype="$gnit"
     25 	done
     26 
     27 	if [ -z "$iface" -o -z "$gnunet_iftype" ]; then
     28 		proto_setup_failed "$cfg"
     29 		return
     30 	fi
     31 
     32 	proto_init_update "$iface" 1
     33 	ipaddr="$(gnunet-config -c $configfile -s $gnunet_iftype -o IPV4ADDR 2>/dev/null)"
     34 	ipmask="$(gnunet-config -c $configfile -s $gnunet_iftype -o IPV4MASK 2>/dev/null)"
     35 	ip6addr="$(gnunet-config -c $configfile -s $gnunet_iftype -o IPV6ADDR 2>/dev/null)"
     36 	ip6prefix="$(gnunet-config -c $configfile -s $gnunet_iftype -o IPV6PREFIX 2>/dev/null)"
     37 
     38 	[ -n "$ipaddr" ]  && proto_add_ipv4_address "$ipaddr" "$ipmask"
     39 	[ -n "$ip6addr" ] && proto_add_ipv6_address "$ip6addr" "$ip6prefix"
     40 	proto_send_update "$cfg"
     41 }
     42 
     43 proto_gnunet_teardown() {
     44 	return
     45 }
     46 
     47 [ -n "$INCLUDE_ONLY" ] || {
     48 	add_protocol gnunet
     49 }
     50 
     51