From 98799b4d3a814c871cf13a758959513086cdb68e Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 3 Mar 2022 20:45:39 -0500 Subject: [PATCH] sync --- Cargo.lock | 1 + veilid-core/src/core_context.rs | 2 +- veilid-core/src/lib.rs | 3 + veilid-flutter/android/build.gradle | 2 +- .../kotlin/com/veilid/veilid/VeilidPlugin.kt | 8 +- veilid-flutter/example/android/build.gradle | 2 +- veilid-flutter/example/lib/config.dart | 125 ++++++++++++++ veilid-flutter/example/lib/main.dart | 156 ++++++++++++------ .../Flutter/GeneratedPluginRegistrant.swift | 2 + veilid-flutter/example/pubspec.lock | 118 ++++++++++--- veilid-flutter/example/pubspec.yaml | 4 +- veilid-flutter/lib/veilid.dart | 2 +- veilid-flutter/lib/veilid_ffi.dart | 17 +- veilid-flutter/lib/veilid_js.dart | 11 ++ veilid-flutter/linux/rust.cmake | 3 +- veilid-flutter/pubspec.yaml | 2 + veilid-flutter/rust/Cargo.toml | 4 + veilid-flutter/rust/src/lib.rs | 2 +- veilid-flutter/test/veilid_test.dart | 1 - veilid-server/src/settings.rs | 96 +++++------ 20 files changed, 426 insertions(+), 135 deletions(-) create mode 100644 veilid-flutter/example/lib/config.dart diff --git a/Cargo.lock b/Cargo.lock index 30c41ac7..8ab4ed3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3954,6 +3954,7 @@ dependencies = [ "console_error_panic_hook", "ffi-support", "futures", + "jni", "js-sys", "lazy_static", "log", diff --git a/veilid-core/src/core_context.rs b/veilid-core/src/core_context.rs index f045c456..a330ce37 100644 --- a/veilid-core/src/core_context.rs +++ b/veilid-core/src/core_context.rs @@ -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() }); } } } diff --git a/veilid-core/src/lib.rs b/veilid-core/src/lib.rs index 07bd575d..fc00509b 100644 --- a/veilid-core/src/lib.rs +++ b/veilid-core/src/lib.rs @@ -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", diff --git a/veilid-flutter/android/build.gradle b/veilid-flutter/android/build.gradle index 8e787d30..084e79e8 100644 --- a/veilid-flutter/android/build.gradle +++ b/veilid-flutter/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.4.32' repositories { google() mavenCentral() diff --git a/veilid-flutter/android/src/main/kotlin/com/veilid/veilid/VeilidPlugin.kt b/veilid-flutter/android/src/main/kotlin/com/veilid/veilid/VeilidPlugin.kt index 87455977..1d5995da 100644 --- a/veilid-flutter/android/src/main/kotlin/com/veilid/veilid/VeilidPlugin.kt +++ b/veilid-flutter/android/src/main/kotlin/com/veilid/veilid/VeilidPlugin.kt @@ -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()) diff --git a/veilid-flutter/example/android/build.gradle b/veilid-flutter/example/android/build.gradle index 24047dce..10ab8e50 100644 --- a/veilid-flutter/example/android/build.gradle +++ b/veilid-flutter/example/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.4.32' repositories { google() mavenCentral() diff --git a/veilid-flutter/example/lib/config.dart b/veilid-flutter/example/lib/config.dart new file mode 100644 index 00000000..40c2c3f8 --- /dev/null +++ b/veilid-flutter/example/lib/config.dart @@ -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 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, + )), + ); +} diff --git a/veilid-flutter/example/lib/main.dart b/veilid-flutter/example/lib/main.dart index d3b874fe..fad65daf 100644 --- a/veilid-flutter/example/lib/main.dart +++ b/veilid-flutter/example/lib/main.dart @@ -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 createState() => _MyAppState(); } -class _MyAppState extends State { +class _MyAppState extends State with UiLoggy { String _veilidVersion = 'Unknown'; + Stream? _updateStream; @override void initState() { @@ -75,10 +79,11 @@ class _MyAppState extends State { } 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 { @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( + value: loggy.level.logLevel, + onChanged: (LogLevel? newLevel) { + setState(() { + setRootLogLevel(newLevel); + }); + }, + items: const [ + DropdownMenuItem( + value: LogLevel.error, child: Text("Error")), + DropdownMenuItem( + value: LogLevel.warning, child: Text("Warning")), + DropdownMenuItem( + value: LogLevel.info, child: Text("Info")), + DropdownMenuItem( + value: LogLevel.debug, child: Text("Debug")), + DropdownMenuItem( + value: traceLevel, child: Text("Trace")), + DropdownMenuItem( + value: LogLevel.all, child: Text("All")), + ]) + ]), + ])); } } diff --git a/veilid-flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift b/veilid-flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift index 4b2cd419..5c63c74b 100644 --- a/veilid-flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/veilid-flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -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")) } diff --git a/veilid-flutter/example/pubspec.lock b/veilid-flutter/example/pubspec.lock index 7a96f434..e36702f1 100644 --- a/veilid-flutter/example/pubspec.lock +++ b/veilid-flutter/example/pubspec.lock @@ -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" diff --git a/veilid-flutter/example/pubspec.yaml b/veilid-flutter/example/pubspec.yaml index b55968f0..62dfa08d 100644 --- a/veilid-flutter/example/pubspec.yaml +++ b/veilid-flutter/example/pubspec.yaml @@ -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: diff --git a/veilid-flutter/lib/veilid.dart b/veilid-flutter/lib/veilid.dart index 8e2ab46e..a8c09209 100644 --- a/veilid-flutter/lib/veilid.dart +++ b/veilid-flutter/lib/veilid.dart @@ -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 getVeilidState(); Future changeApiLogLevel(VeilidConfigLogLevel logLevel); Future shutdownVeilidCore(); + Future debug(String command); String veilidVersionString(); VeilidVersion veilidVersion(); } diff --git a/veilid-flutter/lib/veilid_ffi.dart b/veilid-flutter/lib/veilid_ffi.dart index 667c547d..a36bb74c 100644 --- a/veilid-flutter/lib/veilid_ffi.dart +++ b/veilid-flutter/lib/veilid_ffi.dart @@ -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); typedef _ChangeApiLogLevelDart = void Function(int, Pointer); +// fn debug(port: i64, log_level: FfiStr) +typedef _DebugC = Void Function(Int64, Pointer); +typedef _DebugDart = void Function(int, Pointer); // 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 processFuturePlain( - T Function(Map)? jsonConstructor, Future future) { +Future processFuturePlain(Future future) { return future.then((value) { final list = value as List; 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 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(); diff --git a/veilid-flutter/lib/veilid_js.dart b/veilid-flutter/lib/veilid_js.dart index 7bd00945..5f3da651 100644 --- a/veilid-flutter/lib/veilid_js.dart +++ b/veilid-flutter/lib/veilid_js.dart @@ -9,26 +9,37 @@ import 'dart:typed_data'; Veilid getVeilid() => VeilidJS(); class VeilidJS implements Veilid { + @override Stream startupVeilidCore(VeilidConfig config) { throw UnimplementedError(); } + @override Future getVeilidState() { throw UnimplementedError(); } + @override Future changeApiLogLevel(VeilidConfigLogLevel logLevel) { throw UnimplementedError(); } + @override Future shutdownVeilidCore() { throw UnimplementedError(); } + @override + Future debug(String command) { + throw UnimplementedError(); + } + + @override String veilidVersionString() { throw UnimplementedError(); } + @override VeilidVersion veilidVersion() { throw UnimplementedError(); } diff --git a/veilid-flutter/linux/rust.cmake b/veilid-flutter/linux/rust.cmake index 141fe937..4ca71b16 100644 --- a/veilid-flutter/linux/rust.cmake +++ b/veilid-flutter/linux/rust.cmake @@ -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 $) \ No newline at end of file diff --git a/veilid-flutter/pubspec.yaml b/veilid-flutter/pubspec.yaml index 994ea6d7..c4b48d84 100644 --- a/veilid-flutter/pubspec.yaml +++ b/veilid-flutter/pubspec.yaml @@ -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: diff --git a/veilid-flutter/rust/Cargo.toml b/veilid-flutter/rust/Cargo.toml index 66c15ee7..1defa3a8 100644 --- a/veilid-flutter/rust/Cargo.toml +++ b/veilid-flutter/rust/Cargo.toml @@ -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" diff --git a/veilid-flutter/rust/src/lib.rs b/veilid-flutter/rust/src/lib.rs index 439927e0..ef3f0452 100644 --- a/veilid-flutter/rust/src/lib.rs +++ b/veilid-flutter/rust/src/lib.rs @@ -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); } diff --git a/veilid-flutter/test/veilid_test.dart b/veilid-flutter/test/veilid_test.dart index 846c0441..659ebb1d 100644 --- a/veilid-flutter/test/veilid_test.dart +++ b/veilid-flutter/test/veilid_test.dart @@ -1,4 +1,3 @@ -import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:veilid/veilid.dart'; diff --git a/veilid-server/src/settings.rs b/veilid-server/src/settings.rs index 2f44eb8d..1295f1be 100644 --- a/veilid-server/src/settings.rs +++ b/veilid-server/src/settings.rs @@ -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, - pub max_timestamp_ahead: Option, - pub timeout: u64, + pub max_timestamp_behind_ms: Option, + pub max_timestamp_ahead_ms: Option, + pub timeout_ms: u32, pub max_route_hop_count: u8, } #[derive(Debug, Deserialize, Serialize)] pub struct Dht { - pub resolve_node_timeout: Option, + pub resolve_node_timeout_ms: Option, pub resolve_node_count: u32, pub resolve_node_fanout: u32, pub max_find_node_count: u32, - pub get_value_timeout: Option, + pub get_value_timeout_ms: Option, pub get_value_count: u32, pub get_value_fanout: u32, - pub set_value_timeout: Option, + pub set_value_timeout_ms: Option, 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, @@ -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!(