mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-18 17:33:31 +00:00
startup n2n then add route table after 2s (#5852)
This commit is contained in:
parent
bd68f78374
commit
520c5099ba
@ -10,7 +10,7 @@ LUCI_TITLE:=n2n_v2 VPN Configuration module
|
||||
LUCI_DEPENDS:=+n2n-edge +n2n-supernode
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=2.8.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
@ -43,6 +43,7 @@ m = Map("n2n_v2", translate("N2N v2 VPN"), translatef(
|
||||
"n2n is a layer-two peer-to-peer virtual private network (VPN) which allows users to exploit features typical of P2P applications at network instead of application level."))
|
||||
|
||||
-- Basic config
|
||||
-- edge
|
||||
m:section(SimpleSection).template = "n2n_v2/status"
|
||||
|
||||
s = m:section(TypedSection, "edge", translate("N2N Edge Settings"))
|
||||
@ -89,14 +90,15 @@ s:option(Value, "key", translate("Encryption key"))
|
||||
route = s:option(Flag, "route", translate("Enable packet forwarding"))
|
||||
route.rmempty = false
|
||||
|
||||
s2 = m:section(TypedSection, "supernode", translate("N2N Supernode Settings"))
|
||||
s2.anonymous = true
|
||||
s2.addremove = true
|
||||
-- supernode
|
||||
s = m:section(TypedSection, "supernode", translate("N2N Supernode Settings"))
|
||||
s.anonymous = true
|
||||
s.addremove = true
|
||||
|
||||
switch = s2:option(Flag, "enabled", translate("Enable"))
|
||||
switch = s:option(Flag, "enabled", translate("Enable"))
|
||||
switch.rmempty = false
|
||||
|
||||
port = s2:option(Value, "port", translate("Port"))
|
||||
port = s:option(Value, "port", translate("Port"))
|
||||
port.datatype = "port"
|
||||
port.optional = false
|
||||
|
||||
@ -107,6 +109,10 @@ s.anonymous = true
|
||||
s.addremove = true
|
||||
s.template = "cbi/tblsection"
|
||||
|
||||
---- enable
|
||||
switch = s:option(Flag, "enabled", translate("Enable"))
|
||||
switch.rmempty = false
|
||||
|
||||
---- IP address
|
||||
o = s:option(Value, "ip", translate("IP"))
|
||||
o.optional = false
|
||||
|
@ -8,7 +8,7 @@ PKG_NAME:=n2n
|
||||
PKG_SOURCE_URL:=https://github.com/ntop/n2n.git
|
||||
PKG_SOURCE_VERSION:=99e56e9f3c34c49eeb297971d41150b433489120
|
||||
PKG_VERSION:=2.8.0_git-$(PKG_SOURCE_VERSION)
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=3
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
@ -9,8 +9,14 @@ config edge
|
||||
option port '1234'
|
||||
option community 'example'
|
||||
option key 'password'
|
||||
option route '0'
|
||||
option route '1'
|
||||
|
||||
config supernode
|
||||
option enabled '0'
|
||||
option port '1235'
|
||||
|
||||
config route
|
||||
option enabled '0'
|
||||
option ip '192.168.2.0'
|
||||
option mask '24'
|
||||
option gw '10.0.0.200'
|
||||
|
@ -22,11 +22,13 @@ start_instance() {
|
||||
config_get community "$cfg" 'community'
|
||||
config_get key "$cfg" 'key'
|
||||
config_get_bool route "$cfg" 'route' '0'
|
||||
address="$ipaddr/$prefix"
|
||||
address="$ipaddr"
|
||||
[ "$route" = "1" ] && args='-r'
|
||||
[ "$mode" = 'dhcp' ] && address='0.0.0.0'
|
||||
[ "-$mtu" != "-" ] && mtu="-M $mtu"
|
||||
/usr/bin/edge -u 0 -g 0 -d $tunname -a ${mode}:${address} -c $community $([ -n "$key" ] && echo -k $key) -l ${supernode}:${port} $args $mtu
|
||||
eval "$(ipcalc.sh "$ipaddr/$prefix")"
|
||||
netmask="$NETMASK"
|
||||
/usr/bin/edge -u 0 -g 0 -d $tunname -a ${mode}:${address} -s $netmask -c $community $([ -n "$key" ] && echo -k $key) -l ${supernode}:${port} $args $mtu
|
||||
;;
|
||||
supernode)
|
||||
config_get_bool enabled "$cfg" 'enabled' '0'
|
||||
@ -35,6 +37,8 @@ start_instance() {
|
||||
/usr/bin/supernode -l $port &
|
||||
;;
|
||||
route)
|
||||
config_get_bool enabled "$cfg" 'enabled' '0'
|
||||
[ "$enabled" = "0" ] && return 1
|
||||
config_get ip "$cfg" 'ip'
|
||||
config_get mask "$cfg" 'mask'
|
||||
config_get gw "$cfg" 'gw'
|
||||
@ -62,6 +66,7 @@ start() {
|
||||
config_load 'n2n_v2'
|
||||
config_foreach start_instance 'edge'
|
||||
config_foreach start_instance 'supernode'
|
||||
sleep 2
|
||||
config_foreach start_instance 'route'
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user