veilid-cli cleanup
This commit is contained in:
@@ -3,7 +3,6 @@ import 'dart:typed_data';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
import 'package:veilid/veilid.dart';
|
||||
import 'package:flutter_loggy/flutter_loggy.dart';
|
||||
@@ -188,7 +187,7 @@ class _MyAppState extends State<MyApp> with UiLoggy {
|
||||
if (update is VeilidUpdateLog) {
|
||||
await processUpdateLog(update);
|
||||
} else {
|
||||
loggy.trace("Update: " + update.json.toString());
|
||||
loggy.trace("Update: ${update.json}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ packages:
|
||||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.8.2"
|
||||
version: "2.9.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -28,21 +28,14 @@ packages:
|
||||
name: characters
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
version: "1.2.1"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: clock
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.1.1"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -63,21 +56,21 @@ packages:
|
||||
name: fake_async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
version: "1.3.1"
|
||||
ffi:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ffi
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "2.0.1"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.1.2"
|
||||
version: "6.1.4"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@@ -134,30 +127,30 @@ packages:
|
||||
name: matcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.11"
|
||||
version: "0.12.12"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.4"
|
||||
version: "0.1.5"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
version: "1.8.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.1"
|
||||
version: "1.8.2"
|
||||
path_provider:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: path_provider
|
||||
url: "https://pub.dartlang.org"
|
||||
@@ -169,14 +162,14 @@ packages:
|
||||
name: path_provider_android
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.14"
|
||||
version: "2.0.20"
|
||||
path_provider_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_ios
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.10"
|
||||
version: "2.0.11"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -204,7 +197,7 @@ packages:
|
||||
name: path_provider_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.1.3"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -232,7 +225,7 @@ packages:
|
||||
name: rxdart
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.27.4"
|
||||
version: "0.27.5"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@@ -244,7 +237,7 @@ packages:
|
||||
name: source_span
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.2"
|
||||
version: "1.9.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -265,21 +258,21 @@ packages:
|
||||
name: string_scanner
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.1.1"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
version: "1.2.1"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.9"
|
||||
version: "0.4.12"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -300,14 +293,14 @@ packages:
|
||||
name: win32
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.7.0"
|
||||
version: "3.0.0"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xdg_directories
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.0+1"
|
||||
version: "0.2.0+2"
|
||||
sdks:
|
||||
dart: ">=2.17.0 <3.0.0"
|
||||
flutter: ">=3.0.0"
|
||||
|
@@ -34,6 +34,8 @@ dependencies:
|
||||
cupertino_icons: ^1.0.2
|
||||
loggy: ^2.0.1+1
|
||||
flutter_loggy: ^2.0.1
|
||||
path_provider: ^2.0.11
|
||||
path: ^1.8.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
@@ -987,6 +987,243 @@ class VeilidConfig {
|
||||
network = VeilidConfigNetwork.fromJson(json['network']);
|
||||
}
|
||||
|
||||
////////////
|
||||
|
||||
class LatencyStats {
|
||||
BigInt fastest;
|
||||
BigInt average;
|
||||
BigInt slowest;
|
||||
|
||||
LatencyStats({
|
||||
required this.fastest,
|
||||
required this.average,
|
||||
required this.slowest,
|
||||
});
|
||||
|
||||
Map<String, dynamic> get json {
|
||||
return {
|
||||
'fastest': fastest.toString(),
|
||||
'average': average.toString(),
|
||||
'slowest': slowest.toString(),
|
||||
};
|
||||
}
|
||||
|
||||
LatencyStats.fromJson(Map<String, dynamic> json)
|
||||
: fastest = BigInt.parse(json['fastest']),
|
||||
average = BigInt.parse(json['average']),
|
||||
slowest = BigInt.parse(json['slowest']);
|
||||
}
|
||||
|
||||
////////////
|
||||
|
||||
class TransferStats {
|
||||
BigInt total;
|
||||
BigInt fastest;
|
||||
BigInt average;
|
||||
BigInt slowest;
|
||||
|
||||
TransferStats({
|
||||
required this.total,
|
||||
required this.fastest,
|
||||
required this.average,
|
||||
required this.slowest,
|
||||
});
|
||||
|
||||
Map<String, dynamic> get json {
|
||||
return {
|
||||
'total': total.toString(),
|
||||
'fastest': fastest.toString(),
|
||||
'average': average.toString(),
|
||||
'slowest': slowest.toString(),
|
||||
};
|
||||
}
|
||||
|
||||
TransferStats.fromJson(Map<String, dynamic> json)
|
||||
: total = BigInt.parse(json['fastest']),
|
||||
fastest = BigInt.parse(json['fastest']),
|
||||
average = BigInt.parse(json['average']),
|
||||
slowest = BigInt.parse(json['slowest']);
|
||||
}
|
||||
|
||||
////////////
|
||||
|
||||
class TransferStatsDownUp {
|
||||
TransferStats down;
|
||||
TransferStats up;
|
||||
|
||||
TransferStatsDownUp({
|
||||
required this.down,
|
||||
required this.up,
|
||||
});
|
||||
|
||||
Map<String, dynamic> get json {
|
||||
return {
|
||||
'down': down.toString(),
|
||||
'up': up.toString(),
|
||||
};
|
||||
}
|
||||
|
||||
TransferStatsDownUp.fromJson(Map<String, dynamic> json)
|
||||
: down = TransferStats.fromJson(json['down']),
|
||||
up = TransferStats.fromJson(json['up']);
|
||||
}
|
||||
|
||||
////////////
|
||||
|
||||
class RPCStats {
|
||||
int messagesSent;
|
||||
int messagesRcvd;
|
||||
int questionsInFlight;
|
||||
BigInt? lastQuestion;
|
||||
BigInt? lastSeenTs;
|
||||
BigInt? firstConsecutiveSeenTs;
|
||||
int recentLostAnswers;
|
||||
int failedToSend;
|
||||
|
||||
RPCStats({
|
||||
required this.messagesSent,
|
||||
required this.messagesRcvd,
|
||||
required this.questionsInFlight,
|
||||
required this.lastQuestion,
|
||||
required this.lastSeenTs,
|
||||
required this.firstConsecutiveSeenTs,
|
||||
required this.recentLostAnswers,
|
||||
required this.failedToSend,
|
||||
});
|
||||
|
||||
Map<String, dynamic> get json {
|
||||
return {
|
||||
'messages_sent': messagesSent,
|
||||
'messages_rcvd': messagesRcvd,
|
||||
'questions_in_flight': questionsInFlight,
|
||||
'last_question': lastQuestion?.toString(),
|
||||
'last_seen_ts': lastSeenTs?.toString(),
|
||||
'first_consecutive_seen_ts': firstConsecutiveSeenTs?.toString(),
|
||||
'recent_lost_answers': recentLostAnswers,
|
||||
'failed_to_send': failedToSend,
|
||||
};
|
||||
}
|
||||
|
||||
RPCStats.fromJson(Map<String, dynamic> json)
|
||||
: messagesSent = json['messages_sent'],
|
||||
messagesRcvd = json['messages_rcvd'],
|
||||
questionsInFlight = json['questions_in_flight'],
|
||||
lastQuestion = json['last_question'] != null
|
||||
? BigInt.parse(json['last_question'])
|
||||
: null,
|
||||
lastSeenTs = json['last_seen_ts'] != null
|
||||
? BigInt.parse(json['last_seen_ts'])
|
||||
: null,
|
||||
firstConsecutiveSeenTs = json['first_consecutive_seen_ts'] != null
|
||||
? BigInt.parse(json['first_consecutive_seen_ts'])
|
||||
: null,
|
||||
recentLostAnswers = json['recent_lost_answers'],
|
||||
failedToSend = json['failed_to_send'];
|
||||
}
|
||||
|
||||
////////////
|
||||
|
||||
class PeerStats {
|
||||
BigInt timeAdded;
|
||||
RPCStats rpcStats;
|
||||
LatencyStats? latency;
|
||||
TransferStatsDownUp transfer;
|
||||
|
||||
PeerStats({
|
||||
required this.timeAdded,
|
||||
required this.rpcStats,
|
||||
required this.latency,
|
||||
required this.transfer,
|
||||
});
|
||||
|
||||
Map<String, dynamic> get json {
|
||||
return {
|
||||
'time_added': timeAdded.toString(),
|
||||
'rpc_stats': rpcStats.json,
|
||||
'latency': latency?.json,
|
||||
'transfer': transfer.json,
|
||||
};
|
||||
}
|
||||
|
||||
PeerStats.fromJson(Map<String, dynamic> json)
|
||||
: timeAdded = BigInt.parse(json['time_added']),
|
||||
rpcStats = RPCStats.fromJson(json['rpc_stats']),
|
||||
latency = json['latency'] != null
|
||||
? LatencyStats.fromJson(json['latency'])
|
||||
: null,
|
||||
transfer = TransferStatsDownUp.fromJson(json['transfer']);
|
||||
}
|
||||
|
||||
////////////
|
||||
|
||||
class PeerTableData {
|
||||
String nodeId;
|
||||
PeerAddress peerAddress;
|
||||
PeerStats peerStats;
|
||||
|
||||
PeerTableData({
|
||||
required this.nodeId,
|
||||
required this.peerAddress,
|
||||
required this.peerStats,
|
||||
});
|
||||
|
||||
Map<String, dynamic> get json {
|
||||
return {
|
||||
'node_id': nodeId,
|
||||
'peer_address': peerAddress.json,
|
||||
'peer_stats': peerStats.json,
|
||||
};
|
||||
}
|
||||
|
||||
PeerTableData.fromJson(Map<String, dynamic> json)
|
||||
: nodeId = json['node_id'],
|
||||
peerAddress = PeerAddress.fromJson(json['peer_address']),
|
||||
peerStats = PeerStats.fromJson(json['peer_stats']);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
/// AttachmentState
|
||||
|
||||
enum ProtocolType {
|
||||
udp,
|
||||
tcp,
|
||||
ws,
|
||||
wss,
|
||||
}
|
||||
|
||||
extension ProtocolTypeExt on ProtocolType {
|
||||
String get json {
|
||||
return name.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
ProtocolType protocolTypeFromJson(String j) {
|
||||
return ProtocolType.values.byName(j.toLowerCase());
|
||||
}
|
||||
|
||||
////////////
|
||||
|
||||
class PeerAddress {
|
||||
ProtocolType protocolType;
|
||||
String socketAddress;
|
||||
|
||||
PeerAddress({
|
||||
required this.protocolType,
|
||||
required this.socketAddress,
|
||||
});
|
||||
|
||||
Map<String, dynamic> get json {
|
||||
return {
|
||||
'protocol_type': protocolType.json,
|
||||
'socket_address': socketAddress,
|
||||
};
|
||||
}
|
||||
|
||||
PeerAddress.fromJson(Map<String, dynamic> json)
|
||||
: protocolType = protocolTypeFromJson(json['protocol_type']),
|
||||
socketAddress = json['socket_address'];
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
/// VeilidUpdate
|
||||
|
||||
@@ -996,16 +1233,17 @@ abstract class VeilidUpdate {
|
||||
case "Log":
|
||||
{
|
||||
return VeilidUpdateLog(
|
||||
veilidLogLevelFromJson(json["log_level"]), json["message"]);
|
||||
logLevel: veilidLogLevelFromJson(json["log_level"]),
|
||||
message: json["message"]);
|
||||
}
|
||||
case "Attachment":
|
||||
{
|
||||
return VeilidUpdateAttachment(attachmentStateFromJson(json["state"]));
|
||||
return VeilidUpdateAttachment(
|
||||
state: VeilidStateAttachment.fromJson(json));
|
||||
}
|
||||
case "Network":
|
||||
{
|
||||
return VeilidUpdateNetwork(
|
||||
json["started"], json["bps_up"], json["bps_down"]);
|
||||
return VeilidUpdateNetwork(state: VeilidStateNetwork.fromJson(json));
|
||||
}
|
||||
default:
|
||||
{
|
||||
@@ -1021,7 +1259,10 @@ class VeilidUpdateLog implements VeilidUpdate {
|
||||
final VeilidLogLevel logLevel;
|
||||
final String message;
|
||||
//
|
||||
VeilidUpdateLog(this.logLevel, this.message);
|
||||
VeilidUpdateLog({
|
||||
required this.logLevel,
|
||||
required this.message,
|
||||
});
|
||||
|
||||
@override
|
||||
Map<String, dynamic> get json {
|
||||
@@ -1034,34 +1275,28 @@ class VeilidUpdateLog implements VeilidUpdate {
|
||||
}
|
||||
|
||||
class VeilidUpdateAttachment implements VeilidUpdate {
|
||||
final AttachmentState state;
|
||||
final VeilidStateAttachment state;
|
||||
//
|
||||
VeilidUpdateAttachment(this.state);
|
||||
VeilidUpdateAttachment({required this.state});
|
||||
|
||||
@override
|
||||
Map<String, dynamic> get json {
|
||||
return {
|
||||
'kind': "Attachment",
|
||||
'state': state.json,
|
||||
};
|
||||
var jsonRep = state.json;
|
||||
jsonRep['kind'] = "Attachment";
|
||||
return jsonRep;
|
||||
}
|
||||
}
|
||||
|
||||
class VeilidUpdateNetwork implements VeilidUpdate {
|
||||
final bool started;
|
||||
final int bpsDown;
|
||||
final int bpsUp;
|
||||
final VeilidStateNetwork state;
|
||||
//
|
||||
VeilidUpdateNetwork(this.started, this.bpsDown, this.bpsUp);
|
||||
VeilidUpdateNetwork({required this.state});
|
||||
|
||||
@override
|
||||
Map<String, dynamic> get json {
|
||||
return {
|
||||
'kind': "Network",
|
||||
'started': started,
|
||||
'bps_down': bpsDown,
|
||||
'bps_up': bpsUp
|
||||
};
|
||||
var jsonRep = state.json;
|
||||
jsonRep['kind'] = "Network";
|
||||
return jsonRep;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1075,6 +1310,12 @@ class VeilidStateAttachment {
|
||||
|
||||
VeilidStateAttachment.fromJson(Map<String, dynamic> json)
|
||||
: state = attachmentStateFromJson(json['state']);
|
||||
|
||||
Map<String, dynamic> get json {
|
||||
return {
|
||||
'state': state.json,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
@@ -1082,11 +1323,30 @@ class VeilidStateAttachment {
|
||||
|
||||
class VeilidStateNetwork {
|
||||
final bool started;
|
||||
final int bpsDown;
|
||||
final int bpsUp;
|
||||
final List<PeerTableData> peers;
|
||||
|
||||
VeilidStateNetwork(this.started);
|
||||
VeilidStateNetwork(
|
||||
{required this.started,
|
||||
required this.bpsDown,
|
||||
required this.bpsUp,
|
||||
required this.peers});
|
||||
|
||||
VeilidStateNetwork.fromJson(Map<String, dynamic> json)
|
||||
: started = json['started'];
|
||||
: started = json['started'],
|
||||
bpsDown = json['bps_down'],
|
||||
bpsUp = json['bps_up'],
|
||||
peers = json['peers'].map((j) => PeerTableData.fromJson(j)).toList();
|
||||
|
||||
Map<String, dynamic> get json {
|
||||
return {
|
||||
'started': started,
|
||||
'bps_down': bpsDown,
|
||||
'bps_up': bpsUp,
|
||||
'peers': peers.map((p) => p.json).toList(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
@@ -1096,11 +1356,13 @@ class VeilidState {
|
||||
final VeilidStateAttachment attachment;
|
||||
final VeilidStateNetwork network;
|
||||
|
||||
VeilidState(this.attachment, this.network);
|
||||
|
||||
VeilidState.fromJson(Map<String, dynamic> json)
|
||||
: attachment = VeilidStateAttachment.fromJson(json['attachment']),
|
||||
network = VeilidStateNetwork.fromJson(json['network']);
|
||||
|
||||
Map<String, dynamic> get json {
|
||||
return {'attachment': attachment.json, 'network': network.json};
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
Reference in New Issue
Block a user