mirror of https://github.com/hak5/openwrt.git
parent
1474359bd3
commit
fde5b934fd
|
@ -8,14 +8,14 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=6relayd
|
PKG_NAME:=6relayd
|
||||||
PKG_VERSION:=2013-01-02
|
PKG_VERSION:=2013-01-13
|
||||||
PKG_RELEASE=$(PKG_SOURCE_VERSION)
|
PKG_RELEASE=$(PKG_SOURCE_VERSION)
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||||
PKG_SOURCE_URL:=git://github.com/sbyx/6relayd.git
|
PKG_SOURCE_URL:=git://github.com/sbyx/6relayd.git
|
||||||
PKG_SOURCE_PROTO:=git
|
PKG_SOURCE_PROTO:=git
|
||||||
PKG_SOURCE_VERSION:=9bf44b802547d71b75c7e505b8018d35c8fe4016
|
PKG_SOURCE_VERSION:=9c1415f2361184482eeae9f252cc77c70f16be40
|
||||||
|
|
||||||
PKG_MAINTAINER:=Steven Barth <steven@midlink.org>
|
PKG_MAINTAINER:=Steven Barth <steven@midlink.org>
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
# Example #1: Create a relay for several networks in proxy mode
|
# Example #1: Create a relay for several networks in proxy mode
|
||||||
# This can be used to proxy Router Discovery, DHCPv6 and NDP.
|
# This can be used to proxy Router Discovery, DHCPv6 and NDP.
|
||||||
|
|
||||||
#config relay
|
#config server examplerelay
|
||||||
# option network 'wan lan'
|
# option master 'wan'
|
||||||
|
# option network 'lan'
|
||||||
# option rd 'relay'
|
# option rd 'relay'
|
||||||
# option dhcpv6 'relay'
|
# option dhcpv6 'relay'
|
||||||
# option ndp 'relay'
|
# option ndp 'relay'
|
||||||
|
@ -11,7 +12,8 @@
|
||||||
# Example #2: Provide Router Discovery and stateless DHCPv6 in server mode
|
# Example #2: Provide Router Discovery and stateless DHCPv6 in server mode
|
||||||
# This can be used as a small radvd and stateless DHCPv6-server replacement.
|
# This can be used as a small radvd and stateless DHCPv6-server replacement.
|
||||||
|
|
||||||
#config server
|
#config server exampleserver
|
||||||
# option network 'lan'
|
# option network 'lan'
|
||||||
# option rd 'server'
|
# option rd 'server'
|
||||||
# option dhcpv6 'server'
|
# option dhcpv6 'server'
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
/etc/init.d/6relayd enabled && /etc/init.d/6relayd start
|
/etc/init.d/6relayd enabled || exit 0
|
||||||
|
[ -n "$INTERFACE" ] || exit 0
|
||||||
|
|
||||||
|
. /etc/init.d/6relayd
|
||||||
|
restart_affected "$INTERFACE"
|
||||||
|
|
|
@ -1,26 +1,13 @@
|
||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
# Copyright (c) 2011-2012 OpenWrt.org
|
# Copyright (c) 2011-2012 OpenWrt.org
|
||||||
START=80
|
START=80
|
||||||
|
. /lib/functions/network.sh
|
||||||
resolve_ifname() {
|
. /lib/functions/service.sh
|
||||||
grep -qs "^ *$1:" /proc/net/dev && {
|
|
||||||
append ifaces "$1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve_network() {
|
|
||||||
local ifn
|
|
||||||
fixup_interface "$1"
|
|
||||||
config_get ifn "$1" ifname
|
|
||||||
[ -z "$ifn" ] && return 1
|
|
||||||
resolve_ifname "$ifn"
|
|
||||||
}
|
|
||||||
|
|
||||||
start_6relayd() {
|
start_6relayd() {
|
||||||
local cfg="$1"
|
local cfg="$1"
|
||||||
local mode="$2"
|
local mode="$2"
|
||||||
local args="-s -l"
|
local args=""
|
||||||
local ifaces=""
|
|
||||||
|
|
||||||
SERVICE_DAEMONIZE=1
|
SERVICE_DAEMONIZE=1
|
||||||
SERVICE_WRITE_PID=1
|
SERVICE_WRITE_PID=1
|
||||||
|
@ -33,40 +20,96 @@ start_6relayd() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
local net networks
|
# Detect master interface
|
||||||
config_get networks "$cfg" network
|
local master masterif
|
||||||
for net in $networks; do
|
config_get masterif "$cfg" master
|
||||||
resolve_network "$net" || {
|
network_get_device master "$masterif"
|
||||||
return 1
|
[ -z "$master" ] && master="."
|
||||||
}
|
|
||||||
|
# Detect slave interfaces
|
||||||
|
local slaves=""
|
||||||
|
local slaveifs
|
||||||
|
config_get slaveifs "$cfg" network
|
||||||
|
for slaveif in $slaveifs; do
|
||||||
|
local slave
|
||||||
|
network_get_device slave "$slaveif"
|
||||||
|
# Compatibility with old config format
|
||||||
|
if [ "$mode" = "relay" -a "$master" = "." ]; then
|
||||||
|
[ -z "$slave" ] && return 0
|
||||||
|
master="$slave"
|
||||||
|
else
|
||||||
|
[ -n "$slave" ] && append slaves "$slave"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
local ifn ifnames
|
# Bail if no slaves are active
|
||||||
config_get ifnames "$cfg" ifname
|
[ -z "$slaves" ] && return 0
|
||||||
for ifn in $ifnames; do
|
|
||||||
resolve_ifname "$ifn"
|
|
||||||
done
|
|
||||||
|
|
||||||
local rd
|
# Configure services
|
||||||
|
local rd dhcpv6 ndp
|
||||||
config_get rd "$cfg" rd
|
config_get rd "$cfg" rd
|
||||||
[ -n "$rd" ] && append args "-R$rd"
|
|
||||||
|
|
||||||
local dhcpv6
|
|
||||||
config_get dhcpv6 "$cfg" dhcpv6
|
config_get dhcpv6 "$cfg" dhcpv6
|
||||||
[ -n "$dhcpv6" ] && append args "-D$dhcpv6"
|
|
||||||
|
|
||||||
local ndp
|
|
||||||
config_get ndp "$cfg" ndp
|
config_get ndp "$cfg" ndp
|
||||||
[ "$ndp" == "relay" ] && append args "-N -r"
|
|
||||||
|
|
||||||
|
# Test for fallback mode
|
||||||
|
local fallback fallback_relay
|
||||||
|
config_get fallback_relay "$cfg" fallback_relay
|
||||||
|
|
||||||
|
if [ -n "$fallback_relay" -a "$master" != "." ]; then
|
||||||
|
local prefix
|
||||||
|
network_get_prefix6 prefix "$masterif"
|
||||||
|
[ -z "$prefix" ] && fallback=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$fallback" ]; then
|
||||||
|
for service in $fallback_relay; do
|
||||||
|
eval "$service=relay"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Configure feature options
|
||||||
local always_rewrite_dns
|
local always_rewrite_dns
|
||||||
config_get_bool always_rewrite_dns "$cfg" always_rewrite_dns 0
|
config_get_bool always_rewrite_dns "$cfg" always_rewrite_dns 0
|
||||||
[ $always_rewrite_dns -eq 1 ] && append args "-n"
|
[ "$always_rewrite_dns" -eq 1 ] && append args "-n"
|
||||||
|
|
||||||
# In server mode the first interface needs to be passed twice
|
local always_assume_default
|
||||||
[ "$mode" == "server" ] && ifaces=". $ifaces"
|
config_get_bool always_assume_default "$cfg" always_assume_default 0
|
||||||
|
[ "$always_assume_default" -eq 1 ] && append args "-u"
|
||||||
|
|
||||||
service_start /usr/sbin/6relayd $args $ifaces
|
[ "$ndp" = "relay" ] && append args "-N -s -l"
|
||||||
|
[ "$rd" = "relay" ] && append args "-Rrelay"
|
||||||
|
[ "$rd" = "server" ] && append args "-Rserver"
|
||||||
|
[ "$dhcpv6" = "relay" ] && append args "-Drelay"
|
||||||
|
[ "$dhcpv6" = "server" ] && append args "-Dserver"
|
||||||
|
[ "$ndp" != "relay" -a "$rd" != "relay" -a "$dhcpv6" != "relay" ] && master="."
|
||||||
|
|
||||||
|
service_start /usr/sbin/6relayd $args $master $slaves
|
||||||
|
}
|
||||||
|
|
||||||
|
restart_affected_6relayd() {
|
||||||
|
local cfg="$1"
|
||||||
|
local net="$2"
|
||||||
|
local mode="$3"
|
||||||
|
|
||||||
|
local master slaves
|
||||||
|
config_get master "$cfg" master
|
||||||
|
config_get slaves "$cfg" network
|
||||||
|
|
||||||
|
for iface in $master $slaves; do
|
||||||
|
if [ "$iface" = "$net" ]; then
|
||||||
|
SERVICE_PID_FILE="/var/run/6relayd-$cfg.pid"
|
||||||
|
service_stop /usr/sbin/6relayd
|
||||||
|
rm -f "$SERVICE_PID_FILE"
|
||||||
|
start_6relayd "$cfg" "$mode"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
restart_affected() {
|
||||||
|
local net="$1"
|
||||||
|
config_load 6relayd
|
||||||
|
config_foreach restart_affected_6relayd server "$net"
|
||||||
|
config_foreach restart_affected_6relayd relay "$net" "relay"
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
|
@ -78,8 +121,7 @@ stop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
include /lib/network
|
|
||||||
config_load 6relayd
|
config_load 6relayd
|
||||||
|
config_foreach start_6relayd server
|
||||||
config_foreach start_6relayd relay relay
|
config_foreach start_6relayd relay relay
|
||||||
config_foreach start_6relayd server server
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue