diff --git a/veilid-core/src/network_manager/wasm/protocol/ws.rs b/veilid-core/src/network_manager/wasm/protocol/ws.rs index 0315d3e5..56082a86 100644 --- a/veilid-core/src/network_manager/wasm/protocol/ws.rs +++ b/veilid-core/src/network_manager/wasm/protocol/ws.rs @@ -11,12 +11,20 @@ struct WebsocketNetworkConnectionInner { fn to_io(err: WsErr) -> io::Error { match err { - WsErr::InvalidWsState { supplied: _ } => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()), + WsErr::InvalidWsState { supplied: _ } => { + io::Error::new(io::ErrorKind::InvalidInput, err.to_string()) + } WsErr::ConnectionNotOpen => io::Error::new(io::ErrorKind::NotConnected, err.to_string()), - WsErr::InvalidUrl { supplied: _ } => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()), - WsErr::InvalidCloseCode { supplied: _ } => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()), + WsErr::InvalidUrl { supplied: _ } => { + io::Error::new(io::ErrorKind::InvalidInput, err.to_string()) + } + WsErr::InvalidCloseCode { supplied: _ } => { + io::Error::new(io::ErrorKind::InvalidInput, err.to_string()) + } WsErr::ReasonStringToLong => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()), - WsErr::ConnectionFailed { event: _ } => io::Error::new(io::ErrorKind::ConnectionRefused, err.to_string()), + WsErr::ConnectionFailed { event: _ } => { + io::Error::new(io::ErrorKind::ConnectionRefused, err.to_string()) + } WsErr::InvalidEncoding => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()), WsErr::CantDecodeBlob => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()), WsErr::UnknownDataType => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()), @@ -80,19 +88,19 @@ impl WebsocketNetworkConnection { let out = match SendWrapper::new(self.inner.ws_stream.clone().next()).await { Some(WsMessage::Binary(v)) => { if v.len() > MAX_MESSAGE_SIZE { - return Err(io::Error::new( - io::ErrorKind::InvalidData, - "too large ws message", - )); + return Ok(NetworkResult::invalid_message("too large ws message")); } NetworkResult::Value(v) } - Some(_) => NetworkResult::NoConnection(io::Error::new( + Some(_) => NetworkResult::no_connection_other(io::Error::new( io::ErrorKind::ConnectionReset, "Unexpected WS message type", )), None => { - bail_io_error_other!("WS stream closed"); + return Ok(NetworkResult::no_connection(io::Error::new( + io::ErrorKind::ConnectionReset, + "WS stream closed", + ))); } }; // tracing::Span::current().record("network_result", &tracing::field::display(&out)); @@ -126,7 +134,7 @@ impl WebsocketProtocolHandler { let fut = SendWrapper::new(timeout(timeout_ms, async move { WsMeta::connect(request, None).await.map_err(to_io) })); - + let (wsmeta, wsio) = network_result_try!(network_result_try!(fut .await .into_network_result()) diff --git a/veilid-core/src/routing_table/route_spec_store.rs b/veilid-core/src/routing_table/route_spec_store.rs index 4dea0c30..5f7d1b64 100644 --- a/veilid-core/src/routing_table/route_spec_store.rs +++ b/veilid-core/src/routing_table/route_spec_store.rs @@ -1087,7 +1087,7 @@ impl RouteSpecStore { && detail.1.sequencing >= sequencing && detail.1.hops.len() >= min_hop_count && detail.1.hops.len() <= max_hop_count - && detail.1.directions.is_subset(directions) + && detail.1.directions.is_superset(directions) && !detail.1.published && !detail.1.stats.needs_testing(cur_ts) { @@ -1742,6 +1742,11 @@ impl RouteSpecStore { F: FnOnce(&mut RouteStats) -> R, { let inner = &mut *self.inner.lock(); + + // Check for stub route + if *key == self.unlocked_inner.routing_table.node_id() { + return None; + } // Check for local route if let Some(rsd) = Self::detail_mut(inner, key) { return Some(f(&mut rsd.stats)); diff --git a/veilid-core/src/veilid_api/debug.rs b/veilid-core/src/veilid_api/debug.rs index 626f2860..23aca13e 100644 --- a/veilid-core/src/veilid_api/debug.rs +++ b/veilid-core/src/veilid_api/debug.rs @@ -701,10 +701,17 @@ impl VeilidAPI { let rss = routing_table.route_spec_store(); let routes = rss.list_allocated_routes(|k, _| Some(*k)); - let mut out = format!("Routes: (count = {}):\n", routes.len()); + let mut out = format!("Allocated Routes: (count = {}):\n", routes.len()); for r in routes { out.push_str(&format!("{}\n", r.encode())); } + + let remote_routes = rss.list_remote_routes(|k, _| Some(*k)); + let mut out = format!("Remote Routes: (count = {}):\n", remote_routes.len()); + for r in remote_routes { + out.push_str(&format!("{}\n", r.encode())); + } + Ok(out) } async fn debug_route_import(&self, args: Vec) -> Result { @@ -858,9 +865,9 @@ impl VeilidAPI { Ok(">>> Unknown command\n".to_owned()) } }; - if let Ok(res) = &res { - debug!("{}", res); - } + // if let Ok(res) = &res { + // debug!("{}", res); + // } res } } diff --git a/veilid-flutter/example/fonts/FiraCode-VF.ttf b/veilid-flutter/example/fonts/FiraCode-VF.ttf new file mode 100644 index 00000000..fd594139 Binary files /dev/null and b/veilid-flutter/example/fonts/FiraCode-VF.ttf differ diff --git a/veilid-flutter/example/fonts/Fraunces-Italic-VariableFont_SOFT,WONK,opsz,wght.ttf b/veilid-flutter/example/fonts/Fraunces-Italic-VariableFont_SOFT,WONK,opsz,wght.ttf new file mode 100644 index 00000000..970ddc39 Binary files /dev/null and b/veilid-flutter/example/fonts/Fraunces-Italic-VariableFont_SOFT,WONK,opsz,wght.ttf differ diff --git a/veilid-flutter/example/fonts/Fraunces-VariableFont_SOFT,WONK,opsz,wght.ttf b/veilid-flutter/example/fonts/Fraunces-VariableFont_SOFT,WONK,opsz,wght.ttf new file mode 100644 index 00000000..112bfa8a Binary files /dev/null and b/veilid-flutter/example/fonts/Fraunces-VariableFont_SOFT,WONK,opsz,wght.ttf differ diff --git a/veilid-flutter/example/lib/log_terminal.dart b/veilid-flutter/example/lib/log_terminal.dart index cf33c1e0..b19d4af6 100644 --- a/veilid-flutter/example/lib/log_terminal.dart +++ b/veilid-flutter/example/lib/log_terminal.dart @@ -42,7 +42,7 @@ class _LogTerminalState extends State { textStyle: kDefaultTerminalStyle, controller: terminalController, autofocus: true, - backgroundOpacity: 0.7, + backgroundOpacity: 0.9, onSecondaryTapDown: (details, offset) async { final selection = terminalController.selection; if (selection != null) { diff --git a/veilid-flutter/example/lib/veilid_init.dart b/veilid-flutter/example/lib/veilid_init.dart index 373ea012..7d0f8fb3 100644 --- a/veilid-flutter/example/lib/veilid_init.dart +++ b/veilid-flutter/example/lib/veilid_init.dart @@ -11,7 +11,7 @@ void veilidInit() { enabled: true, level: VeilidConfigLogLevel.debug, logsInTimings: true, - logsInConsole: true), + logsInConsole: false), api: VeilidWASMConfigLoggingApi( enabled: true, level: VeilidConfigLogLevel.info))); Veilid.instance.initializeVeilidCore(platformConfig.json); diff --git a/veilid-flutter/example/lib/veilid_theme.dart b/veilid-flutter/example/lib/veilid_theme.dart index ef7b5b0a..eab7564e 100644 --- a/veilid-flutter/example/lib/veilid_theme.dart +++ b/veilid-flutter/example/lib/veilid_theme.dart @@ -241,7 +241,7 @@ const MaterialColor materialPopComplementaryColor = const kDefaultSpacingFactor = 4.0; -const kDefaultMonoTerminalFontFamily = "CascadiaMonoPL.ttf"; +const kDefaultMonoTerminalFontFamily = "Fira Code"; const kDefaultMonoTerminalFontHeight = 1.2; const kDefaultMonoTerminalFontSize = 12.0; diff --git a/veilid-flutter/example/pubspec.yaml b/veilid-flutter/example/pubspec.yaml index fee9152c..a781e59b 100644 --- a/veilid-flutter/example/pubspec.yaml +++ b/veilid-flutter/example/pubspec.yaml @@ -94,3 +94,11 @@ flutter: - family: Cascadia Mono fonts: - asset: fonts/CascadiaMonoPL.ttf + - family: Fira Code + fonts: + - asset: fonts/FiraCode-VF.ttf + - family: Fraunces + fonts: + - asset: fonts/Fraunces-VariableFont_SOFT,WONK,opsz,wght.ttf + - asset: fonts/Fraunces-Italic-VariableFont_SOFT,WONK,opsz,wght.ttf + style: italic \ No newline at end of file diff --git a/veilid-flutter/example/web/index.html b/veilid-flutter/example/web/index.html index fe1c65dc..128d80a0 100644 --- a/veilid-flutter/example/web/index.html +++ b/veilid-flutter/example/web/index.html @@ -1,5 +1,6 @@ + - + - veilid_example + Veilid Example + + + + + - + - + - + + \ No newline at end of file diff --git a/veilid-flutter/lib/veilid.dart b/veilid-flutter/lib/veilid.dart index 9b194c02..a46993ca 100644 --- a/veilid-flutter/lib/veilid.dart +++ b/veilid-flutter/lib/veilid.dart @@ -1474,11 +1474,15 @@ class VeilidStateRoute { }); VeilidStateRoute.fromJson(Map json) - : deadRoutes = json['dead_routes'], - deadRemoteRoutes = json['dead_remote_routes']; + : deadRoutes = List.from(json['dead_routes'].map((j) => j)), + deadRemoteRoutes = + List.from(json['dead_remote_routes'].map((j) => j)); Map get json { - return {'dead_routes': deadRoutes, 'dead_remote_routes': deadRemoteRoutes}; + return { + 'dead_routes': deadRoutes.map((p) => p).toList(), + 'dead_remote_routes': deadRemoteRoutes.map((p) => p).toList() + }; } } diff --git a/veilid-flutter/lib/veilid_js.dart b/veilid-flutter/lib/veilid_js.dart index 5beff613..d19ce2a3 100644 --- a/veilid-flutter/lib/veilid_js.dart +++ b/veilid-flutter/lib/veilid_js.dart @@ -185,8 +185,9 @@ class VeilidJS implements Veilid { } @override - Future debug(String command) { - return _wrapApiPromise(js_util.callMethod(wasm, "debug", [command])); + Future debug(String command) async { + return jsonDecode( + await _wrapApiPromise(js_util.callMethod(wasm, "debug", [command]))); } @override