update 2025-04-27 16:25:21
This commit is contained in:
parent
26e04107cd
commit
0d92f6fe0a
|
@ -11,15 +11,6 @@
|
||||||
'require ui';
|
'require ui';
|
||||||
'require view';
|
'require view';
|
||||||
|
|
||||||
function formatBytes(bytes, decimals = 2) {
|
|
||||||
if (bytes === 0) return '0 Bytes';
|
|
||||||
const k = 1024;
|
|
||||||
const dm = decimals < 0 ? 0 : decimals;
|
|
||||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
||||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
||||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
return view.extend({
|
return view.extend({
|
||||||
load: function() {
|
load: function() {
|
||||||
return fs.exec('/sbin/ip', ['-s', '-j', 'ad']).then(function(res) {
|
return fs.exec('/sbin/ip', ['-s', '-j', 'ad']).then(function(res) {
|
||||||
|
@ -47,8 +38,8 @@ return view.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
parsedInfo.mtu = iface.mtu;
|
parsedInfo.mtu = iface.mtu;
|
||||||
parsedInfo.rxBytes = formatBytes(iface.stats64.rx.bytes);
|
parsedInfo.rxBytes = '%1024mB'.format(iface.stats64.rx.bytes);
|
||||||
parsedInfo.txBytes = formatBytes(iface.stats64.tx.bytes);
|
parsedInfo.txBytes = '%1024mB'.format(iface.stats64.tx.bytes);
|
||||||
|
|
||||||
return parsedInfo;
|
return parsedInfo;
|
||||||
});
|
});
|
||||||
|
|
|
@ -195,7 +195,7 @@ return view.extend({
|
||||||
|
|
||||||
o = s.taboption('advance', form.ListValue, 'exitNode', _('Online Exit Nodes'), _('Select an online machine name to use as an exit node.'));
|
o = s.taboption('advance', form.ListValue, 'exitNode', _('Online Exit Nodes'), _('Select an online machine name to use as an exit node.'));
|
||||||
if (onlineExitNodes.length > 0) {
|
if (onlineExitNodes.length > 0) {
|
||||||
o.optional = false;
|
o.optional = true;
|
||||||
onlineExitNodes.forEach(function(node) {
|
onlineExitNodes.forEach(function(node) {
|
||||||
o.value(node, node);
|
o.value(node, node);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue