New upstream version 3.1.1

This commit is contained in:
billchenchina 2022-11-15 08:50:35 +08:00
parent 4e9934e5ec
commit e7b41df57b
229 changed files with 57000 additions and 12055 deletions

100
packages/openwrt/Makefile Normal file
View file

@ -0,0 +1,100 @@
#
# Copyright (C) 2021 - ntop.org and contributors
#
include $(TOPDIR)/rules.mk
PKG_NAME:=n2n
PKG_VERSION:=HEAD
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
# These are defaults for compiling without any environmental overrides
# (eg, the github action calculates the correct overrides for each build)
PKG_SOURCE_URL:=https://github.com/ntop/n2n
PKG_SOURCE_VERSION:=dev
PKG_MIRROR_HASH:=skip
# Apply overrides from the build environment
ifdef N2N_PKG_SOURCE_URL
PKG_SOURCE_URL:=$(N2N_PKG_SOURCE_URL)
endif
ifdef N2N_PKG_SOURCE_VERSION
PKG_SOURCE_VERSION:=$(N2N_PKG_SOURCE_VERSION)
endif
ifdef N2N_PKG_VERSION
PKG_VERSION:=$(N2N_PKG_VERSION)
endif
PKG_MAINTAINER:=Emanuele Faranda <faranda@ntop.org>
PKG_LICENSE:=GPL3
# autogen fix
PKG_FIXUP:=autoreconf
include $(INCLUDE_DIR)/package.mk
define Package/n2n/Default
SECTION:=net
CATEGORY:=Network
TITLE:=N2N Peer-to-peer VPN
URL:=http://www.ntop.org/n2n
SUBMENU:=VPN
DEPENDS+=+libcap
endef
define Package/n2n-edge
$(call Package/n2n/Default)
TITLE+= client (edge node)
DEPENDS+=+kmod-tun
endef
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; \
./configure )
endef
define Package/n2n-edge/conffiles
/etc/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) $(PKG_BUILD_DIR)/packages/openwrt/etc/init.d/edge $(1)/etc/init.d/edge
$(INSTALL_DIR) $(1)/etc/n2n
$(INSTALL_CONF) $(PKG_BUILD_DIR)/packages/etc/n2n/edge.conf.sample $(1)/etc/n2n/edge.conf
endef
define Package/n2n-supernode/conffiles
/etc/n2n/supernode.conf
endef
define Package/n2n-supernode/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/supernode $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/packages/openwrt/etc/init.d/supernode $(1)/etc/init.d/supernode
$(INSTALL_DIR) $(1)/etc/n2n
$(INSTALL_CONF) $(PKG_BUILD_DIR)/packages/etc/n2n/supernode.conf.sample $(1)/etc/n2n/supernode.conf
endef
$(eval $(call BuildPackage,n2n-edge))
$(eval $(call BuildPackage,n2n-supernode))

View file

@ -0,0 +1,62 @@
## Prerequisites
This instructions explain how to build an OpenWRT .ipk package for n2n.
You will either need to build a full OpenWRT buildchain (See the github
action for building openwrt.yml for some example steps) or have a working
cross-compiling build environment for the OpenWRT version installed into
your device.
### Downloading a cross-compiling build environment
This usually comes down to the following steps:
1. Download and extract the SDK toolchain for your device. The toolchain
must match the *exact* OpenWRT version installed in your device. Toolchain
for official OpenWRT images can be downloaded from https://downloads.openwrt.org
2. Build the toolchain: run `make menuconfig`, save the configuration, then
run `make` to build the cross compiling tools
3. Download the feeds with `./scripts/feeds update -a`
## Compilation
These instructions are for building the current checked out version of the
n2n source (The generally used OpenWRT alternative is to download a tar.gz
file of a specific n2n version, but that is not as suitable for development
or local builds)
You need both the openwrt repository and the n2n repository checked out
for this. In these instructions, we assume that `openwrt` is the directory
where your openwrt checkout is located and `n2n` is the directory for
the n2n repository.
```
git clone https://github.com/ntop/n2n n2n
N2N_PKG_VERSION=$(n2n/scripts/version.sh)
export N2N_PKG_VERSION
cp -r n2n/packages/openwrt openwrt/package/n2n
cd openwrt
make menuconfig # select Network -> VPN -> n2n-edge and n2n-supernode
make package/n2n/clean V=s
make package/n2n/prepare USE_SOURCE_DIR=../n2n V=s
make package/n2n/compile V=s
```
If everything went fine, two ipk will be generated, one for the n2n-edge
and the other for n2n-supernode. They can be found with `find . -name "n2n*.ipk"`,
copied to the target device, and installed with `opkg install`.
The github action described in `.github/workflows/openwrt.yml` implements
an automated version of the above steps.
## Configuration
The edge node can be started with `/etc/init.d/edge start`.
Its configuration file is `/etc/n2n/edge.conf`.
The supernode can be started with `/etc/init.d/supernode start`.
Its configuration file is `/etc/n2n/supernode.conf`.

View file

@ -0,0 +1,25 @@
#!/bin/sh /etc/rc.common
START=90
STOP=10
USE_PROCD=1
PROG=/usr/bin/edge
CONFIGFILE=/etc/n2n/edge.conf
start_service() {
procd_open_instance
procd_set_param command $PROG $CONFIGFILE
procd_set_param file $CONFIGFILE
procd_set_param respawn
procd_close_instance
}
stop_service()
{
service_stop $PROG
}
service_triggers()
{
procd_add_reload_trigger "edge"
}

View file

@ -0,0 +1,25 @@
#!/bin/sh /etc/rc.common
START=90
STOP=10
USE_PROCD=1
PROG=/usr/bin/supernode
CONFIGFILE=/etc/n2n/supernode.conf
start_service() {
procd_open_instance
procd_set_param command $PROG $CONFIGFILE
procd_set_param file $CONFIGFILE
procd_set_param respawn
procd_close_instance
}
stop_service()
{
service_stop $PROG
}
service_triggers()
{
procd_add_reload_trigger "supernode"
}