minimalist-pcproxy: Added.
authorMarkus Stenberg <markus.stenberg@iki.fi>
Mon, 26 May 2014 14:19:42 +0000 (17:19 +0300)
committerMarkus Stenberg <markus.stenberg@iki.fi>
Mon, 2 Jun 2014 21:48:28 +0000 (00:48 +0300)
hnetd: Added use of minimalist-pcproxy(/miniupnpd) for PCP, if present.

hnetd/Makefile
hnetd/files/hnetd.init
hnetd/files/pcp-script [new file with mode: 0644]
minimalist-pcproxy/Makefile [new file with mode: 0644]
minimalist-pcproxy/files/minimalist-pcproxy.defaults [new file with mode: 0644]

index fe7ccb4d27eaa0d137cc8517aff068065be77c21..99cc221b4ed8f0f0316d1a115b6d60bf898290c7 100644 (file)
@@ -7,8 +7,8 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=hnetd
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=hnetd
-PKG_SOURCE_VERSION:=a7fb081a9b98a150f2fda913886c6c0ef0725048
-PKG_VERSION:=2014-05-04-$(PKG_SOURCE_VERSION)
+PKG_SOURCE_VERSION:=c6da40c19d0e550cd1e2dd1a459ef6cab9b15cae
+PKG_VERSION:=2014-06-02-$(PKG_SOURCE_VERSION)
 PKG_RELEASE:=1
 
 PKG_SOURCE_PROTO:=git
 PKG_RELEASE:=1
 
 PKG_SOURCE_PROTO:=git
@@ -39,10 +39,15 @@ endef
 define Package/hnet-full
   SECTION:=net
   CATEGORY:=Network
 define Package/hnet-full
   SECTION:=net
   CATEGORY:=Network
-  TITLE:=HNCP Homenet metapackage (hnetd + ohybridproxy + babels)
+  TITLE:=HNCP Homenet metapackage
   URL:=https://github.com/sbyx/hnetd
   URL:=https://github.com/sbyx/hnetd
-  DEPENDS:=+odhcpd +odhcp6c +netifd +hnetd +ohybridproxy +babels
-  DEPENDS+=+@IPV6
+  DEPENDS:=+hnetd
+  # Routing
+  DEPENDS+=+babels
+  # Service discovery
+  DEPENDS+=+ohybridproxy
+  # Distributed PCP support
+  DEPENDS+=+miniupnpd +minimalist-pcproxy
 endef
 
 define Package/hnetd/description
 endef
 
 define Package/hnetd/description
@@ -61,6 +66,7 @@ define Package/hnetd/install
        $(INSTALL_DIR) $(1)/etc/init.d
        $(INSTALL_BIN) ./files/hnetd.init $(1)/etc/init.d/hnetd
        $(INSTALL_BIN) ./files/ohp-script $(1)/usr/sbin/hnetd-ohp-script
        $(INSTALL_DIR) $(1)/etc/init.d
        $(INSTALL_BIN) ./files/hnetd.init $(1)/etc/init.d/hnetd
        $(INSTALL_BIN) ./files/ohp-script $(1)/usr/sbin/hnetd-ohp-script
+       $(INSTALL_BIN) ./files/pcp-script $(1)/usr/sbin/hnetd-pcp-script
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/hnetd-routing $(1)/usr/sbin/hnetd-routing
        $(INSTALL_DIR) $(1)/etc/uci-defaults
        $(INSTALL_BIN) ./files/hnetd.defaults $(1)/etc/uci-defaults/x-hnetd.defaults
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/hnetd-routing $(1)/usr/sbin/hnetd-routing
        $(INSTALL_DIR) $(1)/etc/uci-defaults
        $(INSTALL_BIN) ./files/hnetd.defaults $(1)/etc/uci-defaults/x-hnetd.defaults
index 70d0d70dd9dfb6995f18bf0b889fbab62c38ca9c..6cdb4be078f10f7d546c61483122650be3516457 100644 (file)
@@ -12,6 +12,8 @@ DNSMASQ_DIR=/tmp/dnsmasq.d
 DNSMASQ_SCRIPT=/etc/init.d/dnsmasq
 OHP_SCRIPT=/usr/sbin/hnetd-ohp-script
 OHP_BINARY=/usr/sbin/ohybridproxy
 DNSMASQ_SCRIPT=/etc/init.d/dnsmasq
 OHP_SCRIPT=/usr/sbin/hnetd-ohp-script
 OHP_BINARY=/usr/sbin/ohybridproxy
+PCP_SCRIPT=/usr/sbin/hnetd-pcp-script
+PCP_BINARY=/usr/sbin/minimalist-pcproxy
 
 start_service() {
     mkdir -p $DNSMASQ_DIR
 
 start_service() {
     mkdir -p $DNSMASQ_DIR
@@ -23,7 +25,7 @@ start_service() {
     then
         mkdir -p $DNSMASQ_DIR
         procd_append_param command -d $DNSMASQ_SCRIPT
     then
         mkdir -p $DNSMASQ_DIR
         procd_append_param command -d $DNSMASQ_SCRIPT
-        procd_append_param command -f $DNSMASQ_DIR/hnet.conf 
+        procd_append_param command -f $DNSMASQ_DIR/hnet.conf
         procd_append_param command -o $OHP_SCRIPT
         HOSTNAME=`cat /proc/sys/kernel/hostname`
         if [ -n "$HOSTNAME" ]
         procd_append_param command -o $OHP_SCRIPT
         HOSTNAME=`cat /proc/sys/kernel/hostname`
         if [ -n "$HOSTNAME" ]
@@ -31,6 +33,13 @@ start_service() {
             procd_append_param command -n "$HOSTNAME"
         fi
     fi
             procd_append_param command -n "$HOSTNAME"
         fi
     fi
+
+    # Enable PCP, if it's present
+    if [ -f $PCP_BINARY -a -f $PCP_SCRIPT ]
+    then
+        procd_append_param command -c $PCP_SCRIPT
+    fi
+
     # State file
     procd_append_param command -s /tmp/hnetd.pa_state
 
     # State file
     procd_append_param command -s /tmp/hnetd.pa_state
 
diff --git a/hnetd/files/pcp-script b/hnetd/files/pcp-script
new file mode 100644 (file)
index 0000000..88648d2
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/sh
+#-*-sh-*-
+#
+# $Id: pcp-script $
+#
+# Author: Markus Stenberg <mstenber@cisco.com>
+#
+# Copyright (c) 2014 cisco Systems, Inc.
+#
+# Created:       Fri Jan 17 11:46:30 2014 mstenber
+# Last modified: Fri May 30 13:27:57 2014 mstenber
+# Edit time:     16 min
+#
+
+# Copied from ohp-script.. Same idea. Just prod minimalist-pcproxy as
+# needed, hoping the miniupnpd is taken care of by the system.
+
+PCP=minimalist-pcproxy
+
+start() {
+    $PCP $* &
+}
+
+stop() {
+    killall -9 $PCP
+}
+
+
+CMD=$1
+# For debugging purposes
+LOGNAME=`basename $0`
+echo "$*" | logger -t "$LOGNAME"
+case $CMD in
+  start)
+    shift
+    stop
+    start $*
+    ;;
+  stop)
+  stop
+    ;;
+  *)
+    echo "Only start [config]/stop supported"
+    exit 1
+  ;;
+esac
diff --git a/minimalist-pcproxy/Makefile b/minimalist-pcproxy/Makefile
new file mode 100644 (file)
index 0000000..1a4f16d
--- /dev/null
@@ -0,0 +1,56 @@
+#
+# Copyright (C) 2014 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=minimalist-pcproxy
+PKG_SOURCE_VERSION:=c8d47ff42c4354f502830faeae13bd8f269401af
+PKG_VERSION:=2014-06-02-$(PKG_SOURCE_VERSION)
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://github.com/fingon/minimalist-pcproxy.git
+PKG_MAINTAINER:=Markus Stenberg <fingon@iki.fi>
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/minimalist-pcproxy
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=Lightweight PCP proxy
+  URL:=https://github.com/fingon/minimalist-pcproxy
+  DEPENDS:=+libubox +@IPV6
+endef
+
+define Package/minimalist-pcproxy/description
+This package contains a daemon which can be used to forward
+PCP (Port Control Protocol - RFC6887) requests requests to PCP remote servers.
+
+In and of itself, it is not very useful, but combined with hnetd+miniupnpd
+it allows for control of NAT forwarding and firewall pinholes from multiple
+hops away.
+endef
+
+define Package/minimalist-pcproxy/install
+       $(INSTALL_DIR) $(1)/usr/sbin/
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/minimalist-pcproxy $(1)/usr/sbin/
+       $(INSTALL_DIR) $(1)/etc/uci-defaults
+       $(INSTALL_BIN) ./files/minimalist-pcproxy.defaults $(1)/etc/uci-defaults/x-minimalist-pcproxy.defaults
+endef
+
+define Package/minimalist-pcproxy/postinst
+!/bin/sh
+[ -n "$${IPKG_INSTROOT}" ] || {
+       (. /etc/uci-defaults/x-minimalist-pcproxy.defaults) && rm -f /etc/uci-defaults/x-minimalist-pcproxy.defaults
+}
+exit 0
+endef
+
+$(eval $(call BuildPackage,minimalist-pcproxy))
diff --git a/minimalist-pcproxy/files/minimalist-pcproxy.defaults b/minimalist-pcproxy/files/minimalist-pcproxy.defaults
new file mode 100644 (file)
index 0000000..4e041e5
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+if [ `uci get -q upnpd.config._pcproxy_configured` = "1" ]
+then
+    exit
+fi
+
+uci batch <<EOF
+set upnpd.config.enable_upnp=0
+set upnpd.config.pcp_allow_thirdparty=1
+set upnpd.config.internal_iface=loopback
+set upnpd.config.ipv6_listening_ip=::1
+set upnpd.config._pcproxy_configured=1
+commit upnpd
+EOF