mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Update luci-mod-network from OpenWRT
This commit is contained in:
parent
c12e49844e
commit
ad7ecd87e2
6 changed files with 1375 additions and 398 deletions
|
@ -65,46 +65,32 @@ function render_status(node, ifc, with_device) {
|
|||
null, E('em', _('Interface is marked for deletion'))
|
||||
]);
|
||||
|
||||
var i18n = ifc.getI18n();
|
||||
if (i18n)
|
||||
desc = desc ? '%s (%s)'.format(desc, i18n) : i18n;
|
||||
desc = desc ? '%s (%s)'.format(desc, ifc.getI18n()) : ifc.getI18n();
|
||||
|
||||
var changecount = with_device ? 0 : count_changes(ifc.getName()),
|
||||
ipaddrs = changecount ? [] : ifc.getIPAddrs(),
|
||||
ip6addrs = changecount ? [] : ifc.getIP6Addrs(),
|
||||
errors = ifc.getErrors(),
|
||||
maindev = ifc.getL3Device() || ifc.getDevice(),
|
||||
macaddr = maindev ? maindev.getMAC() : null;
|
||||
const changecount = with_device ? 0 : count_changes(ifc.getName());
|
||||
const maindev = ifc.getL3Device() || ifc.getDevice();
|
||||
const macaddr = maindev ? maindev.getMAC() : null;
|
||||
const cond00 = !changecount && !ifc.isDynamic() && !ifc.isAlias();
|
||||
const cond01 = cond00 && macaddr;
|
||||
const cond02 = cond00 && maindev;
|
||||
|
||||
function addEntries(label, array) {
|
||||
return Array.isArray(array) ? array.flatMap((item) => [label, item]) : [label, null];
|
||||
}
|
||||
|
||||
return L.itemlist(node, [
|
||||
_('Protocol'), with_device ? null : (desc || '?'),
|
||||
_('Device'), with_device ? (maindev ? maindev.getShortName() : E('em', _('Not present'))) : null,
|
||||
_('Uptime'), (!changecount && ifc.isUp()) ? '%t'.format(ifc.getUptime()) : null,
|
||||
_('MAC'), (!changecount && !ifc.isDynamic() && !ifc.isAlias() && macaddr) ? macaddr : null,
|
||||
_('RX'), (!changecount && !ifc.isDynamic() && !ifc.isAlias() && maindev) ? '%.2mB (%d %s)'.format(maindev.getRXBytes(), maindev.getRXPackets(), _('Pkts.')) : null,
|
||||
_('TX'), (!changecount && !ifc.isDynamic() && !ifc.isAlias() && maindev) ? '%.2mB (%d %s)'.format(maindev.getTXBytes(), maindev.getTXPackets(), _('Pkts.')) : null,
|
||||
_('IPv4'), ipaddrs[0],
|
||||
_('IPv4'), ipaddrs[1],
|
||||
_('IPv4'), ipaddrs[2],
|
||||
_('IPv4'), ipaddrs[3],
|
||||
_('IPv4'), ipaddrs[4],
|
||||
_('IPv6'), ip6addrs[0],
|
||||
_('IPv6'), ip6addrs[1],
|
||||
_('IPv6'), ip6addrs[2],
|
||||
_('IPv6'), ip6addrs[3],
|
||||
_('IPv6'), ip6addrs[4],
|
||||
_('IPv6'), ip6addrs[5],
|
||||
_('IPv6'), ip6addrs[6],
|
||||
_('IPv6'), ip6addrs[7],
|
||||
_('IPv6'), ip6addrs[8],
|
||||
_('IPv6'), ip6addrs[9],
|
||||
_('IPv6-PD'), changecount ? null : ifc.getIP6Prefix(),
|
||||
_('Device'), with_device ? (maindev ? maindev.getShortName() : E('em', _('Not present'))) : null,
|
||||
_('Uptime'), (!changecount && ifc.isUp()) ? '%t'.format(ifc.getUptime()) : null,
|
||||
_('MAC'), (cond01) ? macaddr : null,
|
||||
_('RX'), (cond02) ? '%.2mB (%d %s)'.format(maindev.getRXBytes(), maindev.getRXPackets(), _('Pkts.')) : null,
|
||||
_('TX'), (cond02) ? '%.2mB (%d %s)'.format(maindev.getTXBytes(), maindev.getTXPackets(), _('Pkts.')) : null,
|
||||
...addEntries(_('IPv4'), changecount ? [] : ifc.getIPAddrs()),
|
||||
...addEntries(_('IPv6'), changecount ? [] : ifc.getIP6Addrs()),
|
||||
...addEntries(_('IPv6-PD'), changecount ? null : ifc.getIP6Prefixes?.()),
|
||||
_('Information'), with_device ? null : (ifc.get('disabled') != '1' ? null : _('Interface disabled')),
|
||||
_('Information'), with_device ? null : (ifc.get('auto') != '0' ? null : _('Not started on boot')),
|
||||
_('Error'), errors ? errors[0] : null,
|
||||
_('Error'), errors ? errors[1] : null,
|
||||
_('Error'), errors ? errors[2] : null,
|
||||
_('Error'), errors ? errors[3] : null,
|
||||
_('Error'), errors ? errors[4] : null,
|
||||
...addEntries(_('Error'), ifc.getErrors()),
|
||||
null, changecount ? E('a', {
|
||||
href: '#',
|
||||
click: L.bind(ui.changes.displayChanges, ui.changes)
|
||||
|
@ -175,9 +161,9 @@ function iface_updown(up, id, ev, force) {
|
|||
|
||||
ui.showModal(_('Confirm disconnect'), [
|
||||
E('p', _('You appear to be currently connected to the device via the "%h" interface. Do you really want to shut down the interface?').format(id)),
|
||||
E('div', { 'class': 'right' }, [
|
||||
E('div', { 'class': 'button-row' }, [
|
||||
E('button', {
|
||||
'class': 'cbi-button cbi-button-neutral',
|
||||
'class': 'btn cbi-button cbi-button-neutral',
|
||||
'click': function(ev) {
|
||||
btns[1].classList.remove('spinning');
|
||||
btns[1].disabled = false;
|
||||
|
@ -188,7 +174,7 @@ function iface_updown(up, id, ev, force) {
|
|||
}, _('Cancel')),
|
||||
' ',
|
||||
E('button', {
|
||||
'class': 'cbi-button cbi-button-negative important',
|
||||
'class': 'btn cbi-button cbi-button-negative important',
|
||||
'click': function(ev) {
|
||||
dsc.setAttribute('disconnect', '');
|
||||
dom.content(dsc, E('em', _('Interface is shutting down...')));
|
||||
|
@ -264,39 +250,6 @@ function has_sourcefilter(proto) {
|
|||
return false;
|
||||
}
|
||||
|
||||
var cbiRichListValue = form.ListValue.extend({
|
||||
renderWidget: function(section_id, option_index, cfgvalue) {
|
||||
var choices = this.transformChoices();
|
||||
var widget = new ui.Dropdown((cfgvalue != null) ? cfgvalue : this.default, choices, {
|
||||
id: this.cbid(section_id),
|
||||
sort: this.keylist,
|
||||
optional: true,
|
||||
select_placeholder: this.select_placeholder || this.placeholder,
|
||||
custom_placeholder: this.custom_placeholder || this.placeholder,
|
||||
validate: L.bind(this.validate, this, section_id),
|
||||
disabled: (this.readonly != null) ? this.readonly : this.map.readonly
|
||||
});
|
||||
|
||||
return widget.render();
|
||||
},
|
||||
|
||||
value: function(value, title, description) {
|
||||
if (description) {
|
||||
form.ListValue.prototype.value.call(this, value, E([], [
|
||||
E('span', { 'class': 'hide-open' }, [ title ]),
|
||||
E('div', { 'class': 'hide-close', 'style': 'min-width:25vw' }, [
|
||||
E('strong', [ title ]),
|
||||
E('br'),
|
||||
E('span', { 'style': 'white-space:normal' }, description)
|
||||
])
|
||||
]));
|
||||
}
|
||||
else {
|
||||
form.ListValue.prototype.value.call(this, value, title);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return view.extend({
|
||||
poll_status: function(map, networks) {
|
||||
var resolveZone = null;
|
||||
|
@ -470,6 +423,7 @@ return view.extend({
|
|||
},
|
||||
|
||||
render: function(data) {
|
||||
|
||||
if (this.interfaceBridgeWithIfnameSections().length)
|
||||
return this.renderBridgeMigration();
|
||||
else if (this.deviceWithIfnameSections().length || this.interfaceWithIfnameSections().length)
|
||||
|
@ -498,7 +452,8 @@ return view.extend({
|
|||
s.load = function() {
|
||||
return Promise.all([
|
||||
network.getNetworks(),
|
||||
firewall.getZones()
|
||||
firewall.getZones(),
|
||||
uci.load('system')
|
||||
]).then(L.bind(function(data) {
|
||||
this.networks = data[0];
|
||||
this.zones = data[1];
|
||||
|
@ -560,13 +515,9 @@ return view.extend({
|
|||
};
|
||||
|
||||
s.addModalOptions = function(s) {
|
||||
var protoval = uci.get('network', s.section, 'proto'),
|
||||
protoclass = protoval ? network.getProtocol(protoval) : null,
|
||||
var protoval = uci.get('network', s.section, 'proto') || 'none',
|
||||
o, proto_select, proto_switch, type, stp, igmp, ss, so;
|
||||
|
||||
if (!protoval)
|
||||
return;
|
||||
|
||||
return network.getNetwork(s.section).then(L.bind(function(ifc) {
|
||||
var protocols = network.getProtocols();
|
||||
|
||||
|
@ -589,6 +540,7 @@ return view.extend({
|
|||
|
||||
proto_select = s.taboption('general', form.ListValue, 'proto', _('Protocol'));
|
||||
proto_select.modalonly = true;
|
||||
proto_select.default = 'none';
|
||||
|
||||
proto_switch = s.taboption('general', form.Button, '_switch_proto');
|
||||
proto_switch.modalonly = true;
|
||||
|
@ -657,7 +609,7 @@ return view.extend({
|
|||
for (var i = 0; i < protocols.length; i++) {
|
||||
proto_select.value(protocols[i].getProtocol(), protocols[i].getI18n());
|
||||
|
||||
if (protocols[i].getProtocol() != uci.get('network', s.section, 'proto'))
|
||||
if (protocols[i].getProtocol() != protoval)
|
||||
proto_switch.depends('proto', protocols[i].getProtocol());
|
||||
}
|
||||
|
||||
|
@ -706,7 +658,7 @@ return view.extend({
|
|||
ss.taboption('general', form.Flag, 'ignore', _('Ignore interface'), _('Disable <abbr title="Dynamic Host Configuration Protocol">DHCP</abbr> for this interface.'));
|
||||
|
||||
if (protoval == 'static') {
|
||||
so = ss.taboption('general', form.Value, 'start', _('Start'), _('Lowest leased address as offset from the network address.'));
|
||||
so = ss.taboption('general', form.Value, 'start', _('Start', 'DHCP IP range start address'), _('Lowest leased address as offset from the network address.'));
|
||||
so.optional = true;
|
||||
so.datatype = 'or(uinteger,ip4addr("nomask"))';
|
||||
so.default = '100';
|
||||
|
@ -719,6 +671,17 @@ return view.extend({
|
|||
so = ss.taboption('general', form.Value, 'leasetime', _('Lease time'), _('Expiry time of leased addresses, minimum is 2 minutes (<code>2m</code>).'));
|
||||
so.optional = true;
|
||||
so.default = '12h';
|
||||
so.validate = function (section_id, value) {
|
||||
if (value === "infinite" || value === "deprecated") {
|
||||
return true;
|
||||
}
|
||||
|
||||
const regex = new RegExp("^[0-9]+[smhdw]?$", "i");
|
||||
if (regex.test(value)) {
|
||||
return true;
|
||||
}
|
||||
return _("Invalid DHCP lease time format. Use integer values optionally followed by s, m, h, d, or w.");
|
||||
}
|
||||
|
||||
so = ss.taboption('advanced', form.Flag, 'dynamicdhcp', _('Dynamic <abbr title="Dynamic Host Configuration Protocol">DHCP</abbr>'), _('Dynamically allocate DHCP addresses for clients. If disabled, only clients having static leases will be served.'));
|
||||
so.default = so.enabled;
|
||||
|
@ -771,9 +734,9 @@ return view.extend({
|
|||
|
||||
/* Assume that serving RAs by default is fine, but disallow it for certain
|
||||
interface protocols such as DHCP, DHCPv6 or the various PPP flavors.
|
||||
The intent is to only allow RA serving for interface protocols doing
|
||||
The intent is only to allow RA serving for interface protocols doing
|
||||
some kind of static IP config over something resembling a layer 2
|
||||
ethernet device. */
|
||||
Ethernet device. */
|
||||
switch (protoval) {
|
||||
case 'dhcp':
|
||||
case 'dhcpv6':
|
||||
|
@ -823,8 +786,9 @@ return view.extend({
|
|||
};
|
||||
|
||||
|
||||
so = ss.taboption('ipv6', cbiRichListValue, 'ra', _('<abbr title="Router Advertisement">RA</abbr>-Service'),
|
||||
so = ss.taboption('ipv6', form.RichListValue, 'ra', _('<abbr title="Router Advertisement">RA</abbr>-Service'),
|
||||
_('Configures the operation mode of the <abbr title="Router Advertisement">RA</abbr> service on this interface.'));
|
||||
so.optional = true;
|
||||
so.value('', _('disabled'),
|
||||
_('Do not send any <abbr title="Router Advertisement, ICMPv6 Type 134">RA</abbr> messages on this interface.'));
|
||||
so.value('server', _('server mode'),
|
||||
|
@ -834,8 +798,9 @@ return view.extend({
|
|||
so.value('hybrid', _('hybrid mode'), ' ');
|
||||
|
||||
|
||||
so = ss.taboption('ipv6-ra', cbiRichListValue, 'ra_default', _('Default router'),
|
||||
so = ss.taboption('ipv6-ra', form.RichListValue, 'ra_default', _('Default router'),
|
||||
_('Configures the default router advertisement in <abbr title="Router Advertisement">RA</abbr> messages.'));
|
||||
so.optional = true;
|
||||
so.value('', _('automatic'),
|
||||
_('Announce this device as default router if a local IPv6 default route is present.'));
|
||||
so.value('1', _('on available prefix'),
|
||||
|
@ -851,8 +816,9 @@ return view.extend({
|
|||
so.depends('ra', 'server');
|
||||
so.depends({ ra: 'hybrid', master: '0' });
|
||||
|
||||
so = ss.taboption('ipv6-ra', cbiRichListValue, 'ra_flags', _('<abbr title="Router Advertisement">RA</abbr> Flags'),
|
||||
so = ss.taboption('ipv6-ra', form.RichListValue, 'ra_flags', _('<abbr title="Router Advertisement">RA</abbr> Flags'),
|
||||
_('Specifies the flags sent in <abbr title="Router Advertisement">RA</abbr> messages, for example to instruct clients to request further information via stateful DHCPv6.'));
|
||||
so.optional = true;
|
||||
so.value('managed-config', _('managed config (M)'),
|
||||
_('The <em>Managed address configuration</em> (M) flag indicates that IPv6 addresses are available via DHCPv6.'));
|
||||
so.value('other-config', _('other config (O)'),
|
||||
|
@ -945,8 +911,9 @@ return view.extend({
|
|||
};
|
||||
|
||||
|
||||
so = ss.taboption('ipv6', cbiRichListValue, 'dhcpv6', _('DHCPv6-Service'),
|
||||
so = ss.taboption('ipv6', form.RichListValue, 'dhcpv6', _('DHCPv6-Service'),
|
||||
_('Configures the operation mode of the DHCPv6 service on this interface.'));
|
||||
so.optional = true;
|
||||
so.value('', _('disabled'),
|
||||
_('Do not offer DHCPv6 service on this interface.'));
|
||||
so.value('server', _('server mode'),
|
||||
|
@ -984,9 +951,35 @@ return view.extend({
|
|||
so.depends('dhcpv6', 'server');
|
||||
so.depends({ dhcpv6: 'hybrid', master: '0' });
|
||||
|
||||
//This is a DHCPv6 specific odhcpd setting
|
||||
so = ss.taboption('ipv6', form.DynamicList, 'ntp', _('NTP Servers'),
|
||||
_('DHCPv6 option 56. %s.', 'DHCPv6 option 56. RFC5908 link').format('<a href="%s" target="_blank">RFC5908</a>').format('https://www.rfc-editor.org/rfc/rfc5908#section-4'));
|
||||
so.datatype = 'host(0)';
|
||||
for(var x of uci.get('system', 'ntp', 'server') || '') {
|
||||
so.value(x);
|
||||
}
|
||||
var local_nets = this.networks.filter(function(n) { return n.getName() != 'loopback' });
|
||||
if(local_nets) {
|
||||
// If ntpd is set up, suggest our IP(v6) also
|
||||
if(uci.get('system', 'ntp', 'enable_server')) {
|
||||
local_nets.forEach(function(n){
|
||||
n.getIPAddrs().forEach(function(i4) {
|
||||
so.value(i4.split('/')[0]);
|
||||
});
|
||||
n.getIP6Addrs().forEach(function(i6) {
|
||||
so.value(i6.split('/')[0]);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
so.optional = true;
|
||||
so.rmempty = true;
|
||||
so.depends('dhcpv6', 'server');
|
||||
so.depends({ dhcpv6: 'hybrid', master: '0' });
|
||||
|
||||
so = ss.taboption('ipv6', cbiRichListValue, 'ndp', _('<abbr title="Neighbour Discovery Protocol">NDP</abbr>-Proxy'),
|
||||
so = ss.taboption('ipv6', form.RichListValue, 'ndp', _('<abbr title="Neighbour Discovery Protocol">NDP</abbr>-Proxy'),
|
||||
_('Configures the operation mode of the NDP proxy service on this interface.'));
|
||||
so.optional = true;
|
||||
so.value('', _('disabled'),
|
||||
_('Do not proxy any <abbr title="Neighbour Discovery Protocol">NDP</abbr> packets.'));
|
||||
so.value('relay', _('relay mode'),
|
||||
|
@ -1041,10 +1034,11 @@ return view.extend({
|
|||
o.datatype = 'uinteger';
|
||||
o.placeholder = '0';
|
||||
|
||||
o = nettools.replaceOption(s, 'advanced', form.Value, 'metric', _('Use gateway metric'));
|
||||
o = nettools.replaceOption(s, 'advanced', form.Value, 'metric', _('Use gateway metric'),
|
||||
_('Metric is an ordinal, where a gateway with 1 is chosen 1st, 2 is chosen 2nd, 3 is chosen 3rd, etc'));
|
||||
o.datatype = 'uinteger';
|
||||
o.placeholder = '0';
|
||||
|
||||
|
||||
o = nettools.replaceOption(s,'advanced', form.ListValue, 'multipath', _('Multipath setting'), _('Only one interface must be set as Master.'));
|
||||
o.value('on',_('Enabled'));
|
||||
o.value('off',_('Disabled'));
|
||||
|
@ -1216,7 +1210,10 @@ return view.extend({
|
|||
};
|
||||
|
||||
proto = s2.option(form.ListValue, 'proto', _('Protocol'));
|
||||
proto.validate = name.validate;
|
||||
proto.onchange = function(ev, section_id, value) {
|
||||
var elem = name.getUIElement(section_id);
|
||||
elem.triggerValidation();
|
||||
};
|
||||
|
||||
device = s2.option(widgets.DeviceSelect, 'device', _('Device'));
|
||||
device.noaliases = false;
|
||||
|
@ -1471,6 +1468,9 @@ return view.extend({
|
|||
case '8021ad':
|
||||
return '8021ad';
|
||||
|
||||
case 'bonding':
|
||||
return 'bonding';
|
||||
|
||||
case 'bridge':
|
||||
return 'bridge';
|
||||
|
||||
|
@ -1503,6 +1503,9 @@ return view.extend({
|
|||
case '8021ad':
|
||||
return _('VLAN (802.1ad)');
|
||||
|
||||
case 'bonding':
|
||||
return _('Aggregation device');
|
||||
|
||||
case 'bridge':
|
||||
return _('Bridge device');
|
||||
|
||||
|
@ -1570,20 +1573,24 @@ return view.extend({
|
|||
s.addremove = false;
|
||||
s.anonymous = true;
|
||||
|
||||
o = s.option(form.Value, 'ula_prefix', _('IPv6 ULA-Prefix'), _('Unique Local Address - in the range <code>fc00::/7</code>. Typically only within the ‘local’ half <code>fd00::/8</code>. ULA for IPv6 is analogous to IPv4 private network addressing. This prefix is randomly generated at first install.'));
|
||||
o = s.option(form.Value, 'ula_prefix', _('IPv6 ULA-Prefix'),
|
||||
_('Unique Local Address (%s) - prefix <code>fd00::/8</code> (the L bit is always 1).').format('<a href="%s" target="_blank">RFC4193</a>').format('https://datatracker.ietf.org/doc/html/rfc4193#section-3') + ' ' +
|
||||
_('ULA for IPv6 is analogous to IPv4 private network addressing.') + ' ' +
|
||||
_('This prefix is randomly generated at first install.'));
|
||||
o.datatype = 'cidr6';
|
||||
|
||||
o = s.option(form.ListValue, 'packet_steering', _('Packet Steering'), _('Enable packet steering across CPUs. May help or hinder network speed.'));
|
||||
o.value('', _('Disabled'));
|
||||
o.value('0', _('Disabled'));
|
||||
o.value('1',_('Enabled'));
|
||||
o.value('2',_('Enabled (all CPUs)'));
|
||||
o.default = '1';
|
||||
o.optional = true;
|
||||
|
||||
var steer_flow = uci.get('network', 'globals', 'steering_flows');
|
||||
var steer_flow = uci.get('network', 'globals', 'steering_flows');
|
||||
|
||||
o = s.option(form.Value, 'steering_flows', _('Steering flows (<abbr title="Receive Packet Steering">RPS</abbr>)'),
|
||||
_('Directs packet flows to specific CPUs where the local socket owner listens (the local service).') + ' ' +
|
||||
_('Note: this setting is for local services on the device only (not for forwarding).'));
|
||||
_('Directs packet flows to specific CPUs where the local socket owner listens (the local service).') + ' ' +
|
||||
_('Note: this setting is for local services on the device only (not for forwarding).'));
|
||||
o.value('', _('Standard: none'));
|
||||
o.value('128', _('Suggested: 128'));
|
||||
o.value('256', _('256'));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue