mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
new & opt
new: `net` total in & out bytes opt: i18n for `ssh` opt: disk path ignore
This commit is contained in:
@@ -36,6 +36,13 @@ class NetSpeed {
|
||||
return buildStandardOutput(speedInBytesPerSecond);
|
||||
}
|
||||
|
||||
String totalIn({String? device}) {
|
||||
if (_old[0].device == '' || _now[0].device == '') return '0kb';
|
||||
final idx = deviceIdx(device);
|
||||
final totalInBytes = _now[idx].bytesIn;
|
||||
return totalInBytes.toInt().convertBytes;
|
||||
}
|
||||
|
||||
String speedOut({String? device}) {
|
||||
if (_old[0].device == '' || _now[0].device == '') return '0kb/s';
|
||||
final idx = deviceIdx(device);
|
||||
@@ -44,6 +51,13 @@ class NetSpeed {
|
||||
return buildStandardOutput(speedOutBytesPerSecond);
|
||||
}
|
||||
|
||||
String totalOut({String? device}) {
|
||||
if (_old[0].device == '' || _now[0].device == '') return '0kb';
|
||||
final idx = deviceIdx(device);
|
||||
final totalOutBytes = _now[idx].bytesOut;
|
||||
return totalOutBytes.toInt().convertBytes;
|
||||
}
|
||||
|
||||
int deviceIdx(String? device) {
|
||||
if (device != null) {
|
||||
for (var item in _now) {
|
||||
@@ -55,10 +69,15 @@ class NetSpeed {
|
||||
return 0;
|
||||
}
|
||||
|
||||
String buildStandardOutput(double speed) =>
|
||||
'${speed.convertBytes.toLowerCase()}/s';
|
||||
String buildStandardOutput(double speed) => '${speed.convertBytes}/s';
|
||||
}
|
||||
|
||||
/// [raw] example:
|
||||
/// Inter-| Receive | Transmit
|
||||
/// face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
|
||||
/// lo: 45929941 269112 0 0 0 0 0 0 45929941 269112 0 0 0 0 0 0
|
||||
/// eth0: 48481023 505772 0 0 0 0 0 0 36002262 202307 0 0 0 0 0 0
|
||||
/// 1635752901
|
||||
List<NetSpeedPart> parseNetSpeed(String raw) {
|
||||
final split = raw.split('\n');
|
||||
if (split.length < 4) {
|
||||
|
||||
Reference in New Issue
Block a user