sync
This commit is contained in:
parent
7458d0d991
commit
98799b4d3a
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -3954,6 +3954,7 @@ dependencies = [
|
||||
"console_error_panic_hook",
|
||||
"ffi-support",
|
||||
"futures",
|
||||
"jni",
|
||||
"js-sys",
|
||||
"lazy_static",
|
||||
"log",
|
||||
|
@ -62,7 +62,7 @@ impl VeilidCoreContext {
|
||||
if utils::android::ANDROID_GLOBALS.lock().is_none() {
|
||||
error!("Android globals are not set up");
|
||||
config.terminate().await;
|
||||
return Err("Android globals are not set up".to_owned());
|
||||
return Err(VeilidAPIError::Internal { message: "Android globals are not set up".to_owned() });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,9 @@ pub fn veilid_version() -> (u32, u32, u32) {
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
pub use intf::utils::android::{veilid_core_setup_android, veilid_core_setup_android_no_log};
|
||||
|
||||
pub static DEFAULT_LOG_IGNORE_LIST: [&str; 8] = [
|
||||
"async_std",
|
||||
"async_io",
|
||||
|
@ -1,5 +1,5 @@
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.50'
|
||||
ext.kotlin_version = '1.4.32'
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
@ -11,13 +11,13 @@ import io.flutter.plugin.common.MethodChannel.Result
|
||||
/** VeilidPlugin */
|
||||
class VeilidPlugin: FlutterPlugin, MethodCallHandler {
|
||||
|
||||
class object {
|
||||
{
|
||||
System.loadLibrary("veilid_flutter");
|
||||
companion object {
|
||||
init {
|
||||
System.loadLibrary("veilid_flutter")
|
||||
}
|
||||
}
|
||||
|
||||
native fun init_android(ctx: Context)
|
||||
external fun init_android(ctx: Context)
|
||||
|
||||
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||
init_android(flutterPluginBinding.getApplicationContext())
|
||||
|
@ -1,5 +1,5 @@
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.50'
|
||||
ext.kotlin_version = '1.4.32'
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
125
veilid-flutter/example/lib/config.dart
Normal file
125
veilid-flutter/example/lib/config.dart
Normal file
@ -0,0 +1,125 @@
|
||||
import 'package:veilid/veilid.dart';
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
Future<VeilidConfig> getDefaultVeilidConfig() async {
|
||||
return VeilidConfig(
|
||||
programName: "Veilid Plugin Test",
|
||||
namespace: "",
|
||||
apiLogLevel: VeilidConfigLogLevel.trace,
|
||||
capabilities: VeilidConfigCapabilities(
|
||||
protocolUDP: !kIsWeb,
|
||||
protocolConnectTCP: !kIsWeb,
|
||||
protocolAcceptTCP: !kIsWeb,
|
||||
protocolConnectWS: true,
|
||||
protocolAcceptWS: !kIsWeb,
|
||||
protocolConnectWSS: true,
|
||||
protocolAcceptWSS: false,
|
||||
),
|
||||
protectedStore: VeilidConfigProtectedStore(
|
||||
allowInsecureFallback: false,
|
||||
alwaysUseInsecureStorage: false,
|
||||
insecureFallbackDirectory: "",
|
||||
delete: false,
|
||||
),
|
||||
tableStore: VeilidConfigTableStore(
|
||||
directory: p.join((await getApplicationSupportDirectory()).absolute.path,
|
||||
"table_store"),
|
||||
delete: false,
|
||||
),
|
||||
blockStore: VeilidConfigBlockStore(
|
||||
directory: p.join((await getApplicationSupportDirectory()).absolute.path,
|
||||
"block_store"),
|
||||
delete: false,
|
||||
),
|
||||
network: VeilidConfigNetwork(
|
||||
maxConnections: 16,
|
||||
connectionInitialTimeoutMs: 2000,
|
||||
nodeId: "",
|
||||
nodeIdSecret: "",
|
||||
bootstrap: [],
|
||||
rpc: VeilidConfigRPC(
|
||||
concurrency: 0,
|
||||
queueSize: 1024,
|
||||
maxTimestampBehindMs: 10000,
|
||||
maxTimestampAheadMs: 10000,
|
||||
timeoutMs: 10000,
|
||||
maxRouteHopCount: 7,
|
||||
),
|
||||
dht: VeilidConfigDHT(
|
||||
resolveNodeTimeoutMs: null,
|
||||
resolveNodeCount: 20,
|
||||
resolveNodeFanout: 3,
|
||||
maxFindNodeCount: 20,
|
||||
getValueTimeoutMs: null,
|
||||
getValueCount: 20,
|
||||
getValueFanout: 3,
|
||||
setValueTimeoutMs: null,
|
||||
setValueCount: 20,
|
||||
setValueFanout: 5,
|
||||
minPeerCount: 20,
|
||||
minPeerRefreshTimeMs: 2000,
|
||||
validateDialInfoReceiptTimeMs: 5000,
|
||||
),
|
||||
upnp: true,
|
||||
natpmp: true,
|
||||
enableLocalPeerScope: false,
|
||||
restrictedNatRetries: 3,
|
||||
tls: VeilidConfigTLS(
|
||||
certificatePath: "",
|
||||
privateKeyPath: "",
|
||||
connectionInitialTimeoutMs: 2000,
|
||||
),
|
||||
application: VeilidConfigApplication(
|
||||
https: VeilidConfigHTTPS(
|
||||
enabled: false,
|
||||
listenAddress: "",
|
||||
path: "",
|
||||
url: null,
|
||||
),
|
||||
http: VeilidConfigHTTP(
|
||||
enabled: false,
|
||||
listenAddress: "",
|
||||
path: "",
|
||||
url: null,
|
||||
)),
|
||||
protocol: VeilidConfigProtocol(
|
||||
udp: VeilidConfigUDP(
|
||||
enabled: !kIsWeb,
|
||||
socketPoolSize: 0,
|
||||
listenAddress: "[::]:5150",
|
||||
publicAddress: null,
|
||||
),
|
||||
tcp: VeilidConfigTCP(
|
||||
connect: !kIsWeb,
|
||||
listen: !kIsWeb,
|
||||
maxConnections: 32,
|
||||
listenAddress: "[::]:5150",
|
||||
publicAddress: null,
|
||||
),
|
||||
ws: VeilidConfigWS(
|
||||
connect: true,
|
||||
listen: !kIsWeb,
|
||||
maxConnections: 16,
|
||||
listenAddress: "[::]:5150",
|
||||
path: "ws",
|
||||
url: null,
|
||||
),
|
||||
wss: VeilidConfigWSS(
|
||||
connect: true,
|
||||
listen: false,
|
||||
maxConnections: 16,
|
||||
listenAddress: "[::]:5150",
|
||||
path: "ws",
|
||||
url: null,
|
||||
),
|
||||
),
|
||||
leases: VeilidConfigLeases(
|
||||
maxServerSignalLeases: 256,
|
||||
maxServerRelayLeases: 8,
|
||||
maxClientSignalLeases: 2,
|
||||
maxClientRelayLeases: 2,
|
||||
)),
|
||||
);
|
||||
}
|
@ -1,51 +1,54 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:veilid/veilid.dart';
|
||||
import 'package:logger_flutter_viewer/logger_flutter_viewer.dart';
|
||||
import 'package:flutter_loggy/flutter_loggy.dart';
|
||||
import 'package:loggy/loggy.dart';
|
||||
|
||||
// Logger
|
||||
var stacklog = Logger(
|
||||
printer: PrettyPrinter(
|
||||
methodCount: 10,
|
||||
errorMethodCount: 10,
|
||||
printTime: true,
|
||||
colors: true,
|
||||
printEmojis: true),
|
||||
output: ScreenOutput());
|
||||
var log = Logger(
|
||||
printer: PrettyPrinter(
|
||||
methodCount: 0,
|
||||
errorMethodCount: 1,
|
||||
printTime: true,
|
||||
colors: true,
|
||||
printEmojis: true,
|
||||
noBoxingByDefault: true,
|
||||
),
|
||||
output: ScreenOutput());
|
||||
var barelog = Logger(
|
||||
printer: PrettyPrinter(
|
||||
methodCount: 0,
|
||||
errorMethodCount: 0,
|
||||
printTime: false,
|
||||
colors: true,
|
||||
printEmojis: true,
|
||||
noBoxingByDefault: true,
|
||||
),
|
||||
output: ScreenOutput());
|
||||
import 'config.dart';
|
||||
|
||||
class ScreenOutput extends LogOutput {
|
||||
@override
|
||||
void output(OutputEvent event) {
|
||||
LogConsole.output(event);
|
||||
}
|
||||
// Loggy tools
|
||||
const LogLevel traceLevel = LogLevel('trace', 1);
|
||||
|
||||
extension TraceLoggy on Loggy {
|
||||
void trace(dynamic message, [Object? error, StackTrace? stackTrace]) =>
|
||||
log(traceLevel, message, error, stackTrace);
|
||||
}
|
||||
|
||||
LogOptions getLogOptions(LogLevel? level) {
|
||||
return LogOptions(
|
||||
level ?? LogLevel.all,
|
||||
stackTraceLevel: LogLevel.error,
|
||||
);
|
||||
}
|
||||
|
||||
void setRootLogLevel(LogLevel? level) {
|
||||
Loggy('').level = getLogOptions(level);
|
||||
}
|
||||
|
||||
void initLoggy() {
|
||||
Loggy.initLoggy(
|
||||
logPrinter: StreamPrinter(
|
||||
const PrettyDeveloperPrinter(),
|
||||
),
|
||||
logOptions: getLogOptions(null),
|
||||
);
|
||||
}
|
||||
|
||||
// Entrypoint
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
initLoggy();
|
||||
|
||||
runApp(MaterialApp(
|
||||
title: 'Veilid Plugin Demo',
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
),
|
||||
home: const MyApp()));
|
||||
}
|
||||
|
||||
// Main App
|
||||
@ -56,8 +59,9 @@ class MyApp extends StatefulWidget {
|
||||
State<MyApp> createState() => _MyAppState();
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> {
|
||||
class _MyAppState extends State<MyApp> with UiLoggy {
|
||||
String _veilidVersion = 'Unknown';
|
||||
Stream<VeilidUpdate>? _updateStream;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -75,10 +79,11 @@ class _MyAppState extends State<MyApp> {
|
||||
} on PlatformException {
|
||||
veilidVersion = 'Failed to get veilid version.';
|
||||
}
|
||||
log.e("Error test");
|
||||
log.w("Warning test");
|
||||
stacklog.i("Info test with stacklog");
|
||||
barelog.d("debug bare-log test");
|
||||
loggy.error("Error test");
|
||||
loggy.warning("Warning test");
|
||||
loggy.info("Info test");
|
||||
loggy.debug("Debug test");
|
||||
loggy.trace("Trace test");
|
||||
|
||||
// If the widget was removed from the tree while the asynchronous platform
|
||||
// message was in flight, we want to discard the reply rather than calling
|
||||
@ -92,13 +97,70 @@ class _MyAppState extends State<MyApp> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
final ButtonStyle buttonStyle =
|
||||
ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20));
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Veilid Plugin Version $_veilidVersion'),
|
||||
),
|
||||
body: LogConsole(dark: Theme.of(context).brightness == Brightness.dark),
|
||||
),
|
||||
);
|
||||
body: Column(children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: ThemeData.dark().scaffoldBackgroundColor,
|
||||
height: MediaQuery.of(context).size.height * 0.4,
|
||||
child: LoggyStreamWidget(logLevel: loggy.level.logLevel),
|
||||
)),
|
||||
Container(
|
||||
padding: const EdgeInsets.fromLTRB(8, 8, 8, 12),
|
||||
child: Row(children: [
|
||||
ElevatedButton(
|
||||
style: buttonStyle,
|
||||
onPressed: () async {
|
||||
//var await Veilid.instance.startupVeilidCore(await getDefaultVeilidConfig())
|
||||
// setState(() {
|
||||
// };
|
||||
},
|
||||
child: const Text('Startup'),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: buttonStyle,
|
||||
onPressed: () {},
|
||||
child: const Text('Shutdown'),
|
||||
),
|
||||
])),
|
||||
Row(children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Debug Command'),
|
||||
textInputAction: TextInputAction.send,
|
||||
onSubmitted: (String v) async {
|
||||
loggy.debug(await Veilid.instance.debug(v));
|
||||
})),
|
||||
DropdownButton<LogLevel>(
|
||||
value: loggy.level.logLevel,
|
||||
onChanged: (LogLevel? newLevel) {
|
||||
setState(() {
|
||||
setRootLogLevel(newLevel);
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
DropdownMenuItem<LogLevel>(
|
||||
value: LogLevel.error, child: Text("Error")),
|
||||
DropdownMenuItem<LogLevel>(
|
||||
value: LogLevel.warning, child: Text("Warning")),
|
||||
DropdownMenuItem<LogLevel>(
|
||||
value: LogLevel.info, child: Text("Info")),
|
||||
DropdownMenuItem<LogLevel>(
|
||||
value: LogLevel.debug, child: Text("Debug")),
|
||||
DropdownMenuItem<LogLevel>(
|
||||
value: traceLevel, child: Text("Trace")),
|
||||
DropdownMenuItem<LogLevel>(
|
||||
value: LogLevel.all, child: Text("All")),
|
||||
])
|
||||
]),
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,10 @@
|
||||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import path_provider_macos
|
||||
import veilid
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
VeilidPlugin.register(with: registry.registrar(forPlugin: "VeilidPlugin"))
|
||||
}
|
||||
|
@ -71,6 +71,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.2"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.1.2"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@ -83,6 +90,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
flutter_loggy:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_loggy
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
@ -107,20 +121,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
logger:
|
||||
loggy:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: logger
|
||||
name: loggy
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
logger_flutter_viewer:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: logger_flutter_viewer
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.8.0"
|
||||
version: "2.0.1+1"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -149,6 +156,62 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.0"
|
||||
path_provider:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.9"
|
||||
path_provider_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_android
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.12"
|
||||
path_provider_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_ios
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.8"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_linux
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.5"
|
||||
path_provider_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_macos
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.5"
|
||||
path_provider_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.3"
|
||||
path_provider_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.5"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: platform
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.1.0"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -156,27 +219,20 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
sensors_plus:
|
||||
process:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sensors_plus
|
||||
name: process
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
sensors_plus_platform_interface:
|
||||
version: "4.2.4"
|
||||
rxdart:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sensors_plus_platform_interface
|
||||
name: rxdart
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
sensors_plus_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sensors_plus_web
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "0.27.3"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@ -245,6 +301,20 @@ packages:
|
||||
relative: true
|
||||
source: path
|
||||
version: "0.0.1"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.4.1"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xdg_directories
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.0+1"
|
||||
sdks:
|
||||
dart: ">=2.15.1 <3.0.0"
|
||||
flutter: ">=2.5.0"
|
||||
flutter: ">=2.8.0"
|
||||
|
@ -33,8 +33,8 @@ dependencies:
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.2
|
||||
logger: ^1.1.0
|
||||
logger_flutter_viewer: ^0.8.0
|
||||
loggy: ^2.0.1+1
|
||||
flutter_loggy: ^2.0.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
@ -1,5 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:change_case/change_case.dart';
|
||||
|
||||
@ -996,6 +995,7 @@ abstract class Veilid {
|
||||
Future<VeilidState> getVeilidState();
|
||||
Future<void> changeApiLogLevel(VeilidConfigLogLevel logLevel);
|
||||
Future<void> shutdownVeilidCore();
|
||||
Future<String> debug(String command);
|
||||
String veilidVersionString();
|
||||
VeilidVersion veilidVersion();
|
||||
}
|
||||
|
@ -38,6 +38,9 @@ typedef _GetVeilidStateDart = void Function(int);
|
||||
// fn change_api_log_level(port: i64, log_level: FfiStr)
|
||||
typedef _ChangeApiLogLevelC = Void Function(Int64, Pointer<Utf8>);
|
||||
typedef _ChangeApiLogLevelDart = void Function(int, Pointer<Utf8>);
|
||||
// fn debug(port: i64, log_level: FfiStr)
|
||||
typedef _DebugC = Void Function(Int64, Pointer<Utf8>);
|
||||
typedef _DebugDart = void Function(int, Pointer<Utf8>);
|
||||
// fn shutdown_veilid_core(port: i64)
|
||||
typedef _ShutdownVeilidCoreC = Void Function(Int64);
|
||||
typedef _ShutdownVeilidCoreDart = void Function(int);
|
||||
@ -73,8 +76,7 @@ const int messageStreamClose = 8;
|
||||
Veilid getVeilid() => VeilidFFI(_dylib);
|
||||
|
||||
// Parse handle async returns
|
||||
Future<T> processFuturePlain<T>(
|
||||
T Function(Map<String, dynamic>)? jsonConstructor, Future<dynamic> future) {
|
||||
Future<T> processFuturePlain<T>(Future<dynamic> future) {
|
||||
return future.then((value) {
|
||||
final list = value as List<dynamic>;
|
||||
switch (list[0] as int) {
|
||||
@ -235,6 +237,7 @@ class VeilidFFI implements Veilid {
|
||||
final _GetVeilidStateDart _getVeilidState;
|
||||
final _ChangeApiLogLevelDart _changeApiLogLevel;
|
||||
final _ShutdownVeilidCoreDart _shutdownVeilidCore;
|
||||
final _DebugDart _debug;
|
||||
final _VeilidVersionStringDart _veilidVersionString;
|
||||
final _VeilidVersionDart _veilidVersion;
|
||||
|
||||
@ -254,6 +257,7 @@ class VeilidFFI implements Veilid {
|
||||
_shutdownVeilidCore =
|
||||
dylib.lookupFunction<_ShutdownVeilidCoreC, _ShutdownVeilidCoreDart>(
|
||||
'shutdown_veilid_core'),
|
||||
_debug = dylib.lookupFunction<_DebugC, _DebugDart>('debug'),
|
||||
_veilidVersionString = dylib.lookupFunction<_VeilidVersionStringC,
|
||||
_VeilidVersionStringDart>('veilid_version_string'),
|
||||
_veilidVersion =
|
||||
@ -304,6 +308,15 @@ class VeilidFFI implements Veilid {
|
||||
return processFutureVoid(recvPort.single);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> debug(String command) async {
|
||||
var nativeCommand = command.toNativeUtf8();
|
||||
final recvPort = ReceivePort("debug");
|
||||
final sendPort = recvPort.sendPort;
|
||||
_debug(sendPort.nativePort, nativeCommand);
|
||||
return processFuturePlain(recvPort.single);
|
||||
}
|
||||
|
||||
@override
|
||||
String veilidVersionString() {
|
||||
final versionString = _veilidVersionString();
|
||||
|
@ -9,26 +9,37 @@ import 'dart:typed_data';
|
||||
Veilid getVeilid() => VeilidJS();
|
||||
|
||||
class VeilidJS implements Veilid {
|
||||
@override
|
||||
Stream<VeilidUpdate> startupVeilidCore(VeilidConfig config) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<VeilidState> getVeilidState() {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> changeApiLogLevel(VeilidConfigLogLevel logLevel) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> shutdownVeilidCore() {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> debug(String command) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
String veilidVersionString() {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
VeilidVersion veilidVersion() {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
@ -14,10 +14,9 @@ FetchContent_Declare(
|
||||
|
||||
FetchContent_MakeAvailable(Corrosion)
|
||||
|
||||
corrosion_import_crate(MANIFEST_PATH ${CMAKE_SOURCE_DIR}/../../rust/Cargo.toml)
|
||||
corrosion_import_crate(MANIFEST_PATH ${CMAKE_SOURCE_DIR}/../../rust/Cargo.toml CRATES veilid-flutter)
|
||||
|
||||
# Flutter-specific
|
||||
|
||||
set(CRATE_NAME "veilid-flutter")
|
||||
target_link_libraries(${PLUGIN_NAME} PUBLIC ${CRATE_NAME})
|
||||
# list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${CRATE_NAME}-shared>)
|
@ -15,6 +15,8 @@ dependencies:
|
||||
sdk: flutter
|
||||
ffi: ^1.1.2
|
||||
change_case: ^1.0.1
|
||||
path_provider: ^2.0.9
|
||||
path: ^1.8.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
@ -34,6 +34,10 @@ wasm-logger = "^0"
|
||||
wasm-bindgen-futures = "^0"
|
||||
js-sys = "^0"
|
||||
|
||||
# Dependencies for Android builds only
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
jni = "^0"
|
||||
|
||||
# Dev Dependencies for WASM builds only
|
||||
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
|
||||
wasm-bindgen-test = "^0"
|
||||
|
@ -21,5 +21,5 @@ pub extern "system" fn Java_com_veilid_veilid_VeilidPlugin_init_1android(
|
||||
_class: JClass,
|
||||
ctx: JObject,
|
||||
) {
|
||||
crate::intf::utils::android::veilid_core_setup_android_no_log(env, ctx);
|
||||
veilid_core::veilid_core_setup_android_no_log(env, ctx);
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:veilid/veilid.dart';
|
||||
|
||||
|
@ -48,16 +48,16 @@ core:
|
||||
delete: false
|
||||
network:
|
||||
max_connections: 16
|
||||
connection_initial_timeout: 2000000
|
||||
connection_initial_timeout_ms: 2000
|
||||
node_id: ''
|
||||
node_id_secret: ''
|
||||
bootstrap: []
|
||||
rpc:
|
||||
concurrency: 0
|
||||
queue_size: 1024
|
||||
max_timestamp_behind: 10000000
|
||||
max_timestamp_ahead: 10000000
|
||||
timeout: 10000000
|
||||
max_timestamp_behind_ms: 10000
|
||||
max_timestamp_ahead_ms: 10000
|
||||
timeout_ms: 10000
|
||||
max_route_hop_count: 7
|
||||
dht:
|
||||
resolve_node_timeout:
|
||||
@ -71,8 +71,8 @@ core:
|
||||
set_value_count: 20
|
||||
set_value_fanout: 5
|
||||
min_peer_count: 20
|
||||
min_peer_refresh_time: 2000000
|
||||
validate_dial_info_receipt_time: 5000000
|
||||
min_peer_refresh_time_ms: 2000
|
||||
validate_dial_info_receipt_time_ms: 5000
|
||||
upnp: false
|
||||
natpmp: false
|
||||
enable_local_peer_scope: false
|
||||
@ -80,7 +80,7 @@ core:
|
||||
tls:
|
||||
certificate_path: '/etc/veilid/server.crt'
|
||||
private_key_path: '/etc/veilid/private/server.key'
|
||||
connection_initial_timeout: 2000000
|
||||
connection_initial_timeout_ms: 2000
|
||||
application:
|
||||
https:
|
||||
enabled: false
|
||||
@ -476,34 +476,34 @@ pub struct Protocol {
|
||||
pub struct Tls {
|
||||
pub certificate_path: PathBuf,
|
||||
pub private_key_path: PathBuf,
|
||||
pub connection_initial_timeout: u64,
|
||||
pub connection_initial_timeout_ms: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct Rpc {
|
||||
pub concurrency: u32,
|
||||
pub queue_size: u32,
|
||||
pub max_timestamp_behind: Option<u64>,
|
||||
pub max_timestamp_ahead: Option<u64>,
|
||||
pub timeout: u64,
|
||||
pub max_timestamp_behind_ms: Option<u32>,
|
||||
pub max_timestamp_ahead_ms: Option<u32>,
|
||||
pub timeout_ms: u32,
|
||||
pub max_route_hop_count: u8,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct Dht {
|
||||
pub resolve_node_timeout: Option<u64>,
|
||||
pub resolve_node_timeout_ms: Option<u32>,
|
||||
pub resolve_node_count: u32,
|
||||
pub resolve_node_fanout: u32,
|
||||
pub max_find_node_count: u32,
|
||||
pub get_value_timeout: Option<u64>,
|
||||
pub get_value_timeout_ms: Option<u32>,
|
||||
pub get_value_count: u32,
|
||||
pub get_value_fanout: u32,
|
||||
pub set_value_timeout: Option<u64>,
|
||||
pub set_value_timeout_ms: Option<u32>,
|
||||
pub set_value_count: u32,
|
||||
pub set_value_fanout: u32,
|
||||
pub min_peer_count: u32,
|
||||
pub min_peer_refresh_time: u64,
|
||||
pub validate_dial_info_receipt_time: u64,
|
||||
pub min_peer_refresh_time_ms: u32,
|
||||
pub validate_dial_info_receipt_time_ms: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
@ -517,7 +517,7 @@ pub struct Leases {
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct Network {
|
||||
pub max_connections: u32,
|
||||
pub connection_initial_timeout: u64,
|
||||
pub connection_initial_timeout_ms: u32,
|
||||
pub node_id: veilid_core::DHTKey,
|
||||
pub node_id_secret: veilid_core::DHTKeySecret,
|
||||
pub bootstrap: Vec<ParsedNodeDialInfo>,
|
||||
@ -796,8 +796,8 @@ impl Settings {
|
||||
"block_store.delete" => Ok(Box::new(inner.core.block_store.delete)),
|
||||
|
||||
"network.max_connections" => Ok(Box::new(inner.core.network.max_connections)),
|
||||
"network.connection_initial_timeout" => {
|
||||
Ok(Box::new(inner.core.network.connection_initial_timeout))
|
||||
"network.connection_initial_timeout_ms" => {
|
||||
Ok(Box::new(inner.core.network.connection_initial_timeout_ms))
|
||||
}
|
||||
"network.node_id" => Ok(Box::new(inner.core.network.node_id)),
|
||||
"network.node_id_secret" => Ok(Box::new(inner.core.network.node_id_secret)),
|
||||
@ -813,18 +813,18 @@ impl Settings {
|
||||
)),
|
||||
"network.rpc.concurrency" => Ok(Box::new(inner.core.network.rpc.concurrency)),
|
||||
"network.rpc.queue_size" => Ok(Box::new(inner.core.network.rpc.queue_size)),
|
||||
"network.rpc.max_timestamp_behind" => {
|
||||
Ok(Box::new(inner.core.network.rpc.max_timestamp_behind))
|
||||
"network.rpc.max_timestamp_behind_ms" => {
|
||||
Ok(Box::new(inner.core.network.rpc.max_timestamp_behind_ms))
|
||||
}
|
||||
"network.rpc.max_timestamp_ahead" => {
|
||||
Ok(Box::new(inner.core.network.rpc.max_timestamp_ahead))
|
||||
"network.rpc.max_timestamp_ahead_ms" => {
|
||||
Ok(Box::new(inner.core.network.rpc.max_timestamp_ahead_ms))
|
||||
}
|
||||
"network.rpc.timeout" => Ok(Box::new(inner.core.network.rpc.timeout)),
|
||||
"network.rpc.timeout_ms" => Ok(Box::new(inner.core.network.rpc.timeout_ms)),
|
||||
"network.rpc.max_route_hop_count" => {
|
||||
Ok(Box::new(inner.core.network.rpc.max_route_hop_count))
|
||||
}
|
||||
"network.dht.resolve_node_timeout" => {
|
||||
Ok(Box::new(inner.core.network.dht.resolve_node_timeout))
|
||||
"network.dht.resolve_node_timeout_ms" => {
|
||||
Ok(Box::new(inner.core.network.dht.resolve_node_timeout_ms))
|
||||
}
|
||||
"network.dht.resolve_node_count" => {
|
||||
Ok(Box::new(inner.core.network.dht.resolve_node_count))
|
||||
@ -835,8 +835,8 @@ impl Settings {
|
||||
"network.dht.max_find_node_count" => {
|
||||
Ok(Box::new(inner.core.network.dht.max_find_node_count))
|
||||
}
|
||||
"network.dht.get_value_timeout" => {
|
||||
Ok(Box::new(inner.core.network.dht.get_value_timeout))
|
||||
"network.dht.get_value_timeout_ms" => {
|
||||
Ok(Box::new(inner.core.network.dht.get_value_timeout_ms))
|
||||
}
|
||||
"network.dht.get_value_count" => {
|
||||
Ok(Box::new(inner.core.network.dht.get_value_count))
|
||||
@ -844,8 +844,8 @@ impl Settings {
|
||||
"network.dht.get_value_fanout" => {
|
||||
Ok(Box::new(inner.core.network.dht.get_value_fanout))
|
||||
}
|
||||
"network.dht.set_value_timeout" => {
|
||||
Ok(Box::new(inner.core.network.dht.set_value_timeout))
|
||||
"network.dht.set_value_timeout_ms" => {
|
||||
Ok(Box::new(inner.core.network.dht.set_value_timeout_ms))
|
||||
}
|
||||
"network.dht.set_value_count" => {
|
||||
Ok(Box::new(inner.core.network.dht.set_value_count))
|
||||
@ -854,11 +854,11 @@ impl Settings {
|
||||
Ok(Box::new(inner.core.network.dht.set_value_fanout))
|
||||
}
|
||||
"network.dht.min_peer_count" => Ok(Box::new(inner.core.network.dht.min_peer_count)),
|
||||
"network.dht.min_peer_refresh_time" => {
|
||||
Ok(Box::new(inner.core.network.dht.min_peer_refresh_time))
|
||||
"network.dht.min_peer_refresh_time_ms" => {
|
||||
Ok(Box::new(inner.core.network.dht.min_peer_refresh_time_ms))
|
||||
}
|
||||
"network.dht.validate_dial_info_receipt_time" => Ok(Box::new(
|
||||
inner.core.network.dht.validate_dial_info_receipt_time,
|
||||
"network.dht.validate_dial_info_receipt_time_ms" => Ok(Box::new(
|
||||
inner.core.network.dht.validate_dial_info_receipt_time_ms,
|
||||
)),
|
||||
"network.upnp" => Ok(Box::new(inner.core.network.upnp)),
|
||||
"network.natpmp" => Ok(Box::new(inner.core.network.natpmp)),
|
||||
@ -886,9 +886,9 @@ impl Settings {
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
)),
|
||||
"network.tls.connection_initial_timeout" => {
|
||||
Ok(Box::new(inner.core.network.tls.connection_initial_timeout))
|
||||
}
|
||||
"network.tls.connection_initial_timeout_ms" => Ok(Box::new(
|
||||
inner.core.network.tls.connection_initial_timeout_ms,
|
||||
)),
|
||||
"network.application.https.enabled" => {
|
||||
Ok(Box::new(inner.core.network.application.https.enabled))
|
||||
}
|
||||
@ -1139,7 +1139,7 @@ mod tests {
|
||||
assert_eq!(s.core.protected_store.delete, false);
|
||||
|
||||
assert_eq!(s.core.network.max_connections, 16);
|
||||
assert_eq!(s.core.network.connection_initial_timeout, 2_000_000u64);
|
||||
assert_eq!(s.core.network.connection_initial_timeout_ms, 2_000u32);
|
||||
assert_eq!(s.core.network.node_id, veilid_core::DHTKey::default());
|
||||
assert_eq!(
|
||||
s.core.network.node_id_secret,
|
||||
@ -1150,26 +1150,26 @@ mod tests {
|
||||
//
|
||||
assert_eq!(s.core.network.rpc.concurrency, 0);
|
||||
assert_eq!(s.core.network.rpc.queue_size, 1024);
|
||||
assert_eq!(s.core.network.rpc.max_timestamp_behind, Some(10_000_000u64));
|
||||
assert_eq!(s.core.network.rpc.max_timestamp_ahead, Some(10_000_000u64));
|
||||
assert_eq!(s.core.network.rpc.timeout, 10000000);
|
||||
assert_eq!(s.core.network.rpc.max_timestamp_behind_ms, Some(10_000u32));
|
||||
assert_eq!(s.core.network.rpc.max_timestamp_ahead_ms, Some(10_000u32));
|
||||
assert_eq!(s.core.network.rpc.timeout_ms, 10_000u32);
|
||||
assert_eq!(s.core.network.rpc.max_route_hop_count, 7);
|
||||
//
|
||||
assert_eq!(s.core.network.dht.resolve_node_timeout, None);
|
||||
assert_eq!(s.core.network.dht.resolve_node_timeout_ms, None);
|
||||
assert_eq!(s.core.network.dht.resolve_node_count, 20u32);
|
||||
assert_eq!(s.core.network.dht.resolve_node_fanout, 3u32);
|
||||
assert_eq!(s.core.network.dht.max_find_node_count, 20u32);
|
||||
assert_eq!(s.core.network.dht.get_value_timeout, None);
|
||||
assert_eq!(s.core.network.dht.get_value_timeout_ms, None);
|
||||
assert_eq!(s.core.network.dht.get_value_count, 20u32);
|
||||
assert_eq!(s.core.network.dht.get_value_fanout, 3u32);
|
||||
assert_eq!(s.core.network.dht.set_value_timeout, None);
|
||||
assert_eq!(s.core.network.dht.set_value_timeout_ms, None);
|
||||
assert_eq!(s.core.network.dht.set_value_count, 20u32);
|
||||
assert_eq!(s.core.network.dht.set_value_fanout, 5u32);
|
||||
assert_eq!(s.core.network.dht.min_peer_count, 20u32);
|
||||
assert_eq!(s.core.network.dht.min_peer_refresh_time, 2000000u64);
|
||||
assert_eq!(s.core.network.dht.min_peer_refresh_time_ms, 2_000u32);
|
||||
assert_eq!(
|
||||
s.core.network.dht.validate_dial_info_receipt_time,
|
||||
5000000u64
|
||||
s.core.network.dht.validate_dial_info_receipt_time_ms,
|
||||
5_000u32
|
||||
);
|
||||
//
|
||||
assert_eq!(s.core.network.upnp, false);
|
||||
@ -1185,7 +1185,7 @@ mod tests {
|
||||
s.core.network.tls.private_key_path,
|
||||
std::path::PathBuf::from("/etc/veilid/private/server.key")
|
||||
);
|
||||
assert_eq!(s.core.network.tls.connection_initial_timeout, 2_000_000u64);
|
||||
assert_eq!(s.core.network.tls.connection_initial_timeout_ms, 2_000u32);
|
||||
//
|
||||
assert_eq!(s.core.network.application.https.enabled, false);
|
||||
assert_eq!(
|
||||
|
Loading…
Reference in New Issue
Block a user