n2n: update to v2.6.0-stable (#4349)

This commit is contained in:
Xiaok 2020-04-17 11:51:15 +08:00 committed by GitHub
parent 9448672845
commit 639f3631e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 104 additions and 76 deletions

View File

@ -7,10 +7,10 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
LUCI_TITLE:=n2n_v2 VPN Configuration module LUCI_TITLE:=n2n_v2 VPN Configuration module
LUCI_DEPENDS:=+n2n_v2 LUCI_DEPENDS:=+n2n-edge +n2n-supernode
LUCI_PKGARCH:=all LUCI_PKGARCH:=all
PKG_VERSION:=1.0 PKG_VERSION:=1.0
PKG_RELEASE:=3 PKG_RELEASE:=4
include $(TOPDIR)/feeds/luci/luci.mk include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -1,53 +1,81 @@
# #
# Copyright (C) 2007-2012 OpenWrt.org # Copyright (C) 2020 - ntop.org and contributors
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
# #
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=n2n_v2 PKG_NAME:=n2n
PKG_VERSION:=2.4 PKG_SOURCE_URL:=https://github.com/ntop/n2n.git
PKG_RELEASE:=2 PKG_SOURCE_VERSION:=bc0a6bf8b78c90dd902efa75891d41d2a489286e
PKG_REV=25563f31d9aba5f61b3e2fb42941b66dad1f531f 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_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=$(PKG_REV)
PKG_SOURCE_URL:=https://github.com/ntop/n2n.git PKG_MAINTAINER:=Emanuele Faranda <faranda@ntop.org>
PKG_LICENSE:=GPL3
PKG_BUILD_PARALLEL:=1
# autogen fix
PKG_FIXUP:=autoreconf
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
define Package/n2n_v2 define Package/n2n/Default
SECTION:=net SECTION:=net
CATEGORY:=Network CATEGORY:=Network
TITLE:=N2N VPN tunneling daemon(V2) TITLE:=N2N Peer-to-peer VPN
URL:=http://www.ntop.org/n2n/ URL:=http://www.ntop.org/n2n
SUBMENU:=VPN SUBMENU:=VPN
DEPENDS:=+libpthread +kmod-tun +libopenssl
endef endef
define Build/Compile define Package/n2n-edge
$(MAKE) -C $(PKG_BUILD_DIR) \ $(call Package/n2n/Default)
$(TARGET_CONFIGURE_OPTS) \ TITLE+= client (edge node)
CFLAGS="$(TARGET_CFLAGS)" \ DEPENDS+=+kmod-tun +resolveip +libopenssl
INSTALL_PROG=":"
endef endef
define Package/n2n_v2/install define Package/n2n-supernode
$(INSTALL_DIR) $(1)/usr/sbin $(call Package/n2n/Default)
$(INSTALL_BIN) $(PKG_BUILD_DIR)/edge $(1)/usr/sbin/ TITLE+= server (supernode)
$(INSTALL_BIN) $(PKG_BUILD_DIR)/supernode $(1)/usr/sbin/ endef
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/n2n_v2.config $(1)/etc/config/n2n_v2 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_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/n2n_v2.init $(1)/etc/init.d/n2n_v2 $(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 endef
define Package/n2n_v2/conffiles define Package/n2n-supernode/conffiles
/etc/config/n2n_v2 /etc/config/n2n-supernode.conf
endef 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))

View File

@ -1,15 +1,15 @@
config edge config edge
option enabled '0' option enabled '0'
option tunname 'n2n_edge' option tunname 'n2n0'
option mode 'static' option mode 'static'
option ipaddr '10.0.0.100' option ipaddr '10.0.0.100'
option netmask '255.255.255.0' option netmask '255.255.255.0'
option supernode '1.2.3.4' option supernode '1.2.3.4'
option port '1234' option port '1234'
option community 'example' option community 'example'
option key 'password' option key 'password'
option route '0' option route '0'
config supernode config supernode
option enabled '0' option enabled '0'
option port '1235' option port '1235'

View File

@ -1,64 +1,64 @@
#!/bin/sh /etc/rc.common #!/bin/sh /etc/rc.common
# Copyright (C) 2008-2012 OpenWrt.org # Copyright (C) 2008-2020 OpenWrt.org
START=99 START=99
start_instance() { start_instance() {
local cfg="$1" local cfg="$1"
config_get type "$cfg" TYPE config_get type "$cfg" TYPE
case "$type" in case "$type" in
edge) edge)
config_get_bool enabled "$cfg" 'enabled' '0' config_get_bool enabled "$cfg" 'enabled' '0'
[ "$enabled" = "0" ] && return 1 [ "$enabled" = "0" ] && return 1
config_get tunname "$cfg" 'tunname' config_get tunname "$cfg" 'tunname'
config_get mode "$cfg" 'mode' config_get mode "$cfg" 'mode'
config_get ipaddr "$cfg" 'ipaddr' config_get ipaddr "$cfg" 'ipaddr'
config_get netmask "$cfg" 'netmask' config_get netmask "$cfg" 'netmask'
config_get mtu "$cfg" 'mtu' config_get mtu "$cfg" 'mtu'
config_get supernode "$cfg" 'supernode' config_get supernode "$cfg" 'supernode'
config_get port "$cfg" 'port' config_get port "$cfg" 'port'
config_get community "$cfg" 'community' config_get community "$cfg" 'community'
config_get key "$cfg" 'key' config_get key "$cfg" 'key'
config_get_bool route "$cfg" 'route' '0' config_get_bool route "$cfg" 'route' '0'
[ "$route" = "1" ] && args='-r' [ "$route" = "1" ] && args='-r'
[ "$mode" = 'dhcp' ] && ipaddr='0.0.0.0' [ "$mode" = 'dhcp' ] && ipaddr='0.0.0.0'
[ "-$mtu" != "-" ] && mtu="-M $mtu" [ "-$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 /usr/bin/edge -d $tunname -a ${mode}:${ipaddr} -c $community $([ -n "$key" ] && echo -k $key) -s ${netmask} -l ${supernode}:${port} $args $mtu
;; ;;
supernode) supernode)
config_get_bool enabled "$cfg" 'enabled' '0' config_get_bool enabled "$cfg" 'enabled' '0'
[ "$enabled" = "0" ] && return 1 [ "$enabled" = "0" ] && return 1
config_get port "$cfg" port config_get port "$cfg" port
/usr/sbin/supernode -l $port & /usr/bin/supernode -l $port &
;; ;;
esac esac
} }
stop_instance() { stop_instance() {
local cfg="$1" local cfg="$1"
config_get type "$cfg" TYPE config_get type "$cfg" TYPE
case "$type" in case "$type" in
edge) edge)
killall -9 edge killall -9 edge
;; ;;
supernode) supernode)
killall -9 supernode killall -9 supernode
;; ;;
esac esac
} }
start() { start() {
config_load 'n2n_v2' config_load 'n2n_v2'
config_foreach start_instance 'edge' config_foreach start_instance 'edge'
config_foreach start_instance 'supernode' config_foreach start_instance 'supernode'
} }
stop() { stop() {
config_load 'n2n_v2' config_load 'n2n_v2'
killall -9 edge killall -9 edge
ps | grep supernode | grep -v grep 2>&1 >/dev/null && killall -9 supernode ps | grep supernode | grep -v grep 2>&1 >/dev/null && killall -9 supernode
} }