summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-network
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-mod-network')
-rw-r--r--modules/luci-mod-network/htdocs/luci-static/resources/view/network/routes.js102
-rw-r--r--modules/luci-mod-network/luasrc/controller/admin/network.lua2
-rw-r--r--modules/luci-mod-network/luasrc/model/cbi/admin_network/routes.lua102
3 files changed, 103 insertions, 103 deletions
diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/routes.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/routes.js
new file mode 100644
index 0000000000..4a002c2520
--- /dev/null
+++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/routes.js
@@ -0,0 +1,102 @@
+'use strict';
+'require form';
+'require network';
+'require tools.widgets as widgets';
+
+return L.view.extend({
+ load: function() {
+ return network.getDevices();
+ },
+
+ render: function(netdevs) {
+ var m, s, o;
+
+ m = new form.Map('network', _('Routes'), _('Routes specify over which interface and gateway a certain host or network can be reached.'));
+ m.tabbed = true;
+
+ for (var i = 4; i <= 6; i += 2) {
+ s = m.section(form.GridSection, (i == 4) ? 'route' : 'route6', (i == 4) ? _('Static IPv4 Routes') : _('Static IPv6 Routes'));
+ s.anonymous = true;
+ s.addremove = true;
+ s.sortable = true;
+
+ s.tab('general', _('General Settings'));
+ s.tab('advanced', _('Advanced Settings'));
+
+ o = s.taboption('general', widgets.NetworkSelect, 'interface', _('Interface'));
+ o.rmempty = false;
+ o.nocreate = true;
+
+ o = s.taboption('general', form.Value, 'target', _('Target'), (i == 4) ? _('Host-<abbr title="Internet Protocol Address">IP</abbr> or Network') : _('<abbr title="Internet Protocol Version 6">IPv6</abbr>-Address or Network (CIDR)'));
+ o.datatype = (i == 4) ? 'ip4addr' : 'ip6addr';
+ o.rmempty = false;
+
+ if (i == 4) {
+ o = s.taboption('general', form.Value, 'netmask', _('<abbr title="Internet Protocol Version 4">IPv4</abbr>-Netmask'), _('if target is a network'));
+ o.placeholder = '255.255.255.255';
+ o.datatype = 'ip4addr';
+ o.rmempty = true;
+ }
+
+ o = s.taboption('general', form.Value, 'gateway', (i == 4) ? _('<abbr title="Internet Protocol Version 4">IPv4</abbr>-Gateway') : _('<abbr title="Internet Protocol Version 6">IPv6</abbr>-Gateway'));
+ o.datatype = (i == 4) ? 'ip4addr' : 'ip6addr';
+ o.rmempty = true;
+
+ o = s.taboption('advanced', form.Value, 'metric', _('Metric'));
+ o.placeholder = 0;
+ o.datatype = (i == 4) ? 'range(0,255)' : 'range(0,65535)';
+ o.rmempty = true;
+ o.textvalue = function(section_id) {
+ return this.cfgvalue(section_id) || 0;
+ };
+
+ o = s.taboption('advanced', form.Value, 'mtu', _('MTU'));
+ o.placeholder = 1500;
+ o.datatype = 'range(64,9000)';
+ o.rmempty = true;
+ o.modalonly = true;
+
+ o = s.taboption('advanced', form.ListValue, 'type', _('Route type'));
+ o.value('', 'unicast');
+ o.value('local');
+ o.value('broadcast');
+ o.value('multicast');
+ o.value('unreachable');
+ o.value('prohibit');
+ o.value('blackhole');
+ o.value('anycast');
+ o.default = '';
+ o.rmempty = true;
+ o.modalonly = true;
+
+ o = s.taboption('advanced', form.Value, 'table', _('Route table'));
+ o.value('local', 'local (255)');
+ o.value('main', 'main (254)');
+ o.value('default', 'default (253)');
+ o.rmempty = true;
+ o.modalonly = true;
+ o.cfgvalue = function(section_id) {
+ var cfgvalue = this.super('cfgvalue', [section_id]);
+ return cfgvalue || 'main';
+ };
+
+ o = s.taboption('advanced', form.Value, 'source', _('Source Address'));
+ o.placeholder = E('em', _('automatic'));
+ for (var j = 0; j < netdevs.length; j++) {
+ var addrs = netdevs[j].getIPAddrs();
+ for (var k = 0; k < addrs.length; k++)
+ o.value(addrs[k].split('/')[0]);
+ }
+ o.datatype = (i == 4) ? 'ip4addr' : 'ip6addr';
+ o.default = '';
+ o.rmempty = true;
+ o.modalonly = true;
+
+ o = s.taboption('advanced', form.Flag, 'onlink', _('On-Link route'));
+ o.default = o.disabled;
+ o.rmempty = true;
+ }
+
+ return m.render();
+ }
+});
diff --git a/modules/luci-mod-network/luasrc/controller/admin/network.lua b/modules/luci-mod-network/luasrc/controller/admin/network.lua
index 5c580b4ef9..6bd92b2d1a 100644
--- a/modules/luci-mod-network/luasrc/controller/admin/network.lua
+++ b/modules/luci-mod-network/luasrc/controller/admin/network.lua
@@ -114,7 +114,7 @@ function index()
end
page = node("admin", "network", "routes")
- page.target = cbi("admin_network/routes")
+ page.target = view("network/routes")
page.title = _("Static Routes")
page.order = 50
diff --git a/modules/luci-mod-network/luasrc/model/cbi/admin_network/routes.lua b/modules/luci-mod-network/luasrc/model/cbi/admin_network/routes.lua
deleted file mode 100644
index 1970f36a28..0000000000
--- a/modules/luci-mod-network/luasrc/model/cbi/admin_network/routes.lua
+++ /dev/null
@@ -1,102 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Licensed to the public under the Apache License 2.0.
-
-local wa = require "luci.tools.webadmin"
-local fs = require "nixio.fs"
-
-m = Map("network",
- translate("Routes"),
- translate("Routes specify over which interface and gateway a certain host or network " ..
- "can be reached."))
-
-s = m:section(TypedSection, "route", translate("Static IPv4 Routes"))
-s.addremove = true
-s.anonymous = true
-
-s.template = "cbi/tblsection"
-
-iface = s:option(ListValue, "interface", translate("Interface"))
-wa.cbi_add_networks(iface)
-
-t = s:option(Value, "target", translate("Target"), translate("Host-<abbr title=\"Internet Protocol Address\">IP</abbr> or Network"))
-t.datatype = "ip4addr"
-t.rmempty = false
-
-n = s:option(Value, "netmask", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Netmask"), translate("if target is a network"))
-n.placeholder = "255.255.255.255"
-n.datatype = "ip4addr"
-n.rmempty = true
-
-g = s:option(Value, "gateway", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Gateway"))
-g.datatype = "ip4addr"
-g.rmempty = true
-
-metric = s:option(Value, "metric", translate("Metric"))
-metric.placeholder = 0
-metric.datatype = "range(0,255)"
-metric.size = 5
-metric.rmempty = true
-
-mtu = s:option(Value, "mtu", translate("MTU"))
-mtu.placeholder = 1500
-mtu.datatype = "range(64,9000)"
-mtu.size = 5
-mtu.rmempty = true
-
-routetype = s:option(Value, "type", translate("Route type"))
-routetype:value("", "unicast")
-routetype:value("local", "local")
-routetype:value("broadcast", "broadcast")
-routetype:value("multicast", "multicast")
-routetype:value("unreachable", "unreachable")
-routetype:value("prohibit", "prohibit")
-routetype:value("blackhole", "blackhole")
-routetype:value("anycast", "anycast")
-routetype.default = ""
-routetype.rmempty = true
-
-if fs.access("/proc/net/ipv6_route") then
- s = m:section(TypedSection, "route6", translate("Static IPv6 Routes"))
- s.addremove = true
- s.anonymous = true
-
- s.template = "cbi/tblsection"
-
- iface = s:option(ListValue, "interface", translate("Interface"))
- wa.cbi_add_networks(iface)
-
- t = s:option(Value, "target", translate("Target"), translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Address or Network (CIDR)"))
- t.datatype = "ip6addr"
- t.rmempty = false
-
- g = s:option(Value, "gateway", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Gateway"))
- g.datatype = "ip6addr"
- g.rmempty = true
-
- metric = s:option(Value, "metric", translate("Metric"))
- metric.placeholder = 0
- metric.datatype = "range(0,65535)" -- XXX: not sure
- metric.size = 5
- metric.rmempty = true
-
- mtu = s:option(Value, "mtu", translate("MTU"))
- mtu.placeholder = 1500
- mtu.datatype = "range(64,9000)"
- mtu.size = 5
- mtu.rmempty = true
-
- routetype = s:option(Value, "type", translate("Route type"))
- routetype:value("", "unicast")
- routetype:value("local", "local")
- routetype:value("broadcast", "broadcast")
- routetype:value("multicast", "multicast")
- routetype:value("unreachable", "unreachable")
- routetype:value("prohibit", "prohibit")
- routetype:value("blackhole", "blackhole")
- routetype:value("anycast", "anycast")
- routetype.default = ""
- routetype.rmempty = true
-end
-
-
-return m