diff --git a/veilid-core/src/network_manager/mod.rs b/veilid-core/src/network_manager/mod.rs index 8bd6012b..923c6ea3 100644 --- a/veilid-core/src/network_manager/mod.rs +++ b/veilid-core/src/network_manager/mod.rs @@ -1514,6 +1514,7 @@ impl NetworkManager { bps_down: 0.into(), bps_up: 0.into(), peers: Vec::new(), + }; } let routing_table = self.routing_table(); diff --git a/veilid-core/src/routing_table/mod.rs b/veilid-core/src/routing_table/mod.rs index 054bbc6d..2a09e875 100644 --- a/veilid-core/src/routing_table/mod.rs +++ b/veilid-core/src/routing_table/mod.rs @@ -59,6 +59,10 @@ pub struct RoutingTableHealth { pub unreliable_entry_count: usize, /// Number of dead (always unresponsive) entries in the routing table pub dead_entry_count: usize, + /// If PublicInternet network class is valid yet + pub public_internet_network_class_valid: bool, xxx do this and add to attachment calculation + /// If LocalNetwork network class is valid yet + pub local_network_network_class_valid: bool, } pub(super) struct RoutingTableUnlockedInner { diff --git a/veilid-flutter/example/lib/app.dart b/veilid-flutter/example/lib/app.dart index 3c9e7fbb..4cb9dfbc 100644 --- a/veilid-flutter/example/lib/app.dart +++ b/veilid-flutter/example/lib/app.dart @@ -7,7 +7,6 @@ import 'package:loggy/loggy.dart'; import 'package:veilid_example/veilid_theme.dart'; import 'log_terminal.dart'; -import 'config.dart'; import 'log.dart'; import 'history_wrapper.dart'; @@ -110,8 +109,8 @@ class _MyAppState extends State with UiLoggy { Future toggleStartup(bool startup) async { if (startup && !_startedUp) { - var updateStream = await Veilid.instance - .startupVeilidCore(await getDefaultVeilidConfig()); + var updateStream = await Veilid.instance.startupVeilidCore( + await getDefaultVeilidConfig("Veilid Plugin Example")); setState(() { _updateStream = updateStream; _updateProcessor = processUpdates(); diff --git a/veilid-flutter/example/lib/config.dart b/veilid-flutter/example/lib/config.dart deleted file mode 100644 index 92020d68..00000000 --- a/veilid-flutter/example/lib/config.dart +++ /dev/null @@ -1,140 +0,0 @@ -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: "", - 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: kIsWeb - ? "" - : p.join((await getApplicationSupportDirectory()).absolute.path, - "table_store"), - delete: false, - ), - blockStore: VeilidConfigBlockStore( - directory: kIsWeb - ? "" - : p.join((await getApplicationSupportDirectory()).absolute.path, - "block_store"), - delete: false, - ), - network: VeilidConfigNetwork( - connectionInitialTimeoutMs: 2000, - connectionInactivityTimeoutMs: 60000, - maxConnectionsPerIp4: 32, - maxConnectionsPerIp6Prefix: 32, - maxConnectionsPerIp6PrefixSize: 56, - maxConnectionFrequencyPerMin: 128, - clientWhitelistTimeoutMs: 300000, - reverseConnectionReceiptTimeMs: 5000, - holePunchReceiptTimeMs: 5000, - nodeId: null, - nodeIdSecret: null, - bootstrap: kIsWeb - ? ["ws://bootstrap.dev.veilid.net:5150/ws"] - : ["bootstrap.dev.veilid.net"], - bootstrapNodes: [], - routingTable: VeilidConfigRoutingTable( - limitOverAttached: 64, - limitFullyAttached: 32, - limitAttachedStrong: 16, - limitAttachedGood: 8, - limitAttachedWeak: 4, - ), - rpc: VeilidConfigRPC( - concurrency: 0, - queueSize: 1024, - maxTimestampBehindMs: 10000, - maxTimestampAheadMs: 10000, - timeoutMs: 10000, - maxRouteHopCount: 4, - defaultRouteHopCount: 1, - ), - 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: 2000, - ), - upnp: true, - detectAddressChanges: true, - restrictedNatRetries: 0, - 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: "", - publicAddress: null, - ), - tcp: VeilidConfigTCP( - connect: !kIsWeb, - listen: !kIsWeb, - maxConnections: 32, - listenAddress: "", - publicAddress: null, - ), - ws: VeilidConfigWS( - connect: true, - listen: !kIsWeb, - maxConnections: 16, - listenAddress: "", - path: "ws", - url: null, - ), - wss: VeilidConfigWSS( - connect: true, - listen: false, - maxConnections: 16, - listenAddress: "", - path: "ws", - url: null, - ), - ), - ), - ); -} diff --git a/veilid-flutter/example/lib/platform_menu.dart b/veilid-flutter/example/lib/platform_menu.dart deleted file mode 100644 index db55916a..00000000 --- a/veilid-flutter/example/lib/platform_menu.dart +++ /dev/null @@ -1,149 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; - -class AppPlatformMenu extends StatefulWidget { - const AppPlatformMenu({super.key, required this.child}); - - final Widget child; - - @override - State createState() => _AppPlatformMenuState(); -} - -class _AppPlatformMenuState extends State { - @override - Widget build(BuildContext context) { - if (defaultTargetPlatform != TargetPlatform.macOS) { - return widget.child; - } - - return PlatformMenuBar( - menus: [ - PlatformMenu( - label: 'TerminalStudio', - menus: [ - if (PlatformProvidedMenuItem.hasMenu( - PlatformProvidedMenuItemType.about, - )) - const PlatformProvidedMenuItem( - type: PlatformProvidedMenuItemType.about, - ), - PlatformMenuItemGroup( - members: [ - if (PlatformProvidedMenuItem.hasMenu( - PlatformProvidedMenuItemType.servicesSubmenu, - )) - const PlatformProvidedMenuItem( - type: PlatformProvidedMenuItemType.servicesSubmenu, - ), - ], - ), - PlatformMenuItemGroup( - members: [ - if (PlatformProvidedMenuItem.hasMenu( - PlatformProvidedMenuItemType.hide, - )) - const PlatformProvidedMenuItem( - type: PlatformProvidedMenuItemType.hide, - ), - if (PlatformProvidedMenuItem.hasMenu( - PlatformProvidedMenuItemType.hideOtherApplications, - )) - const PlatformProvidedMenuItem( - type: PlatformProvidedMenuItemType.hideOtherApplications, - ), - ], - ), - if (PlatformProvidedMenuItem.hasMenu( - PlatformProvidedMenuItemType.quit, - )) - const PlatformProvidedMenuItem( - type: PlatformProvidedMenuItemType.quit, - ), - ], - ), - PlatformMenu( - label: 'Edit', - menus: [ - PlatformMenuItemGroup( - members: [ - PlatformMenuItem( - label: 'Copy', - shortcut: const SingleActivator( - LogicalKeyboardKey.keyC, - meta: true, - ), - onSelected: () { - final primaryContext = primaryFocus?.context; - if (primaryContext == null) { - return; - } - Actions.invoke( - primaryContext, - CopySelectionTextIntent.copy, - ); - }, - ), - PlatformMenuItem( - label: 'Paste', - shortcut: const SingleActivator( - LogicalKeyboardKey.keyV, - meta: true, - ), - onSelected: () { - final primaryContext = primaryFocus?.context; - if (primaryContext == null) { - return; - } - Actions.invoke( - primaryContext, - const PasteTextIntent(SelectionChangedCause.keyboard), - ); - }, - ), - PlatformMenuItem( - label: 'Select All', - shortcut: const SingleActivator( - LogicalKeyboardKey.keyA, - meta: true, - ), - onSelected: () { - final primaryContext = primaryFocus?.context; - if (primaryContext == null) { - return; - } - print(primaryContext); - try { - final action = Actions.maybeFind( - primaryContext, - intent: const SelectAllTextIntent( - SelectionChangedCause.keyboard, - ), - ); - print('action: $action'); - } catch (e) { - print(e); - } - Actions.invoke( - primaryContext, - const SelectAllTextIntent(SelectionChangedCause.keyboard), - ); - }, - ), - ], - ), - if (PlatformProvidedMenuItem.hasMenu( - PlatformProvidedMenuItemType.quit, - )) - const PlatformProvidedMenuItem( - type: PlatformProvidedMenuItemType.quit, - ), - ], - ), - ], - child: widget.child, - ); - } -} diff --git a/veilid-flutter/example/lib/virtual_keyboard.dart b/veilid-flutter/example/lib/virtual_keyboard.dart deleted file mode 100644 index 5625e2c7..00000000 --- a/veilid-flutter/example/lib/virtual_keyboard.dart +++ /dev/null @@ -1,80 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:xterm/xterm.dart'; - -class VirtualKeyboardView extends StatelessWidget { - const VirtualKeyboardView(this.keyboard, {super.key}); - - final VirtualKeyboard keyboard; - - @override - Widget build(BuildContext context) { - return AnimatedBuilder( - animation: keyboard, - builder: (context, child) => ToggleButtons( - isSelected: [keyboard.ctrl, keyboard.alt, keyboard.shift], - onPressed: (index) { - switch (index) { - case 0: - keyboard.ctrl = !keyboard.ctrl; - break; - case 1: - keyboard.alt = !keyboard.alt; - break; - case 2: - keyboard.shift = !keyboard.shift; - break; - } - }, - children: const [Text('Ctrl'), Text('Alt'), Text('Shift')], - ), - ); - } -} - -class VirtualKeyboard extends TerminalInputHandler with ChangeNotifier { - final TerminalInputHandler _inputHandler; - - VirtualKeyboard(this._inputHandler); - - bool _ctrl = false; - - bool get ctrl => _ctrl; - - set ctrl(bool value) { - if (_ctrl != value) { - _ctrl = value; - notifyListeners(); - } - } - - bool _shift = false; - - bool get shift => _shift; - - set shift(bool value) { - if (_shift != value) { - _shift = value; - notifyListeners(); - } - } - - bool _alt = false; - - bool get alt => _alt; - - set alt(bool value) { - if (_alt != value) { - _alt = value; - notifyListeners(); - } - } - - @override - String? call(TerminalKeyboardEvent event) { - return _inputHandler.call(event.copyWith( - ctrl: event.ctrl || _ctrl, - shift: event.shift || _shift, - alt: event.alt || _alt, - )); - } -} diff --git a/veilid-flutter/lib/veilid.dart b/veilid-flutter/lib/veilid.dart index 57598885..8171afe6 100644 --- a/veilid-flutter/lib/veilid.dart +++ b/veilid-flutter/lib/veilid.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:html'; import 'dart:typed_data'; import 'dart:convert'; @@ -11,6 +10,8 @@ import 'veilid_stub.dart' ////////////////////////////////////////////////////////// +export 'default_config.dart'; + ////////////////////////////////////////////////////////// // FFI Platform-specific config