2022-01-16 16:19:01 +00:00
|
|
|
import 'dart:async';
|
2022-10-01 02:37:55 +00:00
|
|
|
import 'dart:typed_data';
|
|
|
|
import 'dart:convert';
|
2022-01-29 18:23:10 +00:00
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
import 'package:change_case/change_case.dart';
|
2022-02-07 02:18:42 +00:00
|
|
|
|
|
|
|
import 'veilid_stub.dart'
|
2022-02-09 14:47:36 +00:00
|
|
|
if (dart.library.io) 'veilid_ffi.dart'
|
|
|
|
if (dart.library.js) 'veilid_js.dart';
|
2022-02-07 02:18:42 +00:00
|
|
|
|
2023-01-04 22:02:45 +00:00
|
|
|
import 'base64url_no_pad.dart';
|
|
|
|
|
2022-02-07 02:18:42 +00:00
|
|
|
//////////////////////////////////////////////////////////
|
|
|
|
|
2022-12-26 02:28:45 +00:00
|
|
|
export 'default_config.dart';
|
|
|
|
|
2022-06-16 01:51:38 +00:00
|
|
|
//////////////////////////////////////////////////////////
|
|
|
|
// FFI Platform-specific config
|
|
|
|
|
|
|
|
class VeilidFFIConfigLoggingTerminal {
|
|
|
|
bool enabled;
|
2022-07-01 16:13:52 +00:00
|
|
|
VeilidConfigLogLevel level;
|
2022-06-16 01:51:38 +00:00
|
|
|
|
|
|
|
VeilidFFIConfigLoggingTerminal({
|
|
|
|
required this.enabled,
|
|
|
|
required this.level,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'enabled': enabled,
|
|
|
|
'level': level.json,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidFFIConfigLoggingTerminal.fromJson(dynamic json)
|
2022-06-16 01:51:38 +00:00
|
|
|
: enabled = json['enabled'],
|
2022-07-01 16:13:52 +00:00
|
|
|
level = veilidConfigLogLevelFromJson(json['level']);
|
2022-06-16 01:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class VeilidFFIConfigLoggingOtlp {
|
|
|
|
bool enabled;
|
2022-07-01 16:13:52 +00:00
|
|
|
VeilidConfigLogLevel level;
|
2022-06-16 01:51:38 +00:00
|
|
|
String grpcEndpoint;
|
|
|
|
String serviceName;
|
|
|
|
|
|
|
|
VeilidFFIConfigLoggingOtlp({
|
|
|
|
required this.enabled,
|
|
|
|
required this.level,
|
|
|
|
required this.grpcEndpoint,
|
|
|
|
required this.serviceName,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'enabled': enabled,
|
|
|
|
'level': level.json,
|
|
|
|
'grpc_endpoint': grpcEndpoint,
|
|
|
|
'service_name': serviceName,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidFFIConfigLoggingOtlp.fromJson(dynamic json)
|
2022-06-16 01:51:38 +00:00
|
|
|
: enabled = json['enabled'],
|
2022-07-01 16:13:52 +00:00
|
|
|
level = veilidConfigLogLevelFromJson(json['level']),
|
2022-06-16 01:51:38 +00:00
|
|
|
grpcEndpoint = json['grpc_endpoint'],
|
|
|
|
serviceName = json['service_name'];
|
|
|
|
}
|
|
|
|
|
2022-07-01 16:13:52 +00:00
|
|
|
class VeilidFFIConfigLoggingApi {
|
|
|
|
bool enabled;
|
|
|
|
VeilidConfigLogLevel level;
|
|
|
|
|
|
|
|
VeilidFFIConfigLoggingApi({
|
|
|
|
required this.enabled,
|
|
|
|
required this.level,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'enabled': enabled,
|
|
|
|
'level': level.json,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidFFIConfigLoggingApi.fromJson(dynamic json)
|
2022-07-01 16:13:52 +00:00
|
|
|
: enabled = json['enabled'],
|
|
|
|
level = veilidConfigLogLevelFromJson(json['level']);
|
|
|
|
}
|
|
|
|
|
2022-06-16 01:51:38 +00:00
|
|
|
class VeilidFFIConfigLogging {
|
|
|
|
VeilidFFIConfigLoggingTerminal terminal;
|
|
|
|
VeilidFFIConfigLoggingOtlp otlp;
|
2022-07-01 16:13:52 +00:00
|
|
|
VeilidFFIConfigLoggingApi api;
|
2022-06-16 01:51:38 +00:00
|
|
|
|
2022-07-01 16:13:52 +00:00
|
|
|
VeilidFFIConfigLogging(
|
|
|
|
{required this.terminal, required this.otlp, required this.api});
|
2022-06-16 01:51:38 +00:00
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'terminal': terminal.json,
|
|
|
|
'otlp': otlp.json,
|
2022-07-01 16:13:52 +00:00
|
|
|
'api': api.json,
|
2022-06-16 01:51:38 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidFFIConfigLogging.fromJson(dynamic json)
|
2022-06-16 01:51:38 +00:00
|
|
|
: terminal = VeilidFFIConfigLoggingTerminal.fromJson(json['terminal']),
|
2022-07-01 16:13:52 +00:00
|
|
|
otlp = VeilidFFIConfigLoggingOtlp.fromJson(json['otlp']),
|
|
|
|
api = VeilidFFIConfigLoggingApi.fromJson(json['api']);
|
2022-06-16 01:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class VeilidFFIConfig {
|
|
|
|
VeilidFFIConfigLogging logging;
|
|
|
|
|
|
|
|
VeilidFFIConfig({
|
|
|
|
required this.logging,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'logging': logging.json,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
VeilidFFIConfig.fromJson(Map<String, dynamic> json)
|
|
|
|
: logging = VeilidFFIConfigLogging.fromJson(json['logging']);
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////
|
|
|
|
// WASM Platform-specific config
|
|
|
|
|
|
|
|
class VeilidWASMConfigLoggingPerformance {
|
|
|
|
bool enabled;
|
2022-07-01 16:13:52 +00:00
|
|
|
VeilidConfigLogLevel level;
|
2022-06-16 01:51:38 +00:00
|
|
|
bool logsInTimings;
|
|
|
|
bool logsInConsole;
|
|
|
|
|
|
|
|
VeilidWASMConfigLoggingPerformance({
|
|
|
|
required this.enabled,
|
|
|
|
required this.level,
|
|
|
|
required this.logsInTimings,
|
|
|
|
required this.logsInConsole,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'enabled': enabled,
|
|
|
|
'level': level.json,
|
|
|
|
'logs_in_timings': logsInTimings,
|
|
|
|
'logs_in_console': logsInConsole,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidWASMConfigLoggingPerformance.fromJson(dynamic json)
|
2022-06-16 01:51:38 +00:00
|
|
|
: enabled = json['enabled'],
|
2022-07-01 16:13:52 +00:00
|
|
|
level = veilidConfigLogLevelFromJson(json['level']),
|
2022-06-16 01:51:38 +00:00
|
|
|
logsInTimings = json['logs_in_timings'],
|
|
|
|
logsInConsole = json['logs_in_console'];
|
|
|
|
}
|
|
|
|
|
2022-07-01 16:13:52 +00:00
|
|
|
class VeilidWASMConfigLoggingApi {
|
|
|
|
bool enabled;
|
|
|
|
VeilidConfigLogLevel level;
|
|
|
|
|
|
|
|
VeilidWASMConfigLoggingApi({
|
|
|
|
required this.enabled,
|
|
|
|
required this.level,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'enabled': enabled,
|
|
|
|
'level': level.json,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidWASMConfigLoggingApi.fromJson(dynamic json)
|
2022-07-01 16:13:52 +00:00
|
|
|
: enabled = json['enabled'],
|
|
|
|
level = veilidConfigLogLevelFromJson(json['level']);
|
|
|
|
}
|
|
|
|
|
2022-06-16 01:51:38 +00:00
|
|
|
class VeilidWASMConfigLogging {
|
|
|
|
VeilidWASMConfigLoggingPerformance performance;
|
2022-07-01 16:13:52 +00:00
|
|
|
VeilidWASMConfigLoggingApi api;
|
2022-06-16 01:51:38 +00:00
|
|
|
|
2022-07-01 16:13:52 +00:00
|
|
|
VeilidWASMConfigLogging({required this.performance, required this.api});
|
2022-06-16 01:51:38 +00:00
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'performance': performance.json,
|
2022-07-01 16:13:52 +00:00
|
|
|
'api': api.json,
|
2022-06-16 01:51:38 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidWASMConfigLogging.fromJson(dynamic json)
|
2022-06-16 01:51:38 +00:00
|
|
|
: performance =
|
2022-07-01 16:13:52 +00:00
|
|
|
VeilidWASMConfigLoggingPerformance.fromJson(json['performance']),
|
|
|
|
api = VeilidWASMConfigLoggingApi.fromJson(json['api']);
|
2022-06-16 01:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class VeilidWASMConfig {
|
|
|
|
VeilidWASMConfigLogging logging;
|
|
|
|
|
|
|
|
VeilidWASMConfig({
|
|
|
|
required this.logging,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'logging': logging.json,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidWASMConfig.fromJson(dynamic json)
|
2022-06-16 01:51:38 +00:00
|
|
|
: logging = VeilidWASMConfigLogging.fromJson(json['logging']);
|
|
|
|
}
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
//////////////////////////////////////
|
|
|
|
/// JSON Encode Helper
|
2022-06-16 01:51:38 +00:00
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
Object? veilidApiToEncodable(Object? value) {
|
|
|
|
if (value == null) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
switch (value.runtimeType) {
|
|
|
|
case AttachmentState:
|
|
|
|
return (value as AttachmentState).json;
|
|
|
|
case VeilidLogLevel:
|
|
|
|
return (value as VeilidLogLevel).json;
|
2022-02-10 02:40:01 +00:00
|
|
|
case VeilidConfigLogLevel:
|
|
|
|
return (value as VeilidConfigLogLevel).json;
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
|
|
|
throw UnsupportedError('Cannot convert to JSON: $value');
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////
|
|
|
|
/// AttachmentState
|
|
|
|
|
2022-02-07 02:18:42 +00:00
|
|
|
enum AttachmentState {
|
2022-02-09 14:47:36 +00:00
|
|
|
detached,
|
|
|
|
attaching,
|
|
|
|
attachedWeak,
|
|
|
|
attachedGood,
|
|
|
|
attachedStrong,
|
|
|
|
fullyAttached,
|
|
|
|
overAttached,
|
|
|
|
detaching,
|
2022-02-07 02:18:42 +00:00
|
|
|
}
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
extension AttachmentStateExt on AttachmentState {
|
|
|
|
String get json {
|
|
|
|
return name.toPascalCase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AttachmentState attachmentStateFromJson(String j) {
|
|
|
|
return AttachmentState.values.byName(j.toCamelCase());
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////
|
|
|
|
/// VeilidLogLevel
|
|
|
|
|
2022-02-07 02:18:42 +00:00
|
|
|
enum VeilidLogLevel {
|
2022-02-09 14:47:36 +00:00
|
|
|
error,
|
|
|
|
warn,
|
|
|
|
info,
|
|
|
|
debug,
|
|
|
|
trace,
|
2022-02-07 02:18:42 +00:00
|
|
|
}
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
extension VeilidLogLevelExt on VeilidLogLevel {
|
|
|
|
String get json {
|
|
|
|
return name.toPascalCase();
|
|
|
|
}
|
|
|
|
}
|
2022-02-07 02:18:42 +00:00
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
VeilidLogLevel veilidLogLevelFromJson(String j) {
|
|
|
|
return VeilidLogLevel.values.byName(j.toCamelCase());
|
|
|
|
}
|
|
|
|
|
2022-02-10 02:40:01 +00:00
|
|
|
//////////////////////////////////////
|
|
|
|
/// VeilidConfigLogLevel
|
|
|
|
|
|
|
|
enum VeilidConfigLogLevel {
|
|
|
|
off,
|
|
|
|
error,
|
|
|
|
warn,
|
|
|
|
info,
|
|
|
|
debug,
|
|
|
|
trace,
|
|
|
|
}
|
|
|
|
|
|
|
|
extension VeilidConfigLogLevelExt on VeilidConfigLogLevel {
|
|
|
|
String get json {
|
|
|
|
return name.toPascalCase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VeilidConfigLogLevel veilidConfigLogLevelFromJson(String j) {
|
|
|
|
return VeilidConfigLogLevel.values.byName(j.toCamelCase());
|
|
|
|
}
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
//////////////////////////////////////
|
|
|
|
/// VeilidConfig
|
|
|
|
|
2022-02-10 02:40:01 +00:00
|
|
|
class VeilidConfigHTTPS {
|
|
|
|
bool enabled;
|
|
|
|
String listenAddress;
|
|
|
|
String path;
|
|
|
|
String? url;
|
|
|
|
|
|
|
|
VeilidConfigHTTPS({
|
|
|
|
required this.enabled,
|
|
|
|
required this.listenAddress,
|
|
|
|
required this.path,
|
|
|
|
this.url,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'enabled': enabled,
|
|
|
|
'listen_address': listenAddress,
|
|
|
|
'path': path,
|
|
|
|
'url': url
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigHTTPS.fromJson(dynamic json)
|
2022-02-10 02:40:01 +00:00
|
|
|
: enabled = json['enabled'],
|
|
|
|
listenAddress = json['listen_address'],
|
|
|
|
path = json['path'],
|
|
|
|
url = json['url'];
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
class VeilidConfigHTTP {
|
|
|
|
bool enabled;
|
|
|
|
String listenAddress;
|
|
|
|
String path;
|
|
|
|
String? url;
|
|
|
|
|
|
|
|
VeilidConfigHTTP({
|
|
|
|
required this.enabled,
|
|
|
|
required this.listenAddress,
|
|
|
|
required this.path,
|
|
|
|
this.url,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'enabled': enabled,
|
|
|
|
'listen_address': listenAddress,
|
|
|
|
'path': path,
|
|
|
|
'url': url
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigHTTP.fromJson(dynamic json)
|
2022-02-10 02:40:01 +00:00
|
|
|
: enabled = json['enabled'],
|
|
|
|
listenAddress = json['listen_address'],
|
|
|
|
path = json['path'],
|
|
|
|
url = json['url'];
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
class VeilidConfigApplication {
|
|
|
|
VeilidConfigHTTPS https;
|
|
|
|
VeilidConfigHTTP http;
|
|
|
|
|
|
|
|
VeilidConfigApplication({
|
|
|
|
required this.https,
|
|
|
|
required this.http,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'https': https.json,
|
|
|
|
'http': http.json,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigApplication.fromJson(dynamic json)
|
2022-02-10 02:40:01 +00:00
|
|
|
: https = VeilidConfigHTTPS.fromJson(json['https']),
|
|
|
|
http = VeilidConfigHTTP.fromJson(json['http']);
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
class VeilidConfigUDP {
|
|
|
|
bool enabled;
|
|
|
|
int socketPoolSize;
|
|
|
|
String listenAddress;
|
|
|
|
String? publicAddress;
|
|
|
|
|
|
|
|
VeilidConfigUDP(
|
|
|
|
{required this.enabled,
|
|
|
|
required this.socketPoolSize,
|
|
|
|
required this.listenAddress,
|
|
|
|
this.publicAddress});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'enabled': enabled,
|
|
|
|
'socket_pool_size': socketPoolSize,
|
|
|
|
'listen_address': listenAddress,
|
|
|
|
'public_address': publicAddress,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigUDP.fromJson(dynamic json)
|
2022-02-10 02:40:01 +00:00
|
|
|
: enabled = json['enabled'],
|
|
|
|
socketPoolSize = json['socket_pool_size'],
|
|
|
|
listenAddress = json['listen_address'],
|
|
|
|
publicAddress = json['publicAddress'];
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
class VeilidConfigTCP {
|
|
|
|
bool connect;
|
|
|
|
bool listen;
|
|
|
|
int maxConnections;
|
|
|
|
String listenAddress;
|
|
|
|
String? publicAddress;
|
|
|
|
|
|
|
|
VeilidConfigTCP(
|
|
|
|
{required this.connect,
|
|
|
|
required this.listen,
|
|
|
|
required this.maxConnections,
|
|
|
|
required this.listenAddress,
|
|
|
|
this.publicAddress});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'connect': connect,
|
|
|
|
'listen': listen,
|
|
|
|
'max_connections': maxConnections,
|
|
|
|
'listen_address': listenAddress,
|
|
|
|
'public_address': publicAddress,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigTCP.fromJson(dynamic json)
|
2022-02-10 02:40:01 +00:00
|
|
|
: connect = json['connect'],
|
|
|
|
listen = json['listen'],
|
|
|
|
maxConnections = json['max_connections'],
|
|
|
|
listenAddress = json['listen_address'],
|
|
|
|
publicAddress = json['publicAddress'];
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
class VeilidConfigWS {
|
|
|
|
bool connect;
|
|
|
|
bool listen;
|
|
|
|
int maxConnections;
|
|
|
|
String listenAddress;
|
|
|
|
String path;
|
|
|
|
String? url;
|
|
|
|
|
|
|
|
VeilidConfigWS(
|
|
|
|
{required this.connect,
|
|
|
|
required this.listen,
|
|
|
|
required this.maxConnections,
|
|
|
|
required this.listenAddress,
|
|
|
|
required this.path,
|
|
|
|
this.url});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'connect': connect,
|
|
|
|
'listen': listen,
|
|
|
|
'max_connections': maxConnections,
|
|
|
|
'listen_address': listenAddress,
|
|
|
|
'path': path,
|
|
|
|
'url': url,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigWS.fromJson(dynamic json)
|
2022-02-10 02:40:01 +00:00
|
|
|
: connect = json['connect'],
|
|
|
|
listen = json['listen'],
|
|
|
|
maxConnections = json['max_connections'],
|
|
|
|
listenAddress = json['listen_address'],
|
|
|
|
path = json['path'],
|
|
|
|
url = json['url'];
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
class VeilidConfigWSS {
|
|
|
|
bool connect;
|
|
|
|
bool listen;
|
|
|
|
int maxConnections;
|
|
|
|
String listenAddress;
|
|
|
|
String path;
|
|
|
|
String? url;
|
|
|
|
|
|
|
|
VeilidConfigWSS(
|
|
|
|
{required this.connect,
|
|
|
|
required this.listen,
|
|
|
|
required this.maxConnections,
|
|
|
|
required this.listenAddress,
|
|
|
|
required this.path,
|
|
|
|
this.url});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'connect': connect,
|
|
|
|
'listen': listen,
|
|
|
|
'max_connections': maxConnections,
|
|
|
|
'listen_address': listenAddress,
|
|
|
|
'path': path,
|
|
|
|
'url': url,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigWSS.fromJson(dynamic json)
|
2022-02-10 02:40:01 +00:00
|
|
|
: connect = json['connect'],
|
|
|
|
listen = json['listen'],
|
|
|
|
maxConnections = json['max_connections'],
|
|
|
|
listenAddress = json['listen_address'],
|
|
|
|
path = json['path'],
|
|
|
|
url = json['url'];
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
class VeilidConfigProtocol {
|
|
|
|
VeilidConfigUDP udp;
|
|
|
|
VeilidConfigTCP tcp;
|
|
|
|
VeilidConfigWS ws;
|
|
|
|
VeilidConfigWSS wss;
|
|
|
|
|
|
|
|
VeilidConfigProtocol({
|
|
|
|
required this.udp,
|
|
|
|
required this.tcp,
|
|
|
|
required this.ws,
|
|
|
|
required this.wss,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'udp': udp.json,
|
|
|
|
'tcp': tcp.json,
|
|
|
|
'ws': ws.json,
|
|
|
|
'wss': wss.json,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigProtocol.fromJson(dynamic json)
|
2022-02-10 02:40:01 +00:00
|
|
|
: udp = VeilidConfigUDP.fromJson(json['udp']),
|
|
|
|
tcp = VeilidConfigTCP.fromJson(json['tcp']),
|
|
|
|
ws = VeilidConfigWS.fromJson(json['ws']),
|
|
|
|
wss = VeilidConfigWSS.fromJson(json['wss']);
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
class VeilidConfigTLS {
|
|
|
|
String certificatePath;
|
|
|
|
String privateKeyPath;
|
|
|
|
int connectionInitialTimeoutMs;
|
|
|
|
|
|
|
|
VeilidConfigTLS({
|
|
|
|
required this.certificatePath,
|
|
|
|
required this.privateKeyPath,
|
|
|
|
required this.connectionInitialTimeoutMs,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'certificate_path': certificatePath,
|
|
|
|
'private_key_path': privateKeyPath,
|
|
|
|
'connection_initial_timeout_ms': connectionInitialTimeoutMs,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigTLS.fromJson(dynamic json)
|
2022-02-10 02:40:01 +00:00
|
|
|
: certificatePath = json['certificate_path'],
|
|
|
|
privateKeyPath = json['private_key_path'],
|
|
|
|
connectionInitialTimeoutMs = json['connection_initial_timeout_ms'];
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
class VeilidConfigDHT {
|
2023-04-16 17:16:00 +00:00
|
|
|
int resolveNodeTimeoutMs;
|
2022-02-10 02:40:01 +00:00
|
|
|
int resolveNodeCount;
|
|
|
|
int resolveNodeFanout;
|
|
|
|
int maxFindNodeCount;
|
2023-04-16 17:16:00 +00:00
|
|
|
int getValueTimeoutMs;
|
2022-02-10 02:40:01 +00:00
|
|
|
int getValueCount;
|
|
|
|
int getValueFanout;
|
2023-04-16 17:16:00 +00:00
|
|
|
int setValueTimeoutMs;
|
2022-02-10 02:40:01 +00:00
|
|
|
int setValueCount;
|
|
|
|
int setValueFanout;
|
|
|
|
int minPeerCount;
|
|
|
|
int minPeerRefreshTimeMs;
|
|
|
|
int validateDialInfoReceiptTimeMs;
|
2023-04-16 17:16:00 +00:00
|
|
|
int localSubkeyCacheSize;
|
|
|
|
int localMaxSubkeyCacheMemoryMb;
|
|
|
|
int remoteSubkeyCacheSize;
|
|
|
|
int remoteMaxRecords;
|
|
|
|
int remoteMaxSubkeyCacheMemoryMb;
|
|
|
|
int remoteMaxStorageSpaceMb;
|
2022-02-10 02:40:01 +00:00
|
|
|
|
|
|
|
VeilidConfigDHT(
|
2023-04-16 17:16:00 +00:00
|
|
|
{required this.resolveNodeTimeoutMs,
|
2022-02-10 02:40:01 +00:00
|
|
|
required this.resolveNodeCount,
|
|
|
|
required this.resolveNodeFanout,
|
|
|
|
required this.maxFindNodeCount,
|
2023-04-16 17:16:00 +00:00
|
|
|
required this.getValueTimeoutMs,
|
2022-02-10 02:40:01 +00:00
|
|
|
required this.getValueCount,
|
|
|
|
required this.getValueFanout,
|
2023-04-16 17:16:00 +00:00
|
|
|
required this.setValueTimeoutMs,
|
2022-02-10 02:40:01 +00:00
|
|
|
required this.setValueCount,
|
|
|
|
required this.setValueFanout,
|
|
|
|
required this.minPeerCount,
|
|
|
|
required this.minPeerRefreshTimeMs,
|
2023-04-16 17:16:00 +00:00
|
|
|
required this.validateDialInfoReceiptTimeMs,
|
|
|
|
required this.localSubkeyCacheSize,
|
|
|
|
required this.localMaxSubkeyCacheMemoryMb,
|
|
|
|
required this.remoteSubkeyCacheSize,
|
|
|
|
required this.remoteMaxRecords,
|
|
|
|
required this.remoteMaxSubkeyCacheMemoryMb,
|
|
|
|
required this.remoteMaxStorageSpaceMb});
|
2022-02-10 02:40:01 +00:00
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'resolve_node_timeout_ms': resolveNodeTimeoutMs,
|
|
|
|
'resolve_node_count': resolveNodeCount,
|
|
|
|
'resolve_node_fanout': resolveNodeFanout,
|
|
|
|
'max_find_node_count': maxFindNodeCount,
|
|
|
|
'get_value_timeout_ms': getValueTimeoutMs,
|
|
|
|
'get_value_count': getValueCount,
|
|
|
|
'get_value_fanout': getValueFanout,
|
|
|
|
'set_value_timeout_ms': setValueTimeoutMs,
|
|
|
|
'set_value_count': setValueCount,
|
|
|
|
'set_value_fanout': setValueFanout,
|
|
|
|
'min_peer_count': minPeerCount,
|
|
|
|
'min_peer_refresh_time_ms': minPeerRefreshTimeMs,
|
2023-04-16 17:16:00 +00:00
|
|
|
'validate_dial_info_receipt_time_ms': validateDialInfoReceiptTimeMs,
|
|
|
|
'local_subkey_cache_size: 128': localSubkeyCacheSize,
|
|
|
|
'local_max_subkey_cache_memory_mb': localMaxSubkeyCacheMemoryMb,
|
|
|
|
'remote_subkey_cache_size': remoteSubkeyCacheSize,
|
|
|
|
'remote_max_records': remoteMaxRecords,
|
|
|
|
'remote_max_subkey_cache_memory_mb': remoteMaxSubkeyCacheMemoryMb,
|
|
|
|
'remote_max_storage_space_mb': remoteMaxStorageSpaceMb,
|
2022-02-10 02:40:01 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigDHT.fromJson(dynamic json)
|
2022-02-10 02:40:01 +00:00
|
|
|
: resolveNodeTimeoutMs = json['resolve_node_timeout_ms'],
|
|
|
|
resolveNodeCount = json['resolve_node_count'],
|
|
|
|
resolveNodeFanout = json['resolve_node_fanout'],
|
|
|
|
maxFindNodeCount = json['max_find_node_count'],
|
|
|
|
getValueTimeoutMs = json['get_value_timeout_ms'],
|
|
|
|
getValueCount = json['get_value_count'],
|
|
|
|
getValueFanout = json['get_value_fanout'],
|
|
|
|
setValueTimeoutMs = json['set_value_timeout_ms'],
|
|
|
|
setValueCount = json['set_value_count'],
|
|
|
|
setValueFanout = json['set_value_fanout'],
|
|
|
|
minPeerCount = json['min_peer_count'],
|
|
|
|
minPeerRefreshTimeMs = json['min_peer_refresh_time_ms'],
|
|
|
|
validateDialInfoReceiptTimeMs =
|
2023-04-16 17:16:00 +00:00
|
|
|
json['validate_dial_info_receipt_time_ms'],
|
|
|
|
localSubkeyCacheSize = json['local_subkey_cache_size'],
|
|
|
|
localMaxSubkeyCacheMemoryMb = json['local_max_subkey_cache_memory_mb'],
|
|
|
|
remoteSubkeyCacheSize = json['remote_subkey_cache_size'],
|
|
|
|
remoteMaxRecords = json['remote_max_records'],
|
|
|
|
remoteMaxSubkeyCacheMemoryMb =
|
|
|
|
json['remote_max_subkey_cache_memory_mb'],
|
|
|
|
remoteMaxStorageSpaceMb = json['remote_max_storage_space_mb'];
|
2022-02-10 02:40:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
class VeilidConfigRPC {
|
|
|
|
int concurrency;
|
|
|
|
int queueSize;
|
|
|
|
int? maxTimestampBehindMs;
|
|
|
|
int? maxTimestampAheadMs;
|
|
|
|
int timeoutMs;
|
|
|
|
int maxRouteHopCount;
|
2022-10-14 02:05:43 +00:00
|
|
|
int defaultRouteHopCount;
|
2022-02-10 02:40:01 +00:00
|
|
|
|
|
|
|
VeilidConfigRPC(
|
|
|
|
{required this.concurrency,
|
|
|
|
required this.queueSize,
|
|
|
|
this.maxTimestampBehindMs,
|
|
|
|
this.maxTimestampAheadMs,
|
|
|
|
required this.timeoutMs,
|
2022-10-14 02:05:43 +00:00
|
|
|
required this.maxRouteHopCount,
|
|
|
|
required this.defaultRouteHopCount});
|
2022-02-10 02:40:01 +00:00
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'concurrency': concurrency,
|
|
|
|
'queue_size': queueSize,
|
|
|
|
'max_timestamp_behind_ms': maxTimestampBehindMs,
|
|
|
|
'max_timestamp_ahead_ms': maxTimestampAheadMs,
|
|
|
|
'timeout_ms': timeoutMs,
|
|
|
|
'max_route_hop_count': maxRouteHopCount,
|
2022-10-14 02:05:43 +00:00
|
|
|
'default_route_hop_count': defaultRouteHopCount,
|
2022-02-10 02:40:01 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigRPC.fromJson(dynamic json)
|
2022-02-10 02:40:01 +00:00
|
|
|
: concurrency = json['concurrency'],
|
|
|
|
queueSize = json['queue_size'],
|
|
|
|
maxTimestampBehindMs = json['max_timestamp_behind_ms'],
|
|
|
|
maxTimestampAheadMs = json['max_timestamp_ahead_ms'],
|
|
|
|
timeoutMs = json['timeout_ms'],
|
2022-10-14 02:05:43 +00:00
|
|
|
maxRouteHopCount = json['max_route_hop_count'],
|
|
|
|
defaultRouteHopCount = json['default_route_hop_count'];
|
2022-02-10 02:40:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
2022-03-24 14:14:50 +00:00
|
|
|
class VeilidConfigRoutingTable {
|
2023-03-12 16:24:21 +00:00
|
|
|
List<String> nodeId;
|
|
|
|
List<String> nodeIdSecret;
|
|
|
|
List<String> bootstrap;
|
2022-03-24 14:14:50 +00:00
|
|
|
int limitOverAttached;
|
|
|
|
int limitFullyAttached;
|
|
|
|
int limitAttachedStrong;
|
|
|
|
int limitAttachedGood;
|
|
|
|
int limitAttachedWeak;
|
|
|
|
|
|
|
|
VeilidConfigRoutingTable({
|
2023-03-12 16:24:21 +00:00
|
|
|
required this.nodeId,
|
|
|
|
required this.nodeIdSecret,
|
|
|
|
required this.bootstrap,
|
2022-03-24 14:14:50 +00:00
|
|
|
required this.limitOverAttached,
|
|
|
|
required this.limitFullyAttached,
|
|
|
|
required this.limitAttachedStrong,
|
|
|
|
required this.limitAttachedGood,
|
|
|
|
required this.limitAttachedWeak,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
2023-03-12 16:24:21 +00:00
|
|
|
'node_id': nodeId.map((p) => p).toList(),
|
|
|
|
'node_id_secret': nodeIdSecret.map((p) => p).toList(),
|
|
|
|
'bootstrap': bootstrap.map((p) => p).toList(),
|
2022-03-24 14:14:50 +00:00
|
|
|
'limit_over_attached': limitOverAttached,
|
|
|
|
'limit_fully_attached': limitFullyAttached,
|
|
|
|
'limit_attached_strong': limitAttachedStrong,
|
|
|
|
'limit_attached_good': limitAttachedGood,
|
|
|
|
'limit_attached_weak': limitAttachedWeak,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigRoutingTable.fromJson(dynamic json)
|
2023-03-12 16:24:21 +00:00
|
|
|
: nodeId = List<String>.from(json['node_id'].map((j) => j)),
|
|
|
|
nodeIdSecret = List<String>.from(json['node_id_secret'].map((j) => j)),
|
|
|
|
bootstrap = List<String>.from(json['bootstrap'].map((j) => j)),
|
|
|
|
limitOverAttached = json['limit_over_attached'],
|
2022-03-24 14:14:50 +00:00
|
|
|
limitFullyAttached = json['limit_fully_attached'],
|
|
|
|
limitAttachedStrong = json['limit_attached_strong'],
|
|
|
|
limitAttachedGood = json['limit_attached_good'],
|
|
|
|
limitAttachedWeak = json['limit_attached_weak'];
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
2022-02-10 02:40:01 +00:00
|
|
|
class VeilidConfigNetwork {
|
|
|
|
int connectionInitialTimeoutMs;
|
2022-03-19 22:19:40 +00:00
|
|
|
int connectionInactivityTimeoutMs;
|
2022-05-05 00:40:10 +00:00
|
|
|
int maxConnectionsPerIp4;
|
|
|
|
int maxConnectionsPerIp6Prefix;
|
|
|
|
int maxConnectionsPerIp6PrefixSize;
|
|
|
|
int maxConnectionFrequencyPerMin;
|
2022-04-03 16:58:06 +00:00
|
|
|
int clientWhitelistTimeoutMs;
|
2022-05-16 15:52:48 +00:00
|
|
|
int reverseConnectionReceiptTimeMs;
|
|
|
|
int holePunchReceiptTimeMs;
|
2022-03-24 14:14:50 +00:00
|
|
|
VeilidConfigRoutingTable routingTable;
|
2022-02-10 02:40:01 +00:00
|
|
|
VeilidConfigRPC rpc;
|
|
|
|
VeilidConfigDHT dht;
|
|
|
|
bool upnp;
|
2022-08-07 18:55:48 +00:00
|
|
|
bool detectAddressChanges;
|
2022-02-10 02:40:01 +00:00
|
|
|
int restrictedNatRetries;
|
|
|
|
VeilidConfigTLS tls;
|
|
|
|
VeilidConfigApplication application;
|
|
|
|
VeilidConfigProtocol protocol;
|
|
|
|
|
|
|
|
VeilidConfigNetwork({
|
|
|
|
required this.connectionInitialTimeoutMs,
|
2022-03-19 22:19:40 +00:00
|
|
|
required this.connectionInactivityTimeoutMs,
|
2022-05-05 00:40:10 +00:00
|
|
|
required this.maxConnectionsPerIp4,
|
|
|
|
required this.maxConnectionsPerIp6Prefix,
|
|
|
|
required this.maxConnectionsPerIp6PrefixSize,
|
|
|
|
required this.maxConnectionFrequencyPerMin,
|
2022-04-03 16:58:06 +00:00
|
|
|
required this.clientWhitelistTimeoutMs,
|
2022-05-16 15:52:48 +00:00
|
|
|
required this.reverseConnectionReceiptTimeMs,
|
|
|
|
required this.holePunchReceiptTimeMs,
|
2022-03-24 14:14:50 +00:00
|
|
|
required this.routingTable,
|
2022-02-10 02:40:01 +00:00
|
|
|
required this.rpc,
|
|
|
|
required this.dht,
|
|
|
|
required this.upnp,
|
2022-08-07 18:55:48 +00:00
|
|
|
required this.detectAddressChanges,
|
2022-02-10 02:40:01 +00:00
|
|
|
required this.restrictedNatRetries,
|
|
|
|
required this.tls,
|
|
|
|
required this.application,
|
|
|
|
required this.protocol,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'connection_initial_timeout_ms': connectionInitialTimeoutMs,
|
2022-03-19 22:19:40 +00:00
|
|
|
'connection_inactivity_timeout_ms': connectionInactivityTimeoutMs,
|
2022-05-05 00:40:10 +00:00
|
|
|
'max_connections_per_ip4': maxConnectionsPerIp4,
|
|
|
|
'max_connections_per_ip6_prefix': maxConnectionsPerIp6Prefix,
|
|
|
|
'max_connections_per_ip6_prefix_size': maxConnectionsPerIp6PrefixSize,
|
|
|
|
'max_connection_frequency_per_min': maxConnectionFrequencyPerMin,
|
2022-04-03 16:58:06 +00:00
|
|
|
'client_whitelist_timeout_ms': clientWhitelistTimeoutMs,
|
2022-05-16 15:52:48 +00:00
|
|
|
'reverse_connection_receipt_time_ms': reverseConnectionReceiptTimeMs,
|
|
|
|
'hole_punch_receipt_time_ms': holePunchReceiptTimeMs,
|
2022-03-24 14:14:50 +00:00
|
|
|
'routing_table': routingTable.json,
|
2022-02-10 02:40:01 +00:00
|
|
|
'rpc': rpc.json,
|
|
|
|
'dht': dht.json,
|
|
|
|
'upnp': upnp,
|
2022-08-07 18:55:48 +00:00
|
|
|
'detect_address_changes': detectAddressChanges,
|
2022-02-10 02:40:01 +00:00
|
|
|
'restricted_nat_retries': restrictedNatRetries,
|
|
|
|
'tls': tls.json,
|
|
|
|
'application': application.json,
|
|
|
|
'protocol': protocol.json,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigNetwork.fromJson(dynamic json)
|
2022-05-05 00:40:10 +00:00
|
|
|
: connectionInitialTimeoutMs = json['connection_initial_timeout_ms'],
|
2022-03-19 22:19:40 +00:00
|
|
|
connectionInactivityTimeoutMs =
|
|
|
|
json['connection_inactivity_timeout_ms'],
|
2022-05-05 00:40:10 +00:00
|
|
|
maxConnectionsPerIp4 = json['max_connections_per_ip4'],
|
|
|
|
maxConnectionsPerIp6Prefix = json['max_connections_per_ip6_prefix'],
|
|
|
|
maxConnectionsPerIp6PrefixSize =
|
|
|
|
json['max_connections_per_ip6_prefix_size'],
|
|
|
|
maxConnectionFrequencyPerMin = json['max_connection_frequency_per_min'],
|
2022-04-03 16:58:06 +00:00
|
|
|
clientWhitelistTimeoutMs = json['client_whitelist_timeout_ms'],
|
2022-05-16 15:52:48 +00:00
|
|
|
reverseConnectionReceiptTimeMs =
|
|
|
|
json['reverse_connection_receipt_time_ms'],
|
|
|
|
holePunchReceiptTimeMs = json['hole_punch_receipt_time_ms'],
|
2022-03-24 14:14:50 +00:00
|
|
|
routingTable = VeilidConfigRoutingTable.fromJson(json['routing_table']),
|
2022-02-10 02:40:01 +00:00
|
|
|
rpc = VeilidConfigRPC.fromJson(json['rpc']),
|
|
|
|
dht = VeilidConfigDHT.fromJson(json['dht']),
|
|
|
|
upnp = json['upnp'],
|
2022-08-07 18:55:48 +00:00
|
|
|
detectAddressChanges = json['detect_address_changes'],
|
2022-02-10 02:40:01 +00:00
|
|
|
restrictedNatRetries = json['restricted_nat_retries'],
|
|
|
|
tls = VeilidConfigTLS.fromJson(json['tls']),
|
|
|
|
application = VeilidConfigApplication.fromJson(json['application']),
|
2022-05-16 15:52:48 +00:00
|
|
|
protocol = VeilidConfigProtocol.fromJson(json['protocol']);
|
2022-02-10 02:40:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
class VeilidConfigTableStore {
|
|
|
|
String directory;
|
|
|
|
bool delete;
|
|
|
|
|
|
|
|
VeilidConfigTableStore({
|
|
|
|
required this.directory,
|
|
|
|
required this.delete,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {'directory': directory, 'delete': delete};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigTableStore.fromJson(dynamic json)
|
2022-02-10 02:40:01 +00:00
|
|
|
: directory = json['directory'],
|
|
|
|
delete = json['delete'];
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
class VeilidConfigBlockStore {
|
|
|
|
String directory;
|
|
|
|
bool delete;
|
|
|
|
|
|
|
|
VeilidConfigBlockStore({
|
|
|
|
required this.directory,
|
|
|
|
required this.delete,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {'directory': directory, 'delete': delete};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigBlockStore.fromJson(dynamic json)
|
2022-02-10 02:40:01 +00:00
|
|
|
: directory = json['directory'],
|
|
|
|
delete = json['delete'];
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
class VeilidConfigProtectedStore {
|
|
|
|
bool allowInsecureFallback;
|
|
|
|
bool alwaysUseInsecureStorage;
|
|
|
|
String insecureFallbackDirectory;
|
|
|
|
bool delete;
|
|
|
|
|
|
|
|
VeilidConfigProtectedStore({
|
|
|
|
required this.allowInsecureFallback,
|
|
|
|
required this.alwaysUseInsecureStorage,
|
|
|
|
required this.insecureFallbackDirectory,
|
|
|
|
required this.delete,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'allow_insecure_fallback': allowInsecureFallback,
|
|
|
|
'always_use_insecure_storage': alwaysUseInsecureStorage,
|
|
|
|
'insecure_fallback_directory': insecureFallbackDirectory,
|
|
|
|
'delete': delete,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigProtectedStore.fromJson(dynamic json)
|
2022-02-10 02:40:01 +00:00
|
|
|
: allowInsecureFallback = json['allow_insecure_fallback'],
|
|
|
|
alwaysUseInsecureStorage = json['always_use_insecure_storage'],
|
|
|
|
insecureFallbackDirectory = json['insecure_fallback_directory'],
|
|
|
|
delete = json['delete'];
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
class VeilidConfigCapabilities {
|
|
|
|
bool protocolUDP;
|
|
|
|
bool protocolConnectTCP;
|
|
|
|
bool protocolAcceptTCP;
|
|
|
|
bool protocolConnectWS;
|
|
|
|
bool protocolAcceptWS;
|
|
|
|
bool protocolConnectWSS;
|
|
|
|
bool protocolAcceptWSS;
|
|
|
|
|
|
|
|
VeilidConfigCapabilities({
|
|
|
|
required this.protocolUDP,
|
|
|
|
required this.protocolConnectTCP,
|
|
|
|
required this.protocolAcceptTCP,
|
|
|
|
required this.protocolConnectWS,
|
|
|
|
required this.protocolAcceptWS,
|
|
|
|
required this.protocolConnectWSS,
|
|
|
|
required this.protocolAcceptWSS,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'protocol_udp': protocolUDP,
|
|
|
|
'protocol_connect_tcp': protocolConnectTCP,
|
|
|
|
'protocol_accept_tcp': protocolAcceptTCP,
|
|
|
|
'protocol_connect_ws': protocolConnectWS,
|
|
|
|
'protocol_accept_ws': protocolAcceptWS,
|
|
|
|
'protocol_connect_wss': protocolConnectWSS,
|
|
|
|
'protocol_accept_wss': protocolAcceptWSS,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfigCapabilities.fromJson(dynamic json)
|
2022-02-10 02:40:01 +00:00
|
|
|
: protocolUDP = json['protocol_udp'],
|
|
|
|
protocolConnectTCP = json['protocol_connect_tcp'],
|
|
|
|
protocolAcceptTCP = json['protocol_accept_tcp'],
|
|
|
|
protocolConnectWS = json['protocol_connect_ws'],
|
|
|
|
protocolAcceptWS = json['protocol_accept_ws'],
|
|
|
|
protocolConnectWSS = json['protocol_connect_wss'],
|
|
|
|
protocolAcceptWSS = json['protocol_accept_wss'];
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
class VeilidConfig {
|
|
|
|
String programName;
|
2022-02-10 02:40:01 +00:00
|
|
|
String namespace;
|
|
|
|
VeilidConfigCapabilities capabilities;
|
|
|
|
VeilidConfigProtectedStore protectedStore;
|
|
|
|
VeilidConfigTableStore tableStore;
|
|
|
|
VeilidConfigBlockStore blockStore;
|
|
|
|
VeilidConfigNetwork network;
|
2022-02-07 02:18:42 +00:00
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
VeilidConfig({
|
|
|
|
required this.programName,
|
2022-02-10 02:40:01 +00:00
|
|
|
required this.namespace,
|
|
|
|
required this.capabilities,
|
|
|
|
required this.protectedStore,
|
|
|
|
required this.tableStore,
|
|
|
|
required this.blockStore,
|
|
|
|
required this.network,
|
2022-02-07 02:18:42 +00:00
|
|
|
});
|
2022-02-09 14:47:36 +00:00
|
|
|
|
2022-02-10 02:40:01 +00:00
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'program_name': programName,
|
|
|
|
'namespace': namespace,
|
|
|
|
'capabilities': capabilities.json,
|
|
|
|
'protected_store': protectedStore.json,
|
|
|
|
'table_store': tableStore.json,
|
|
|
|
'block_store': blockStore.json,
|
|
|
|
'network': network.json
|
|
|
|
};
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
2022-02-10 02:40:01 +00:00
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidConfig.fromJson(dynamic json)
|
2022-02-10 02:40:01 +00:00
|
|
|
: programName = json['program_name'],
|
|
|
|
namespace = json['namespace'],
|
|
|
|
capabilities = VeilidConfigCapabilities.fromJson(json['capabilities']),
|
|
|
|
protectedStore =
|
|
|
|
VeilidConfigProtectedStore.fromJson(json['protected_store']),
|
|
|
|
tableStore = VeilidConfigTableStore.fromJson(json['table_store']),
|
|
|
|
blockStore = VeilidConfigBlockStore.fromJson(json['block_store']),
|
|
|
|
network = VeilidConfigNetwork.fromJson(json['network']);
|
2022-02-07 02:18:42 +00:00
|
|
|
}
|
|
|
|
|
2022-09-06 20:49:43 +00:00
|
|
|
////////////
|
|
|
|
|
|
|
|
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(),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
LatencyStats.fromJson(dynamic json)
|
2022-09-06 20:49:43 +00:00
|
|
|
: fastest = BigInt.parse(json['fastest']),
|
|
|
|
average = BigInt.parse(json['average']),
|
|
|
|
slowest = BigInt.parse(json['slowest']);
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
class TransferStats {
|
|
|
|
BigInt total;
|
2022-09-07 14:33:14 +00:00
|
|
|
BigInt maximum;
|
2022-09-06 20:49:43 +00:00
|
|
|
BigInt average;
|
2022-09-07 14:33:14 +00:00
|
|
|
BigInt minimum;
|
2022-09-06 20:49:43 +00:00
|
|
|
|
|
|
|
TransferStats({
|
|
|
|
required this.total,
|
2022-09-07 14:33:14 +00:00
|
|
|
required this.maximum,
|
2022-09-06 20:49:43 +00:00
|
|
|
required this.average,
|
2022-09-07 14:33:14 +00:00
|
|
|
required this.minimum,
|
2022-09-06 20:49:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'total': total.toString(),
|
2022-09-07 14:33:14 +00:00
|
|
|
'maximum': maximum.toString(),
|
2022-09-06 20:49:43 +00:00
|
|
|
'average': average.toString(),
|
2022-09-07 14:33:14 +00:00
|
|
|
'minimum': minimum.toString(),
|
2022-09-06 20:49:43 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
TransferStats.fromJson(dynamic json)
|
2022-09-07 14:33:14 +00:00
|
|
|
: total = BigInt.parse(json['total']),
|
|
|
|
maximum = BigInt.parse(json['maximum']),
|
2022-09-06 20:49:43 +00:00
|
|
|
average = BigInt.parse(json['average']),
|
2022-09-07 14:33:14 +00:00
|
|
|
minimum = BigInt.parse(json['minimum']);
|
2022-09-06 20:49:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
class TransferStatsDownUp {
|
|
|
|
TransferStats down;
|
|
|
|
TransferStats up;
|
|
|
|
|
|
|
|
TransferStatsDownUp({
|
|
|
|
required this.down,
|
|
|
|
required this.up,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
2022-09-07 14:33:14 +00:00
|
|
|
'down': down.json,
|
|
|
|
'up': up.json,
|
2022-09-06 20:49:43 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
TransferStatsDownUp.fromJson(dynamic json)
|
2022-09-06 20:49:43 +00:00
|
|
|
: 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,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
RPCStats.fromJson(dynamic json)
|
2022-09-06 20:49:43 +00:00
|
|
|
: 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,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
PeerStats.fromJson(dynamic json)
|
2022-09-06 20:49:43 +00:00
|
|
|
: 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 {
|
2023-03-12 16:24:21 +00:00
|
|
|
List<String> nodeIds;
|
2022-09-06 20:49:43 +00:00
|
|
|
PeerAddress peerAddress;
|
|
|
|
PeerStats peerStats;
|
|
|
|
|
|
|
|
PeerTableData({
|
2023-03-12 16:24:21 +00:00
|
|
|
required this.nodeIds,
|
2022-09-06 20:49:43 +00:00
|
|
|
required this.peerAddress,
|
|
|
|
required this.peerStats,
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
2023-03-12 16:24:21 +00:00
|
|
|
'node_ids': nodeIds.map((p) => p).toList(),
|
2022-09-06 20:49:43 +00:00
|
|
|
'peer_address': peerAddress.json,
|
|
|
|
'peer_stats': peerStats.json,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
PeerTableData.fromJson(dynamic json)
|
2023-03-12 16:24:21 +00:00
|
|
|
: nodeIds = List<String>.from(json['node_ids'].map((j) => j)),
|
2022-09-06 20:49:43 +00:00
|
|
|
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,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
PeerAddress.fromJson(dynamic json)
|
2022-09-06 20:49:43 +00:00
|
|
|
: protocolType = protocolTypeFromJson(json['protocol_type']),
|
|
|
|
socketAddress = json['socket_address'];
|
|
|
|
}
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
//////////////////////////////////////
|
|
|
|
/// VeilidUpdate
|
2022-02-07 02:18:42 +00:00
|
|
|
|
|
|
|
abstract class VeilidUpdate {
|
2022-12-29 03:53:58 +00:00
|
|
|
factory VeilidUpdate.fromJson(dynamic json) {
|
2022-02-10 02:40:01 +00:00
|
|
|
switch (json["kind"]) {
|
2022-02-09 14:47:36 +00:00
|
|
|
case "Log":
|
|
|
|
{
|
2022-09-25 22:04:53 +00:00
|
|
|
return VeilidLog(
|
2022-09-06 20:49:43 +00:00
|
|
|
logLevel: veilidLogLevelFromJson(json["log_level"]),
|
2022-09-06 22:59:41 +00:00
|
|
|
message: json["message"],
|
|
|
|
backtrace: json["backtrace"]);
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
2022-09-25 22:04:53 +00:00
|
|
|
case "AppMessage":
|
|
|
|
{
|
2022-10-01 02:37:55 +00:00
|
|
|
return VeilidAppMessage(
|
|
|
|
sender: json["sender"], message: json["message"]);
|
2022-09-25 22:04:53 +00:00
|
|
|
}
|
|
|
|
case "AppCall":
|
|
|
|
{
|
2022-10-01 02:37:55 +00:00
|
|
|
return VeilidAppCall(
|
|
|
|
sender: json["sender"], message: json["message"], id: json["id"]);
|
2022-09-25 22:04:53 +00:00
|
|
|
}
|
2022-02-09 14:47:36 +00:00
|
|
|
case "Attachment":
|
|
|
|
{
|
2022-09-06 20:49:43 +00:00
|
|
|
return VeilidUpdateAttachment(
|
|
|
|
state: VeilidStateAttachment.fromJson(json));
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
2022-05-16 15:52:48 +00:00
|
|
|
case "Network":
|
|
|
|
{
|
2022-09-06 20:49:43 +00:00
|
|
|
return VeilidUpdateNetwork(state: VeilidStateNetwork.fromJson(json));
|
2022-05-16 15:52:48 +00:00
|
|
|
}
|
2022-11-16 17:49:53 +00:00
|
|
|
case "Config":
|
|
|
|
{
|
|
|
|
return VeilidUpdateConfig(state: VeilidStateConfig.fromJson(json));
|
|
|
|
}
|
2022-11-25 19:21:55 +00:00
|
|
|
case "Route":
|
|
|
|
{
|
|
|
|
return VeilidUpdateRoute(state: VeilidStateRoute.fromJson(json));
|
|
|
|
}
|
2022-02-09 14:47:36 +00:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
throw VeilidAPIExceptionInternal(
|
2022-02-10 02:40:01 +00:00
|
|
|
"Invalid VeilidAPIException type: ${json['kind']}");
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-06-10 21:07:10 +00:00
|
|
|
Map<String, dynamic> get json;
|
2022-02-07 02:18:42 +00:00
|
|
|
}
|
|
|
|
|
2022-09-25 22:04:53 +00:00
|
|
|
class VeilidLog implements VeilidUpdate {
|
2022-02-07 02:18:42 +00:00
|
|
|
final VeilidLogLevel logLevel;
|
|
|
|
final String message;
|
2022-09-06 22:59:41 +00:00
|
|
|
final String? backtrace;
|
2022-02-09 14:47:36 +00:00
|
|
|
//
|
2022-09-25 22:04:53 +00:00
|
|
|
VeilidLog({
|
2022-09-06 20:49:43 +00:00
|
|
|
required this.logLevel,
|
|
|
|
required this.message,
|
2022-09-06 22:59:41 +00:00
|
|
|
required this.backtrace,
|
2022-09-06 20:49:43 +00:00
|
|
|
});
|
2022-06-10 21:07:10 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'kind': "Log",
|
|
|
|
'log_level': logLevel.json,
|
|
|
|
'message': message,
|
2022-09-06 22:59:41 +00:00
|
|
|
'backtrace': backtrace
|
2022-06-10 21:07:10 +00:00
|
|
|
};
|
|
|
|
}
|
2022-02-07 02:18:42 +00:00
|
|
|
}
|
|
|
|
|
2022-10-01 02:37:55 +00:00
|
|
|
class VeilidAppMessage implements VeilidUpdate {
|
|
|
|
final String? sender;
|
|
|
|
final Uint8List message;
|
|
|
|
|
|
|
|
//
|
|
|
|
VeilidAppMessage({
|
|
|
|
required this.sender,
|
|
|
|
required this.message,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'kind': "AppMessage",
|
|
|
|
'sender': sender,
|
2023-01-04 22:02:45 +00:00
|
|
|
'message': base64UrlNoPadEncode(message)
|
2022-10-01 02:37:55 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class VeilidAppCall implements VeilidUpdate {
|
|
|
|
final String? sender;
|
|
|
|
final Uint8List message;
|
|
|
|
final String id;
|
|
|
|
|
|
|
|
//
|
|
|
|
VeilidAppCall({
|
|
|
|
required this.sender,
|
|
|
|
required this.message,
|
|
|
|
required this.id,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'kind': "AppMessage",
|
|
|
|
'sender': sender,
|
2023-01-04 22:02:45 +00:00
|
|
|
'message': base64UrlNoPadEncode(message),
|
2022-10-01 02:37:55 +00:00
|
|
|
'id': id,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-07 02:18:42 +00:00
|
|
|
class VeilidUpdateAttachment implements VeilidUpdate {
|
2022-09-06 20:49:43 +00:00
|
|
|
final VeilidStateAttachment state;
|
2022-02-09 14:47:36 +00:00
|
|
|
//
|
2022-09-06 20:49:43 +00:00
|
|
|
VeilidUpdateAttachment({required this.state});
|
2022-06-10 21:07:10 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> get json {
|
2022-09-06 20:49:43 +00:00
|
|
|
var jsonRep = state.json;
|
|
|
|
jsonRep['kind'] = "Attachment";
|
|
|
|
return jsonRep;
|
2022-06-10 21:07:10 +00:00
|
|
|
}
|
2022-02-07 02:18:42 +00:00
|
|
|
}
|
|
|
|
|
2022-05-16 15:52:48 +00:00
|
|
|
class VeilidUpdateNetwork implements VeilidUpdate {
|
2022-09-06 20:49:43 +00:00
|
|
|
final VeilidStateNetwork state;
|
2022-05-16 15:52:48 +00:00
|
|
|
//
|
2022-09-06 20:49:43 +00:00
|
|
|
VeilidUpdateNetwork({required this.state});
|
2022-06-10 21:07:10 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> get json {
|
2022-09-06 20:49:43 +00:00
|
|
|
var jsonRep = state.json;
|
|
|
|
jsonRep['kind'] = "Network";
|
|
|
|
return jsonRep;
|
2022-06-10 21:07:10 +00:00
|
|
|
}
|
2022-05-16 15:52:48 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 17:49:53 +00:00
|
|
|
class VeilidUpdateConfig implements VeilidUpdate {
|
|
|
|
final VeilidStateConfig state;
|
|
|
|
//
|
|
|
|
VeilidUpdateConfig({required this.state});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
var jsonRep = state.json;
|
|
|
|
jsonRep['kind'] = "Config";
|
|
|
|
return jsonRep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-25 19:21:55 +00:00
|
|
|
class VeilidUpdateRoute implements VeilidUpdate {
|
|
|
|
final VeilidStateRoute state;
|
|
|
|
//
|
|
|
|
VeilidUpdateRoute({required this.state});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
var jsonRep = state.json;
|
|
|
|
jsonRep['kind'] = "Route";
|
|
|
|
return jsonRep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-16 15:52:48 +00:00
|
|
|
//////////////////////////////////////
|
|
|
|
/// VeilidStateAttachment
|
|
|
|
|
|
|
|
class VeilidStateAttachment {
|
|
|
|
final AttachmentState state;
|
2022-12-26 21:33:48 +00:00
|
|
|
final bool publicInternetReady;
|
|
|
|
final bool localNetworkReady;
|
2022-05-16 15:52:48 +00:00
|
|
|
|
2022-12-26 21:33:48 +00:00
|
|
|
VeilidStateAttachment(
|
|
|
|
this.state, this.publicInternetReady, this.localNetworkReady);
|
2022-05-16 15:52:48 +00:00
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidStateAttachment.fromJson(dynamic json)
|
2022-12-26 21:33:48 +00:00
|
|
|
: state = attachmentStateFromJson(json['state']),
|
|
|
|
publicInternetReady = json['public_internet_ready'],
|
|
|
|
localNetworkReady = json['local_network_ready'];
|
2022-09-06 20:49:43 +00:00
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'state': state.json,
|
2022-12-26 21:33:48 +00:00
|
|
|
'public_internet_ready': publicInternetReady,
|
|
|
|
'local_network_ready': localNetworkReady,
|
2022-09-06 20:49:43 +00:00
|
|
|
};
|
|
|
|
}
|
2022-05-16 15:52:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////
|
|
|
|
/// VeilidStateNetwork
|
|
|
|
|
|
|
|
class VeilidStateNetwork {
|
|
|
|
final bool started;
|
2022-09-06 22:59:41 +00:00
|
|
|
final BigInt bpsDown;
|
|
|
|
final BigInt bpsUp;
|
2022-09-06 20:49:43 +00:00
|
|
|
final List<PeerTableData> peers;
|
2022-05-16 15:52:48 +00:00
|
|
|
|
2022-09-06 20:49:43 +00:00
|
|
|
VeilidStateNetwork(
|
|
|
|
{required this.started,
|
|
|
|
required this.bpsDown,
|
|
|
|
required this.bpsUp,
|
|
|
|
required this.peers});
|
2022-05-16 15:52:48 +00:00
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidStateNetwork.fromJson(dynamic json)
|
2022-09-06 20:49:43 +00:00
|
|
|
: started = json['started'],
|
2022-09-06 22:59:41 +00:00
|
|
|
bpsDown = BigInt.parse(json['bps_down']),
|
|
|
|
bpsUp = BigInt.parse(json['bps_up']),
|
2022-09-07 14:33:14 +00:00
|
|
|
peers = List<PeerTableData>.from(
|
|
|
|
json['peers'].map((j) => PeerTableData.fromJson(j)));
|
2022-09-06 20:49:43 +00:00
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
|
|
|
return {
|
|
|
|
'started': started,
|
2022-09-06 22:59:41 +00:00
|
|
|
'bps_down': bpsDown.toString(),
|
|
|
|
'bps_up': bpsUp.toString(),
|
2022-09-06 20:49:43 +00:00
|
|
|
'peers': peers.map((p) => p.json).toList(),
|
|
|
|
};
|
|
|
|
}
|
2022-05-16 15:52:48 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 17:49:53 +00:00
|
|
|
//////////////////////////////////////
|
|
|
|
/// VeilidStateConfig
|
|
|
|
|
|
|
|
class VeilidStateConfig {
|
|
|
|
final Map<String, dynamic> config;
|
|
|
|
|
|
|
|
VeilidStateConfig({
|
|
|
|
required this.config,
|
|
|
|
});
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidStateConfig.fromJson(dynamic json) : config = json['config'];
|
2022-11-16 17:49:53 +00:00
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
2022-11-25 19:21:55 +00:00
|
|
|
return {'config': config};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////
|
|
|
|
/// VeilidStateRoute
|
|
|
|
|
|
|
|
class VeilidStateRoute {
|
|
|
|
final List<String> deadRoutes;
|
|
|
|
final List<String> deadRemoteRoutes;
|
|
|
|
|
|
|
|
VeilidStateRoute({
|
|
|
|
required this.deadRoutes,
|
|
|
|
required this.deadRemoteRoutes,
|
|
|
|
});
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidStateRoute.fromJson(dynamic json)
|
2022-12-11 00:11:58 +00:00
|
|
|
: deadRoutes = List<String>.from(json['dead_routes'].map((j) => j)),
|
|
|
|
deadRemoteRoutes =
|
|
|
|
List<String>.from(json['dead_remote_routes'].map((j) => j));
|
2022-11-25 19:21:55 +00:00
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
2022-12-11 00:11:58 +00:00
|
|
|
return {
|
|
|
|
'dead_routes': deadRoutes.map((p) => p).toList(),
|
|
|
|
'dead_remote_routes': deadRemoteRoutes.map((p) => p).toList()
|
|
|
|
};
|
2022-11-16 17:49:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
//////////////////////////////////////
|
|
|
|
/// VeilidState
|
2022-02-07 02:18:42 +00:00
|
|
|
|
|
|
|
class VeilidState {
|
2022-05-16 15:52:48 +00:00
|
|
|
final VeilidStateAttachment attachment;
|
|
|
|
final VeilidStateNetwork network;
|
2022-11-16 17:49:53 +00:00
|
|
|
final VeilidStateConfig config;
|
2022-02-07 02:18:42 +00:00
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
VeilidState.fromJson(dynamic json)
|
2022-05-16 15:52:48 +00:00
|
|
|
: attachment = VeilidStateAttachment.fromJson(json['attachment']),
|
2022-11-16 17:49:53 +00:00
|
|
|
network = VeilidStateNetwork.fromJson(json['network']),
|
|
|
|
config = VeilidStateConfig.fromJson(json['config']);
|
2022-09-06 20:49:43 +00:00
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
2022-11-16 17:49:53 +00:00
|
|
|
return {
|
|
|
|
'attachment': attachment.json,
|
|
|
|
'network': network.json,
|
|
|
|
'config': config.json
|
|
|
|
};
|
2022-09-06 20:49:43 +00:00
|
|
|
}
|
2022-02-07 02:18:42 +00:00
|
|
|
}
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
//////////////////////////////////////
|
|
|
|
/// VeilidAPIException
|
2022-02-07 02:18:42 +00:00
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
abstract class VeilidAPIException implements Exception {
|
2022-12-29 03:53:58 +00:00
|
|
|
factory VeilidAPIException.fromJson(dynamic json) {
|
2022-02-10 02:40:01 +00:00
|
|
|
switch (json["kind"]) {
|
2022-02-09 14:47:36 +00:00
|
|
|
case "NotInitialized":
|
|
|
|
{
|
|
|
|
return VeilidAPIExceptionNotInitialized();
|
|
|
|
}
|
|
|
|
case "AlreadyInitialized":
|
|
|
|
{
|
|
|
|
return VeilidAPIExceptionAlreadyInitialized();
|
|
|
|
}
|
|
|
|
case "Timeout":
|
|
|
|
{
|
|
|
|
return VeilidAPIExceptionTimeout();
|
|
|
|
}
|
|
|
|
case "Shutdown":
|
|
|
|
{
|
|
|
|
return VeilidAPIExceptionShutdown();
|
|
|
|
}
|
|
|
|
case "NodeNotFound":
|
|
|
|
{
|
2022-02-10 02:40:01 +00:00
|
|
|
return VeilidAPIExceptionNodeNotFound(json["node_id"]);
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
|
|
|
case "NoDialInfo":
|
|
|
|
{
|
2022-02-10 02:40:01 +00:00
|
|
|
return VeilidAPIExceptionNoDialInfo(json["node_id"]);
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
|
|
|
case "Internal":
|
|
|
|
{
|
2022-02-10 02:40:01 +00:00
|
|
|
return VeilidAPIExceptionInternal(json["message"]);
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
|
|
|
case "Unimplemented":
|
|
|
|
{
|
2022-02-10 02:40:01 +00:00
|
|
|
return VeilidAPIExceptionUnimplemented(json["unimplemented"]);
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
|
|
|
case "ParseError":
|
|
|
|
{
|
2022-02-10 02:40:01 +00:00
|
|
|
return VeilidAPIExceptionParseError(json["message"], json["value"]);
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
|
|
|
case "InvalidArgument":
|
|
|
|
{
|
|
|
|
return VeilidAPIExceptionInvalidArgument(
|
2022-02-10 02:40:01 +00:00
|
|
|
json["context"], json["argument"], json["value"]);
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
|
|
|
case "MissingArgument":
|
|
|
|
{
|
|
|
|
return VeilidAPIExceptionMissingArgument(
|
2022-02-10 02:40:01 +00:00
|
|
|
json["context"], json["argument"]);
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
2022-12-03 23:08:53 +00:00
|
|
|
case "Generic":
|
|
|
|
{
|
|
|
|
return VeilidAPIExceptionGeneric(json["message"]);
|
|
|
|
}
|
2022-02-09 14:47:36 +00:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
throw VeilidAPIExceptionInternal(
|
2022-02-10 02:40:01 +00:00
|
|
|
"Invalid VeilidAPIException type: ${json['kind']}");
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-12-14 21:50:33 +00:00
|
|
|
|
|
|
|
String toDisplayError();
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
2022-02-07 02:18:42 +00:00
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
class VeilidAPIExceptionNotInitialized implements VeilidAPIException {
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return "VeilidAPIException: NotInitialized";
|
|
|
|
}
|
2022-12-14 21:50:33 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
String toDisplayError() {
|
|
|
|
return "Not initialized";
|
|
|
|
}
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
2022-02-07 02:18:42 +00:00
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
class VeilidAPIExceptionAlreadyInitialized implements VeilidAPIException {
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return "VeilidAPIException: AlreadyInitialized";
|
|
|
|
}
|
2022-12-14 21:50:33 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
String toDisplayError() {
|
|
|
|
return "Already initialized";
|
|
|
|
}
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class VeilidAPIExceptionTimeout implements VeilidAPIException {
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return "VeilidAPIException: Timeout";
|
|
|
|
}
|
2022-12-14 21:50:33 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
String toDisplayError() {
|
|
|
|
return "Timeout";
|
|
|
|
}
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
2022-02-07 02:18:42 +00:00
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
class VeilidAPIExceptionShutdown implements VeilidAPIException {
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return "VeilidAPIException: Shutdown";
|
2022-01-16 16:19:01 +00:00
|
|
|
}
|
2022-12-14 21:50:33 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
String toDisplayError() {
|
|
|
|
return "Currently shut down";
|
|
|
|
}
|
2022-02-09 14:47:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class VeilidAPIExceptionNodeNotFound implements VeilidAPIException {
|
|
|
|
final String nodeId;
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return "VeilidAPIException: NodeNotFound (nodeId: $nodeId)";
|
|
|
|
}
|
|
|
|
|
2022-12-14 21:50:33 +00:00
|
|
|
@override
|
|
|
|
String toDisplayError() {
|
|
|
|
return "Node node found: $nodeId";
|
|
|
|
}
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
//
|
|
|
|
VeilidAPIExceptionNodeNotFound(this.nodeId);
|
|
|
|
}
|
|
|
|
|
|
|
|
class VeilidAPIExceptionNoDialInfo implements VeilidAPIException {
|
|
|
|
final String nodeId;
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return "VeilidAPIException: NoDialInfo (nodeId: $nodeId)";
|
|
|
|
}
|
|
|
|
|
2022-12-14 21:50:33 +00:00
|
|
|
@override
|
|
|
|
String toDisplayError() {
|
|
|
|
return "No dial info: $nodeId";
|
|
|
|
}
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
//
|
|
|
|
VeilidAPIExceptionNoDialInfo(this.nodeId);
|
|
|
|
}
|
|
|
|
|
|
|
|
class VeilidAPIExceptionInternal implements VeilidAPIException {
|
|
|
|
final String message;
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return "VeilidAPIException: Internal ($message)";
|
|
|
|
}
|
|
|
|
|
2022-12-14 21:50:33 +00:00
|
|
|
@override
|
|
|
|
String toDisplayError() {
|
|
|
|
return "Internal error: $message";
|
|
|
|
}
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
//
|
|
|
|
VeilidAPIExceptionInternal(this.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
class VeilidAPIExceptionUnimplemented implements VeilidAPIException {
|
|
|
|
final String message;
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return "VeilidAPIException: Unimplemented ($message)";
|
|
|
|
}
|
|
|
|
|
2022-12-14 21:50:33 +00:00
|
|
|
@override
|
|
|
|
String toDisplayError() {
|
|
|
|
return "Unimplemented: $message";
|
|
|
|
}
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
//
|
|
|
|
VeilidAPIExceptionUnimplemented(this.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
class VeilidAPIExceptionParseError implements VeilidAPIException {
|
|
|
|
final String message;
|
|
|
|
final String value;
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return "VeilidAPIException: ParseError ($message)\n value: $value";
|
|
|
|
}
|
|
|
|
|
2022-12-14 21:50:33 +00:00
|
|
|
@override
|
|
|
|
String toDisplayError() {
|
|
|
|
return "Parse error: $message";
|
|
|
|
}
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
//
|
|
|
|
VeilidAPIExceptionParseError(this.message, this.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
class VeilidAPIExceptionInvalidArgument implements VeilidAPIException {
|
|
|
|
final String context;
|
|
|
|
final String argument;
|
|
|
|
final String value;
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return "VeilidAPIException: InvalidArgument ($context:$argument)\n value: $value";
|
|
|
|
}
|
|
|
|
|
2022-12-14 21:50:33 +00:00
|
|
|
@override
|
|
|
|
String toDisplayError() {
|
|
|
|
return "Invalid argument for $context: $argument";
|
|
|
|
}
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
//
|
|
|
|
VeilidAPIExceptionInvalidArgument(this.context, this.argument, this.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
class VeilidAPIExceptionMissingArgument implements VeilidAPIException {
|
|
|
|
final String context;
|
|
|
|
final String argument;
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return "VeilidAPIException: MissingArgument ($context:$argument)";
|
|
|
|
}
|
|
|
|
|
2022-12-14 21:50:33 +00:00
|
|
|
@override
|
|
|
|
String toDisplayError() {
|
|
|
|
return "Missing argument for $context: $argument";
|
|
|
|
}
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
//
|
|
|
|
VeilidAPIExceptionMissingArgument(this.context, this.argument);
|
|
|
|
}
|
|
|
|
|
2022-12-03 23:08:53 +00:00
|
|
|
class VeilidAPIExceptionGeneric implements VeilidAPIException {
|
|
|
|
final String message;
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return "VeilidAPIException: Generic (message: $message)";
|
|
|
|
}
|
|
|
|
|
2022-12-14 21:50:33 +00:00
|
|
|
@override
|
|
|
|
String toDisplayError() {
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
2022-12-03 23:08:53 +00:00
|
|
|
//
|
|
|
|
VeilidAPIExceptionGeneric(this.message);
|
|
|
|
}
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
//////////////////////////////////////
|
|
|
|
/// VeilidVersion
|
|
|
|
|
|
|
|
class VeilidVersion {
|
|
|
|
final int major;
|
|
|
|
final int minor;
|
|
|
|
final int patch;
|
|
|
|
|
|
|
|
VeilidVersion(this.major, this.minor, this.patch);
|
|
|
|
}
|
|
|
|
|
2022-11-26 19:16:02 +00:00
|
|
|
//////////////////////////////////////
|
|
|
|
/// Stability
|
|
|
|
|
|
|
|
enum Stability {
|
|
|
|
lowLatency,
|
|
|
|
reliable,
|
|
|
|
}
|
|
|
|
|
|
|
|
extension StabilityExt on Stability {
|
|
|
|
String get json {
|
|
|
|
return name.toPascalCase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Stability stabilityFromJson(String j) {
|
|
|
|
return Stability.values.byName(j.toCamelCase());
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////
|
|
|
|
/// Sequencing
|
|
|
|
|
|
|
|
enum Sequencing {
|
|
|
|
noPreference,
|
|
|
|
preferOrdered,
|
|
|
|
ensureOrdered,
|
|
|
|
}
|
|
|
|
|
|
|
|
extension SequencingExt on Sequencing {
|
|
|
|
String get json {
|
|
|
|
return name.toPascalCase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Sequencing sequencingFromJson(String j) {
|
|
|
|
return Sequencing.values.byName(j.toCamelCase());
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////
|
2023-03-01 20:50:30 +00:00
|
|
|
/// RouteBlob
|
|
|
|
class RouteBlob {
|
|
|
|
final String routeId;
|
2022-11-26 19:16:02 +00:00
|
|
|
final Uint8List blob;
|
|
|
|
|
2023-03-01 20:50:30 +00:00
|
|
|
RouteBlob(this.routeId, this.blob);
|
2022-11-26 19:16:02 +00:00
|
|
|
|
2023-03-01 20:50:30 +00:00
|
|
|
RouteBlob.fromJson(dynamic json)
|
|
|
|
: routeId = json['route_id'],
|
2023-01-04 22:02:45 +00:00
|
|
|
blob = base64UrlNoPadDecode(json['blob']);
|
2022-11-26 19:16:02 +00:00
|
|
|
|
|
|
|
Map<String, dynamic> get json {
|
2023-03-01 20:50:30 +00:00
|
|
|
return {'route_id': routeId, 'blob': base64UrlNoPadEncode(blob)};
|
2022-11-26 19:16:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////
|
|
|
|
/// VeilidRoutingContext
|
|
|
|
abstract class VeilidRoutingContext {
|
|
|
|
VeilidRoutingContext withPrivacy();
|
|
|
|
VeilidRoutingContext withCustomPrivacy(Stability stability);
|
|
|
|
VeilidRoutingContext withSequencing(Sequencing sequencing);
|
|
|
|
Future<Uint8List> appCall(String target, Uint8List request);
|
|
|
|
Future<void> appMessage(String target, Uint8List message);
|
|
|
|
}
|
|
|
|
|
2022-12-28 14:48:25 +00:00
|
|
|
/////////////////////////////////////
|
|
|
|
/// VeilidTableDB
|
2022-12-28 17:12:04 +00:00
|
|
|
abstract class VeilidTableDBTransaction {
|
|
|
|
Future<void> commit();
|
|
|
|
Future<void> rollback();
|
|
|
|
Future<void> store(int col, Uint8List key, Uint8List value);
|
|
|
|
Future<bool> delete(int col, Uint8List key);
|
2022-12-29 03:53:58 +00:00
|
|
|
|
|
|
|
Future<void> storeJson(int col, Uint8List key, Object? object,
|
|
|
|
{Object? Function(Object? nonEncodable)? toEncodable}) async {
|
|
|
|
return store(col, key,
|
|
|
|
utf8.encoder.convert(jsonEncode(object, toEncodable: toEncodable)));
|
|
|
|
}
|
2023-01-04 19:51:13 +00:00
|
|
|
|
|
|
|
Future<void> storeStringJson(int col, String key, Object? object,
|
|
|
|
{Object? Function(Object? nonEncodable)? toEncodable}) {
|
|
|
|
return storeJson(col, utf8.encoder.convert(key), object,
|
|
|
|
toEncodable: toEncodable);
|
|
|
|
}
|
2022-12-28 17:12:04 +00:00
|
|
|
}
|
|
|
|
|
2022-12-28 14:48:25 +00:00
|
|
|
abstract class VeilidTableDB {
|
|
|
|
int getColumnCount();
|
2022-12-28 17:12:04 +00:00
|
|
|
List<Uint8List> getKeys(int col);
|
|
|
|
VeilidTableDBTransaction transact();
|
|
|
|
Future<void> store(int col, Uint8List key, Uint8List value);
|
|
|
|
Future<Uint8List?> load(int col, Uint8List key);
|
|
|
|
Future<bool> delete(int col, Uint8List key);
|
2022-12-29 03:53:58 +00:00
|
|
|
|
|
|
|
Future<void> storeJson(int col, Uint8List key, Object? object,
|
|
|
|
{Object? Function(Object? nonEncodable)? toEncodable}) {
|
|
|
|
return store(col, key,
|
|
|
|
utf8.encoder.convert(jsonEncode(object, toEncodable: toEncodable)));
|
|
|
|
}
|
|
|
|
|
2023-01-03 14:13:18 +00:00
|
|
|
Future<void> storeStringJson(int col, String key, Object? object,
|
|
|
|
{Object? Function(Object? nonEncodable)? toEncodable}) {
|
2023-01-04 19:51:13 +00:00
|
|
|
return storeJson(col, utf8.encoder.convert(key), object,
|
|
|
|
toEncodable: toEncodable);
|
2023-01-03 14:13:18 +00:00
|
|
|
}
|
|
|
|
|
2022-12-29 03:53:58 +00:00
|
|
|
Future<Object?> loadJson(int col, Uint8List key,
|
|
|
|
{Object? Function(Object? key, Object? value)? reviver}) async {
|
|
|
|
var s = await load(col, key);
|
|
|
|
if (s == null) {
|
|
|
|
return null;
|
|
|
|
}
|
2023-01-03 14:13:18 +00:00
|
|
|
return jsonDecode(utf8.decode(s, allowMalformed: false), reviver: reviver);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<Object?> loadStringJson(int col, String key,
|
|
|
|
{Object? Function(Object? key, Object? value)? reviver}) {
|
|
|
|
return loadJson(col, utf8.encoder.convert(key), reviver: reviver);
|
2022-12-29 03:53:58 +00:00
|
|
|
}
|
2022-12-28 14:48:25 +00:00
|
|
|
}
|
|
|
|
|
2022-02-09 14:47:36 +00:00
|
|
|
//////////////////////////////////////
|
|
|
|
/// Veilid singleton factory
|
|
|
|
|
|
|
|
abstract class Veilid {
|
|
|
|
static late Veilid instance = getVeilid();
|
2022-01-29 18:23:10 +00:00
|
|
|
|
2022-07-01 20:20:43 +00:00
|
|
|
void initializeVeilidCore(Map<String, dynamic> platformConfigJson);
|
2022-07-01 16:13:52 +00:00
|
|
|
void changeLogLevel(String layer, VeilidConfigLogLevel logLevel);
|
2022-09-09 20:27:13 +00:00
|
|
|
Future<Stream<VeilidUpdate>> startupVeilidCore(VeilidConfig config);
|
2022-02-09 14:47:36 +00:00
|
|
|
Future<VeilidState> getVeilidState();
|
2022-09-06 22:59:41 +00:00
|
|
|
Future<void> attach();
|
|
|
|
Future<void> detach();
|
2022-02-09 14:47:36 +00:00
|
|
|
Future<void> shutdownVeilidCore();
|
2022-11-26 19:16:02 +00:00
|
|
|
|
|
|
|
// Routing context
|
|
|
|
Future<VeilidRoutingContext> routingContext();
|
|
|
|
|
|
|
|
// Private route allocation
|
2023-03-01 20:50:30 +00:00
|
|
|
Future<RouteBlob> newPrivateRoute();
|
|
|
|
Future<RouteBlob> newCustomPrivateRoute(
|
2022-11-26 19:16:02 +00:00
|
|
|
Stability stability, Sequencing sequencing);
|
|
|
|
Future<String> importRemotePrivateRoute(Uint8List blob);
|
|
|
|
Future<void> releasePrivateRoute(String key);
|
|
|
|
|
|
|
|
// App calls
|
2022-10-01 02:37:55 +00:00
|
|
|
Future<void> appCallReply(String id, Uint8List message);
|
2022-11-26 19:16:02 +00:00
|
|
|
|
2022-12-28 14:48:25 +00:00
|
|
|
// TableStore
|
|
|
|
Future<VeilidTableDB> openTableDB(String name, int columnCount);
|
|
|
|
Future<bool> deleteTableDB(String name);
|
|
|
|
|
2022-11-26 19:16:02 +00:00
|
|
|
// Misc
|
2022-03-17 14:31:10 +00:00
|
|
|
String veilidVersionString();
|
|
|
|
VeilidVersion veilidVersion();
|
2022-11-26 19:16:02 +00:00
|
|
|
Future<String> debug(String command);
|
2022-01-16 16:19:01 +00:00
|
|
|
}
|