diff --git a/package/lean/luci-app-n2n_v2/Makefile b/package/lean/luci-app-n2n_v2/Makefile
index e95b28195..6ffc5b5c3 100755
--- a/package/lean/luci-app-n2n_v2/Makefile
+++ b/package/lean/luci-app-n2n_v2/Makefile
@@ -9,8 +9,8 @@ include $(TOPDIR)/rules.mk
LUCI_TITLE:=n2n_v2 VPN Configuration module
LUCI_DEPENDS:=+n2n-edge +n2n-supernode
LUCI_PKGARCH:=all
-PKG_VERSION:=1.0
-PKG_RELEASE:=4
+PKG_VERSION:=2.8.0
+PKG_RELEASE:=1
include $(TOPDIR)/feeds/luci/luci.mk
diff --git a/package/lean/luci-app-n2n_v2/luasrc/model/cbi/n2n_v2.lua b/package/lean/luci-app-n2n_v2/luasrc/model/cbi/n2n_v2.lua
index 83e09a487..c7c007e89 100644
--- a/package/lean/luci-app-n2n_v2/luasrc/model/cbi/n2n_v2.lua
+++ b/package/lean/luci-app-n2n_v2/luasrc/model/cbi/n2n_v2.lua
@@ -1,18 +1,53 @@
--[[
--N2N VPN(V2) configuration page. Made by 981213
--
-]]--
-
+]] --
local fs = require "nixio.fs"
-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."))
+function get_mask(v)
+ v:value("1 ", "128.0.0.0(1)")
+ v:value("2 ", "192.0.0.0(2)")
+ v:value("3 ", "224.0.0.0(3)")
+ v:value("4 ", "240.0.0.0(4)")
+ v:value("5 ", "248.0.0.0(5)")
+ v:value("6 ", "252.0.0.0(6)")
+ v:value("7 ", "254.0.0.0(7)")
+ v:value("8 ", "255.0.0.0(8)")
+ v:value("9 ", "255.128.0.0(9)")
+ v:value("10", "255.192.0.0(10)")
+ v:value("11", "255.224.0.0(11)")
+ v:value("12", "255.240.0.0(12)")
+ v:value("13", "255.248.0.0(13)")
+ v:value("14", "255.252.0.0(14)")
+ v:value("15", "255.254.0.0(15)")
+ v:value("16", "255.255.0.0(16)")
+ v:value("17", "255.255.128.0(17)")
+ v:value("18", "255.255.192.0(18)")
+ v:value("19", "255.255.224.0(19)")
+ v:value("20", "255.255.240.0(20)")
+ v:value("21", "255.255.248.0(21)")
+ v:value("22", "255.255.252.0(22)")
+ v:value("23", "255.255.254.0(23)")
+ v:value("24", "255.255.255.0(24)")
+ v:value("25", "255.255.255.128(25)")
+ v:value("26", "255.255.255.192(26)")
+ v:value("27", "255.255.255.224(27)")
+ v:value("28", "255.255.255.240(28)")
+ v:value("29", "255.255.255.248(29)")
+ v:value("30", "255.255.255.252(30)")
+ v:value("31", "255.255.255.254(31)")
+ v:value("32", "255.255.255.255(32)")
+end
-m:section(SimpleSection).template = "n2n_v2/status"
+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
+m:section(SimpleSection).template = "n2n_v2/status"
s = m:section(TypedSection, "edge", translate("N2N Edge Settings"))
s.anonymous = true
-s.addremove = true
+s.addremove = true
switch = s:option(Flag, "enabled", translate("Enable"))
switch.rmempty = false
@@ -26,19 +61,24 @@ mode:value("static")
ipaddr = s:option(Value, "ipaddr", translate("Interface IP address"))
ipaddr.optional = false
+ipaddr.datatype = "ip4addr"
+ipaddr:depends("mode", "static")
-netmask = s:option(Value, "netmask", translate("Interface netmask"))
-netmask.optional = false
+prefix = s:option(ListValue, "prefix", translate("Interface netmask"))
+get_mask(prefix)
+prefix.optional = false
+prefix:depends("mode", "static")
mtu = s:option(Value, "mtu", translate("MTU"))
mtu.datatype = "range(1,1500)"
mtu.optional = false
-supernode = s:option(Value, "supernode", translate("Supernode IP address"))
+supernode = s:option(Value, "supernode", translate("Supernode Host"))
+supernode.datatype = "host"
supernode.optional = false
port = s:option(Value, "port", translate("Supernode Port"))
-port.datatype = "range(0,65535)"
+port.datatype = "port"
port.optional = false
community = s:option(Value, "community", translate("N2N Community name"))
@@ -51,15 +91,38 @@ route.rmempty = false
s2 = m:section(TypedSection, "supernode", translate("N2N Supernode Settings"))
s2.anonymous = true
-s2.addremove = true
+s2.addremove = true
switch = s2:option(Flag, "enabled", translate("Enable"))
switch.rmempty = false
port = s2:option(Value, "port", translate("Port"))
-port.datatype = "range(0,65535)"
+port.datatype = "port"
port.optional = false
+-- Static route
+s = m:section(TypedSection, "route", translate("N2N routes"),
+ translate("Static route for n2n interface"))
+s.anonymous = true
+s.addremove = true
+s.template = "cbi/tblsection"
+
+---- IP address
+o = s:option(Value, "ip", translate("IP"))
+o.optional = false
+o.datatype = "ip4addr"
+o.rmempty = false
+
+---- IP mask
+o = s:option(ListValue, "mask", translate("Mask"))
+o.optional = false
+get_mask(o)
+o.default = "24"
+
+---- Gateway
+o = s:option(Value, "gw", translate("Gateway"))
+o.optional = false
+o.datatype = "ip4addr"
+o.rmempty = false
+
return m
-
-
diff --git a/package/lean/luci-app-n2n_v2/po/zh-cn/n2n_v2.po b/package/lean/luci-app-n2n_v2/po/zh-cn/n2n_v2.po
index 93e86e0a9..c5d5a637c 100755
--- a/package/lean/luci-app-n2n_v2/po/zh-cn/n2n_v2.po
+++ b/package/lean/luci-app-n2n_v2/po/zh-cn/n2n_v2.po
@@ -32,8 +32,8 @@ msgstr "接口IP地址"
msgid "Interface netmask"
msgstr "接口子网掩码"
-msgid "Supernode IP address"
-msgstr "Supernode节点IP地址"
+msgid "Supernode Host"
+msgstr "Supernode节点地址"
msgid "N2N Community name"
msgstr "N2N网络组名称"
@@ -58,3 +58,18 @@ msgstr "N2N v2 VPN 运行中"
msgid "N2N v2 VPN is not running."
msgstr "N2N v2 VPN 未运行"
+
+msgid "N2N routes"
+msgstr "路由表"
+
+msgid "Static route for n2n interface"
+msgstr "配置静态路由"
+
+msgid "IP"
+msgstr "IP"
+
+msgid "Mask"
+msgstr "掩码"
+
+msgid "Gateway"
+msgstr "网关"
\ No newline at end of file
diff --git a/package/lean/n2n_v2/Makefile b/package/lean/n2n_v2/Makefile
index 29da7ec64..42e2b7ad7 100644
--- a/package/lean/n2n_v2/Makefile
+++ b/package/lean/n2n_v2/Makefile
@@ -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:=1
+PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
diff --git a/package/lean/n2n_v2/files/n2n_v2.config b/package/lean/n2n_v2/files/n2n_v2.config
index 9c0e2cdac..40d43574d 100644
--- a/package/lean/n2n_v2/files/n2n_v2.config
+++ b/package/lean/n2n_v2/files/n2n_v2.config
@@ -3,7 +3,8 @@ config edge
option tunname 'n2n0'
option mode 'static'
option ipaddr '10.0.0.100'
- option netmask '255.255.255.0'
+ option prefix '24'
+ option mtu '1290'
option supernode '1.2.3.4'
option port '1234'
option community 'example'
diff --git a/package/lean/n2n_v2/files/n2n_v2.init b/package/lean/n2n_v2/files/n2n_v2.init
index 6e6038fa5..bd2517ddd 100644
--- a/package/lean/n2n_v2/files/n2n_v2.init
+++ b/package/lean/n2n_v2/files/n2n_v2.init
@@ -15,17 +15,18 @@ start_instance() {
config_get tunname "$cfg" 'tunname'
config_get mode "$cfg" 'mode'
config_get ipaddr "$cfg" 'ipaddr'
- config_get netmask "$cfg" 'netmask'
+ config_get prefix "$cfg" 'prefix'
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'
+ address="$ipaddr/$prefix"
[ "$route" = "1" ] && args='-r'
- [ "$mode" = 'dhcp' ] && ipaddr='0.0.0.0'
+ [ "$mode" = 'dhcp' ] && address='0.0.0.0'
[ "-$mtu" != "-" ] && mtu="-M $mtu"
- /usr/bin/edge -d $tunname -a ${mode}:${ipaddr} -c $community $([ -n "$key" ] && echo -k $key) -s ${netmask} -l ${supernode}:${port} $args $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
;;
supernode)
config_get_bool enabled "$cfg" 'enabled' '0'
@@ -33,6 +34,12 @@ start_instance() {
config_get port "$cfg" port
/usr/bin/supernode -l $port &
;;
+ route)
+ config_get ip "$cfg" 'ip'
+ config_get mask "$cfg" 'mask'
+ config_get gw "$cfg" 'gw'
+ route add -net $ip/$mask gw $gw
+ ;;
esac
}
@@ -55,6 +62,7 @@ start() {
config_load 'n2n_v2'
config_foreach start_instance 'edge'
config_foreach start_instance 'supernode'
+ config_foreach start_instance 'route'
}
stop() {