mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-07 01:53:34 +08:00
get wan interface prefer from gsw ports (#349)
in some router, eth0 and eth1 both from cpu, the wan speed is 2.5G. that's not correct. so get wan interface prefer from gsw ports to get the right speed.
This commit is contained in:
parent
b5d6e1fe4e
commit
02fff2aebc
@ -67,6 +67,24 @@ function getPortIcon(carrier) {
|
|||||||
return L.resource(`icons/port_${carrier ? 'up' : 'down'}.png`);
|
return L.resource(`icons/port_${carrier ? 'up' : 'down'}.png`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function portDom(link, duplex, label, speed, tx_bytes, rx_bytes) {
|
||||||
|
const portIcon = getPortIcon(link);
|
||||||
|
const portColor = getPortColor(link, duplex);
|
||||||
|
|
||||||
|
return E('div', { style: ethStyle.box }, [
|
||||||
|
E('div', { style: ethStyle.head + portColor }, label),
|
||||||
|
E('div', { style: ethStyle.body }, [
|
||||||
|
E('img', { style: ethStyle.icon, src: portIcon }),
|
||||||
|
E('div', { style: ethStyle.speed }, formatSpeed(speed)),
|
||||||
|
E('div', { style: ethStyle.traffic }, [
|
||||||
|
'\u25b2\u202f%1024.1mB'.format(tx_bytes),
|
||||||
|
E('br'),
|
||||||
|
'\u25bc\u202f%1024.1mB'.format(rx_bytes)
|
||||||
|
])
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
return baseclass.extend({
|
return baseclass.extend({
|
||||||
title: _('Ethernet Information'),
|
title: _('Ethernet Information'),
|
||||||
|
|
||||||
@ -96,53 +114,37 @@ return baseclass.extend({
|
|||||||
const board = data[1];
|
const board = data[1];
|
||||||
const netdevs = data[2];
|
const netdevs = data[2];
|
||||||
|
|
||||||
|
let stats;
|
||||||
|
let foundWAN = false;
|
||||||
const ethPorts = [];
|
const ethPorts = [];
|
||||||
const wan = netdevs[board.network.wan.device];
|
|
||||||
const { speed, duplex, carrier } = wan.link;
|
|
||||||
let portIcon = getPortIcon(carrier);
|
|
||||||
let portColor = getPortColor(carrier, duplex);
|
|
||||||
ethPorts.push(
|
|
||||||
E('div', { style: ethStyle.box }, [
|
|
||||||
E('div', { style: ethStyle.head + portColor }, 'WAN'),
|
|
||||||
E('div', { style: ethStyle.body }, [
|
|
||||||
E('img', { style: ethStyle.icon, src: portIcon }),
|
|
||||||
E('div', { style: ethStyle.speed }, formatSpeed(speed)),
|
|
||||||
E('div', { style: ethStyle.traffic }, [
|
|
||||||
'\u25b2\u202f%1024.1mB'.format(wan.stats.tx_bytes),
|
|
||||||
E('br'),
|
|
||||||
'\u25bc\u202f%1024.1mB'.format(wan.stats.rx_bytes)
|
|
||||||
])
|
|
||||||
])
|
|
||||||
])
|
|
||||||
);
|
|
||||||
|
|
||||||
const switch0 = topologies.switch0;
|
const switch0 = topologies.switch0;
|
||||||
for (const port of switch0.ports) {
|
for (const port of switch0.ports) {
|
||||||
const label = port.label.toUpperCase();
|
const label = port.label.toUpperCase();
|
||||||
if (!label.startsWith('LAN')) continue;
|
|
||||||
const { link, duplex, speed } = switch0.portstate[port.num];
|
const { link, duplex, speed } = switch0.portstate[port.num];
|
||||||
|
|
||||||
portIcon = getPortIcon(link);
|
|
||||||
portColor = getPortColor(link, duplex);
|
|
||||||
const txrx = { tx_bytes: 0, rx_bytes: 0 };
|
const txrx = { tx_bytes: 0, rx_bytes: 0 };
|
||||||
const stats = netdevs['br-lan'].stats;
|
|
||||||
const { tx_bytes, rx_bytes } = link ? stats : txrx;
|
if (label.startsWith('WAN')) {
|
||||||
ethPorts.push(
|
foundWAN = true;
|
||||||
E('div', { style: ethStyle.box }, [
|
stats = netdevs[board.network.wan.device].stats;
|
||||||
E('div', { style: ethStyle.head + portColor }, port.label),
|
const { tx_bytes, rx_bytes } = stats;
|
||||||
E('div', { style: ethStyle.body }, [
|
ethPorts.unshift(
|
||||||
E('img', { style: ethStyle.icon, src: portIcon }),
|
portDom(link, duplex, 'WAN', speed, tx_bytes, rx_bytes)
|
||||||
E('div', { style: ethStyle.speed }, formatSpeed(speed)),
|
);
|
||||||
E('div', { style: ethStyle.traffic }, [
|
} else if (label.startsWith('LAN')) {
|
||||||
'\u25b2\u202f%1024.1mB'.format(tx_bytes),
|
stats = netdevs['br-lan'].stats;
|
||||||
E('br'),
|
const { tx_bytes, rx_bytes } = link ? stats : txrx;
|
||||||
'\u25bc\u202f%1024.1mB'.format(rx_bytes)
|
ethPorts.push(portDom(link, duplex, label, speed, tx_bytes, rx_bytes));
|
||||||
])
|
}
|
||||||
])
|
|
||||||
])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (foundWAN) return ethPorts;
|
||||||
|
|
||||||
|
const wan = netdevs[board.network.wan.device];
|
||||||
|
const { speed, duplex, carrier } = wan.link;
|
||||||
|
const { tx_bytes, rx_bytes } = wan.stats;
|
||||||
|
ethPorts.unshift(
|
||||||
|
portDom(carrier, duplex, 'WAN', speed, tx_bytes, rx_bytes)
|
||||||
|
);
|
||||||
return ethPorts;
|
return ethPorts;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -157,23 +159,10 @@ return baseclass.extend({
|
|||||||
for (const device of devices) {
|
for (const device of devices) {
|
||||||
if (device in netdevs === false) continue;
|
if (device in netdevs === false) continue;
|
||||||
const dev = netdevs[device];
|
const dev = netdevs[device];
|
||||||
|
const label = dev.name;
|
||||||
const { speed, duplex, carrier } = dev.link;
|
const { speed, duplex, carrier } = dev.link;
|
||||||
let portIcon = getPortIcon(carrier);
|
const { tx_bytes, rx_bytes } = dev.stats;
|
||||||
let portColor = getPortColor(carrier, duplex);
|
ethPorts.push(portDom(carrier, duplex, label, speed, tx_bytes, rx_bytes));
|
||||||
ethPorts.push(
|
|
||||||
E('div', { style: ethStyle.box }, [
|
|
||||||
E('div', { style: ethStyle.head + portColor }, dev.name),
|
|
||||||
E('div', { style: ethStyle.body }, [
|
|
||||||
E('img', { style: ethStyle.icon, src: portIcon }),
|
|
||||||
E('div', { style: ethStyle.speed }, formatSpeed(speed)),
|
|
||||||
E('div', { style: ethStyle.traffic }, [
|
|
||||||
'\u25b2\u202f%1024.1mB'.format(dev.stats.tx_bytes),
|
|
||||||
E('br'),
|
|
||||||
'\u25bc\u202f%1024.1mB'.format(dev.stats.rx_bytes)
|
|
||||||
])
|
|
||||||
])
|
|
||||||
])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ethPorts;
|
return ethPorts;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user