From 639f3631e80e9372e9791f5f93343f09241cdda6 Mon Sep 17 00:00:00 2001 From: Xiaok <3795104+luxiaok@users.noreply.github.com> Date: Fri, 17 Apr 2020 11:51:15 +0800 Subject: [PATCH] n2n: update to v2.6.0-stable (#4349) --- package/lean/luci-app-n2n_v2/Makefile | 4 +- package/lean/n2n_v2/Makefile | 86 ++++++++++++++++--------- package/lean/n2n_v2/files/n2n_v2.config | 24 +++---- package/lean/n2n_v2/files/n2n_v2.init | 66 +++++++++---------- 4 files changed, 104 insertions(+), 76 deletions(-) diff --git a/package/lean/luci-app-n2n_v2/Makefile b/package/lean/luci-app-n2n_v2/Makefile index a92981d3b..e95b28195 100755 --- a/package/lean/luci-app-n2n_v2/Makefile +++ b/package/lean/luci-app-n2n_v2/Makefile @@ -7,10 +7,10 @@ include $(TOPDIR)/rules.mk LUCI_TITLE:=n2n_v2 VPN Configuration module -LUCI_DEPENDS:=+n2n_v2 +LUCI_DEPENDS:=+n2n-edge +n2n-supernode LUCI_PKGARCH:=all PKG_VERSION:=1.0 -PKG_RELEASE:=3 +PKG_RELEASE:=4 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/package/lean/n2n_v2/Makefile b/package/lean/n2n_v2/Makefile index a0e45ada3..3f61bf09c 100644 --- a/package/lean/n2n_v2/Makefile +++ b/package/lean/n2n_v2/Makefile @@ -1,53 +1,81 @@ # -# Copyright (C) 2007-2012 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. +# Copyright (C) 2020 - ntop.org and contributors # include $(TOPDIR)/rules.mk -PKG_NAME:=n2n_v2 -PKG_VERSION:=2.4 -PKG_RELEASE:=2 -PKG_REV=25563f31d9aba5f61b3e2fb42941b66dad1f531f +PKG_NAME:=n2n +PKG_SOURCE_URL:=https://github.com/ntop/n2n.git +PKG_SOURCE_VERSION:=bc0a6bf8b78c90dd902efa75891d41d2a489286e +PKG_VERSION:=2.6.0_git-$(PKG_SOURCE_VERSION) +PKG_RELEASE:=1 -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-r$(PKG_REV).tar.bz2 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE_PROTO:=git -PKG_SOURCE_VERSION:=$(PKG_REV) -PKG_SOURCE_URL:=https://github.com/ntop/n2n.git + +PKG_MAINTAINER:=Emanuele Faranda +PKG_LICENSE:=GPL3 +PKG_BUILD_PARALLEL:=1 + +# autogen fix +PKG_FIXUP:=autoreconf include $(INCLUDE_DIR)/package.mk -define Package/n2n_v2 +define Package/n2n/Default SECTION:=net CATEGORY:=Network - TITLE:=N2N VPN tunneling daemon(V2) - URL:=http://www.ntop.org/n2n/ + TITLE:=N2N Peer-to-peer VPN + URL:=http://www.ntop.org/n2n SUBMENU:=VPN - DEPENDS:=+libpthread +kmod-tun +libopenssl endef -define Build/Compile - $(MAKE) -C $(PKG_BUILD_DIR) \ - $(TARGET_CONFIGURE_OPTS) \ - CFLAGS="$(TARGET_CFLAGS)" \ - INSTALL_PROG=":" +define Package/n2n-edge + $(call Package/n2n/Default) + TITLE+= client (edge node) + DEPENDS+=+kmod-tun +resolveip +libopenssl endef -define Package/n2n_v2/install - $(INSTALL_DIR) $(1)/usr/sbin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/edge $(1)/usr/sbin/ - $(INSTALL_BIN) $(PKG_BUILD_DIR)/supernode $(1)/usr/sbin/ - $(INSTALL_DIR) $(1)/etc/config - $(INSTALL_DATA) ./files/n2n_v2.config $(1)/etc/config/n2n_v2 +define Package/n2n-supernode + $(call Package/n2n/Default) + TITLE+= server (supernode) +endef + +define Package/n2n-edge/description +The client node for the N2N infrastructure +endef + +define Package/n2n-supernode/description +The supernode for the N2N infrastructure +endef + +define Build/Configure + ( cd $(PKG_BUILD_DIR); ./autogen.sh ) + $(call Build/Configure/Default) +endef + +define Package/n2n-edge/conffiles +/etc/config/n2n-edge.conf +endef + +define Package/n2n-edge/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/edge $(1)/usr/bin/ $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/n2n_v2.init $(1)/etc/init.d/n2n_v2 + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/n2n_v2.config $(1)/etc/config/n2n_v2 endef -define Package/n2n_v2/conffiles -/etc/config/n2n_v2 +define Package/n2n-supernode/conffiles +/etc/config/n2n-supernode.conf endef -$(eval $(call BuildPackage,n2n_v2)) +define Package/n2n-supernode/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/supernode $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,n2n-edge)) +$(eval $(call BuildPackage,n2n-supernode)) diff --git a/package/lean/n2n_v2/files/n2n_v2.config b/package/lean/n2n_v2/files/n2n_v2.config index c765d02dd..9c0e2cdac 100644 --- a/package/lean/n2n_v2/files/n2n_v2.config +++ b/package/lean/n2n_v2/files/n2n_v2.config @@ -1,15 +1,15 @@ config edge - option enabled '0' - option tunname 'n2n_edge' - option mode 'static' - option ipaddr '10.0.0.100' - option netmask '255.255.255.0' - option supernode '1.2.3.4' - option port '1234' - option community 'example' - option key 'password' - option route '0' + option enabled '0' + option tunname 'n2n0' + option mode 'static' + option ipaddr '10.0.0.100' + option netmask '255.255.255.0' + option supernode '1.2.3.4' + option port '1234' + option community 'example' + option key 'password' + option route '0' config supernode - option enabled '0' - option port '1235' + option enabled '0' + option port '1235' diff --git a/package/lean/n2n_v2/files/n2n_v2.init b/package/lean/n2n_v2/files/n2n_v2.init index 65103d2a8..6e6038fa5 100644 --- a/package/lean/n2n_v2/files/n2n_v2.init +++ b/package/lean/n2n_v2/files/n2n_v2.init @@ -1,64 +1,64 @@ #!/bin/sh /etc/rc.common -# Copyright (C) 2008-2012 OpenWrt.org +# Copyright (C) 2008-2020 OpenWrt.org START=99 start_instance() { - local cfg="$1" + local cfg="$1" - config_get type "$cfg" TYPE + config_get type "$cfg" TYPE - case "$type" in - edge) + case "$type" in + edge) config_get_bool enabled "$cfg" 'enabled' '0' [ "$enabled" = "0" ] && return 1 config_get tunname "$cfg" 'tunname' config_get mode "$cfg" 'mode' - config_get ipaddr "$cfg" 'ipaddr' + config_get ipaddr "$cfg" 'ipaddr' config_get netmask "$cfg" 'netmask' config_get mtu "$cfg" 'mtu' - config_get supernode "$cfg" 'supernode' - config_get port "$cfg" 'port' - config_get community "$cfg" 'community' - config_get key "$cfg" 'key' - config_get_bool route "$cfg" 'route' '0' - [ "$route" = "1" ] && args='-r' + config_get supernode "$cfg" 'supernode' + config_get port "$cfg" 'port' + config_get community "$cfg" 'community' + config_get key "$cfg" 'key' + config_get_bool route "$cfg" 'route' '0' + [ "$route" = "1" ] && args='-r' [ "$mode" = 'dhcp' ] && ipaddr='0.0.0.0' [ "-$mtu" != "-" ] && mtu="-M $mtu" - /usr/sbin/edge -d $tunname -a ${mode}:${ipaddr} -c $community $([ -n "$key" ] && echo -k $key) -s ${netmask} -l ${supernode}:${port} $args $mtu - ;; - supernode) + /usr/bin/edge -d $tunname -a ${mode}:${ipaddr} -c $community $([ -n "$key" ] && echo -k $key) -s ${netmask} -l ${supernode}:${port} $args $mtu + ;; + supernode) config_get_bool enabled "$cfg" 'enabled' '0' [ "$enabled" = "0" ] && return 1 - config_get port "$cfg" port - /usr/sbin/supernode -l $port & - ;; - esac + config_get port "$cfg" port + /usr/bin/supernode -l $port & + ;; + esac } stop_instance() { - local cfg="$1" + local cfg="$1" - config_get type "$cfg" TYPE + config_get type "$cfg" TYPE - case "$type" in - edge) - killall -9 edge - ;; - supernode) - killall -9 supernode - ;; - esac + case "$type" in + edge) + killall -9 edge + ;; + supernode) + killall -9 supernode + ;; + esac } start() { - config_load 'n2n_v2' - config_foreach start_instance 'edge' - config_foreach start_instance 'supernode' + config_load 'n2n_v2' + config_foreach start_instance 'edge' + config_foreach start_instance 'supernode' } stop() { - config_load 'n2n_v2' + config_load 'n2n_v2' killall -9 edge ps | grep supernode | grep -v grep 2>&1 >/dev/null && killall -9 supernode }