diff --git a/luci-app-mlvpn/Makefile b/luci-app-mlvpn/Makefile new file mode 100644 index 000000000..e9ad0fa78 --- /dev/null +++ b/luci-app-mlvpn/Makefile @@ -0,0 +1,15 @@ +# +# Copyright (C) 2018 Ycarus (Yannick Chabanois) +# +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=LuCI Support for MLVPN +LUCI_DEPENDS:=+mlvpn + +PKG_LICENSE:=GPLv3 + +include ../luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-mlvpn/luasrc/controller/mlvpn.lua b/luci-app-mlvpn/luasrc/controller/mlvpn.lua new file mode 100644 index 000000000..aefd8c027 --- /dev/null +++ b/luci-app-mlvpn/luasrc/controller/mlvpn.lua @@ -0,0 +1,6 @@ +module("luci.controller.mlvpn", package.seeall) + +function index() + --entry({"admin", "openmptcprouter", "mlvpn"}, cbi("mlvpn"), _("MLVPN")) + entry({"admin", "services", "mlvpn"}, cbi("mlvpn"), _("MLVPN")) +end diff --git a/luci-app-mlvpn/luasrc/model/cbi/mlvpn.lua b/luci-app-mlvpn/luasrc/model/cbi/mlvpn.lua new file mode 100644 index 000000000..eaef23d7e --- /dev/null +++ b/luci-app-mlvpn/luasrc/model/cbi/mlvpn.lua @@ -0,0 +1,77 @@ +local net = require "luci.model.network".init() +local sys = require "luci.sys" +local ifaces = sys.net:devices() +local m, s, o + +m = Map("mlvpn", translate("MLVPN")) + +s = m:section(TypedSection, "mlvpn", translate("Settings")) +s.anonymous = true +s.addremove = false + +o = s:option(Flag, "enable", translate("Enable")) +o.rmempty = false + +o = s:option(Value, "timeout", translate("Timeout (s)")) +o.placeholder = "30" +o.default = "30" +o.datatype = "uinteger" +o.rmempty = false + +o = s:option(Value, "reorder_buffer_size", translate("Reorder buffer size")) +o.placeholder = "64" +o.default = "64" +o.datatype = "uinteger" +o.rmempty = false + +o = s:option(Value, "loss_tolerance", translate("Loss tolerance")) +o.placeholder = "50" +o.default = "50" +o.datatype = "uinteger" +o.rmempty = false + +o = s:option(Value, "host", translate("Remote host")) +o.placeholder = "128.128.128.128" +o.default = "128.128.128.128" +o.datatype = "host" +o.rmempty = false + +o = s:option(Value, "firstport", translate("First remote port"),translate("Interface will increase port used beginning with this")) +o.default = "65201" +o.datatype = "port" +o.rmempty = false + +o = s:option(Value, "password", translate("Password")) +o.password = true +o.rmempty = false + + +o = s:option(Value, "interface_name", translate("Interface name")) +o.placeholder = "mlvpn0" +o.default = "mlvpn0" +o.rmempty = false + +--o = s:option(Value, "mode", translate("Mode")) +--o:value("client") +--o:value("server") +--o.default = "client" +--o.rmempty = false + + +--s = m:section(TypedSection, "interface", translate("Interfaces")) +--s.template_addremove = "mlvpn/cbi-select-add" +--s.addremove = true +--s.add_select_options = { } +--s.add_select_options[''] = '' +--for _, iface in ipairs(ifaces) do +-- if not (iface == "lo" or iface:match("^ifb.*")) then +-- s.add_select_options[iface] = iface +-- end +--end + +--o = s:option(Value, "port", translate("Remote/Bind port")) +--o.placeholder = "65201" +--o.default = "65201" +--o.datatype = "port" + +return m diff --git a/luci-app-mlvpn/luasrc/view/mlvpn/cbi-select-add.htm b/luci-app-mlvpn/luasrc/view/mlvpn/cbi-select-add.htm new file mode 100644 index 000000000..9ee30d310 --- /dev/null +++ b/luci-app-mlvpn/luasrc/view/mlvpn/cbi-select-add.htm @@ -0,0 +1,10 @@ +
+ <% if self.invalid_cts then -%>
<% end %> + + + <% if self.invalid_cts then %>
<%:Invalid%>
<% end %> +
diff --git a/mlvpn/files/etc/config/mlvpn b/mlvpn/files/etc/config/mlvpn index 19c261289..2c556a038 100644 --- a/mlvpn/files/etc/config/mlvpn +++ b/mlvpn/files/etc/config/mlvpn @@ -5,6 +5,6 @@ config mlvpn 'general' option reorder_buffer_size '64' option loss_tolerence '50' option mode 'client' - option remotehost '128.128.128.128' - option firstremoteport '65201' + option host '128.128.128.128' + option firstport '65201' option interface_name 'mlvpn0' diff --git a/mlvpn/files/etc/init.d/mlvpn b/mlvpn/files/etc/init.d/mlvpn index e9e46260c..f7a813738 100755 --- a/mlvpn/files/etc/init.d/mlvpn +++ b/mlvpn/files/etc/init.d/mlvpn @@ -12,28 +12,28 @@ validate_section() { 'reorder_buffer_size:uinteger:64' \ 'loss_tolerence:uinteger:30' \ 'interface_name:string:mlvpn0' \ - 'remotehost:host' \ - 'firstremoteport:port:65201' + 'host:host' \ + 'firstport:port' } -interface_settings() { - local mode +interface_multipath_settings() { + local mode port local config="$1" id=$(($id+1)) config_get mode "$config" multipath "off" [ "$mode" = "off" ] && return 1 count=$(($count+1)) - port=$((firstremoteport+count)) + port=$((firstport+count)) cat >> /tmp/etc/${interface_name}.conf <<-EOF [${id}] - remotehost = "${remotehost}" + remotehost = "${host}" remoteport = "${port}" EOF } start_service() { - local enable timeout mode password reorder_buffer_size interface_name remotehost firstremoteport loss_tolerence + local enable timeout mode password reorder_buffer_size interface_name host firstport loss_tolerence validate_section "general" || { _err "validation failed" return 1 @@ -55,9 +55,10 @@ start_service() { loss_tolerence = ${loss_tolerence} password = "${password}" EOF + local count=0 id=0 config_load network - config_foreach interface_settings interface + config_foreach interface_multipath_settings interface chmod 0600 "/tmp/etc/${interface_name}.conf" procd_open_instance diff --git a/mlvpn/files/etc/uci-defaults/4100-mlvpn b/mlvpn/files/etc/uci-defaults/4100-mlvpn index cd165c37a..eed3d5dd5 100644 --- a/mlvpn/files/etc/uci-defaults/4100-mlvpn +++ b/mlvpn/files/etc/uci-defaults/4100-mlvpn @@ -21,9 +21,9 @@ if [ "$(uci -q get network.omrvpn)" = "" ] && [ "$(uci -q get network.mlvpn)" = EOF fi -if [ "$(uci get firewall.@zone[2].network | grep omrvpn)" = "" ] && [ "$(uci get firewall.@zone[2].network | grep mlvpn)" = "" ]; then +if [ "$(uci get firewall.zone_vpn.network | grep omrvpn)" = "" ] && [ "$(uci get firewall.zone_vpn.network | grep mlvpn)" = "" ]; then uci -q batch <<-EOF >/dev/null - add_list firewall.@zone[2].network='mlvpn' + add_list firewall.zone_vpn.network='mlvpn' EOF fi rm -f /tmp/luci-indexcache