mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-12-24 23:09:25 -05:00
route fixes
This commit is contained in:
parent
36b6e7446f
commit
2e1920b626
@ -11,12 +11,20 @@ struct WebsocketNetworkConnectionInner {
|
|||||||
|
|
||||||
fn to_io(err: WsErr) -> io::Error {
|
fn to_io(err: WsErr) -> io::Error {
|
||||||
match err {
|
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::ConnectionNotOpen => io::Error::new(io::ErrorKind::NotConnected, err.to_string()),
|
||||||
WsErr::InvalidUrl { supplied: _ } => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()),
|
WsErr::InvalidUrl { supplied: _ } => {
|
||||||
WsErr::InvalidCloseCode { supplied: _ } => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()),
|
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::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::InvalidEncoding => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()),
|
||||||
WsErr::CantDecodeBlob => 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()),
|
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 {
|
let out = match SendWrapper::new(self.inner.ws_stream.clone().next()).await {
|
||||||
Some(WsMessage::Binary(v)) => {
|
Some(WsMessage::Binary(v)) => {
|
||||||
if v.len() > MAX_MESSAGE_SIZE {
|
if v.len() > MAX_MESSAGE_SIZE {
|
||||||
return Err(io::Error::new(
|
return Ok(NetworkResult::invalid_message("too large ws message"));
|
||||||
io::ErrorKind::InvalidData,
|
|
||||||
"too large ws message",
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
NetworkResult::Value(v)
|
NetworkResult::Value(v)
|
||||||
}
|
}
|
||||||
Some(_) => NetworkResult::NoConnection(io::Error::new(
|
Some(_) => NetworkResult::no_connection_other(io::Error::new(
|
||||||
io::ErrorKind::ConnectionReset,
|
io::ErrorKind::ConnectionReset,
|
||||||
"Unexpected WS message type",
|
"Unexpected WS message type",
|
||||||
)),
|
)),
|
||||||
None => {
|
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));
|
// tracing::Span::current().record("network_result", &tracing::field::display(&out));
|
||||||
|
@ -1087,7 +1087,7 @@ impl RouteSpecStore {
|
|||||||
&& detail.1.sequencing >= sequencing
|
&& detail.1.sequencing >= sequencing
|
||||||
&& detail.1.hops.len() >= min_hop_count
|
&& detail.1.hops.len() >= min_hop_count
|
||||||
&& detail.1.hops.len() <= max_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.published
|
||||||
&& !detail.1.stats.needs_testing(cur_ts)
|
&& !detail.1.stats.needs_testing(cur_ts)
|
||||||
{
|
{
|
||||||
@ -1742,6 +1742,11 @@ impl RouteSpecStore {
|
|||||||
F: FnOnce(&mut RouteStats) -> R,
|
F: FnOnce(&mut RouteStats) -> R,
|
||||||
{
|
{
|
||||||
let inner = &mut *self.inner.lock();
|
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
|
// Check for local route
|
||||||
if let Some(rsd) = Self::detail_mut(inner, key) {
|
if let Some(rsd) = Self::detail_mut(inner, key) {
|
||||||
return Some(f(&mut rsd.stats));
|
return Some(f(&mut rsd.stats));
|
||||||
|
@ -701,10 +701,17 @@ impl VeilidAPI {
|
|||||||
let rss = routing_table.route_spec_store();
|
let rss = routing_table.route_spec_store();
|
||||||
|
|
||||||
let routes = rss.list_allocated_routes(|k, _| Some(*k));
|
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 {
|
for r in routes {
|
||||||
out.push_str(&format!("{}\n", r.encode()));
|
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)
|
Ok(out)
|
||||||
}
|
}
|
||||||
async fn debug_route_import(&self, args: Vec<String>) -> Result<String, VeilidAPIError> {
|
async fn debug_route_import(&self, args: Vec<String>) -> Result<String, VeilidAPIError> {
|
||||||
@ -858,9 +865,9 @@ impl VeilidAPI {
|
|||||||
Ok(">>> Unknown command\n".to_owned())
|
Ok(">>> Unknown command\n".to_owned())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if let Ok(res) = &res {
|
// if let Ok(res) = &res {
|
||||||
debug!("{}", res);
|
// debug!("{}", res);
|
||||||
}
|
// }
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
veilid-flutter/example/fonts/FiraCode-VF.ttf
Normal file
BIN
veilid-flutter/example/fonts/FiraCode-VF.ttf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -42,7 +42,7 @@ class _LogTerminalState extends State<LogTerminal> {
|
|||||||
textStyle: kDefaultTerminalStyle,
|
textStyle: kDefaultTerminalStyle,
|
||||||
controller: terminalController,
|
controller: terminalController,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
backgroundOpacity: 0.7,
|
backgroundOpacity: 0.9,
|
||||||
onSecondaryTapDown: (details, offset) async {
|
onSecondaryTapDown: (details, offset) async {
|
||||||
final selection = terminalController.selection;
|
final selection = terminalController.selection;
|
||||||
if (selection != null) {
|
if (selection != null) {
|
||||||
|
@ -11,7 +11,7 @@ void veilidInit() {
|
|||||||
enabled: true,
|
enabled: true,
|
||||||
level: VeilidConfigLogLevel.debug,
|
level: VeilidConfigLogLevel.debug,
|
||||||
logsInTimings: true,
|
logsInTimings: true,
|
||||||
logsInConsole: true),
|
logsInConsole: false),
|
||||||
api: VeilidWASMConfigLoggingApi(
|
api: VeilidWASMConfigLoggingApi(
|
||||||
enabled: true, level: VeilidConfigLogLevel.info)));
|
enabled: true, level: VeilidConfigLogLevel.info)));
|
||||||
Veilid.instance.initializeVeilidCore(platformConfig.json);
|
Veilid.instance.initializeVeilidCore(platformConfig.json);
|
||||||
|
@ -241,7 +241,7 @@ const MaterialColor materialPopComplementaryColor =
|
|||||||
|
|
||||||
const kDefaultSpacingFactor = 4.0;
|
const kDefaultSpacingFactor = 4.0;
|
||||||
|
|
||||||
const kDefaultMonoTerminalFontFamily = "CascadiaMonoPL.ttf";
|
const kDefaultMonoTerminalFontFamily = "Fira Code";
|
||||||
const kDefaultMonoTerminalFontHeight = 1.2;
|
const kDefaultMonoTerminalFontHeight = 1.2;
|
||||||
const kDefaultMonoTerminalFontSize = 12.0;
|
const kDefaultMonoTerminalFontSize = 12.0;
|
||||||
|
|
||||||
|
@ -94,3 +94,11 @@ flutter:
|
|||||||
- family: Cascadia Mono
|
- family: Cascadia Mono
|
||||||
fonts:
|
fonts:
|
||||||
- asset: fonts/CascadiaMonoPL.ttf
|
- 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
|
@ -1,5 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<!--
|
<!--
|
||||||
If you are serving your web app in a path other than the root, change the
|
If you are serving your web app in a path other than the root, change the
|
||||||
@ -29,10 +30,18 @@
|
|||||||
<!-- Favicon -->
|
<!-- Favicon -->
|
||||||
<link rel="icon" type="image/png" href="favicon.png" />
|
<link rel="icon" type="image/png" href="favicon.png" />
|
||||||
|
|
||||||
<title>veilid_example</title>
|
<title>Veilid Example</title>
|
||||||
<link rel="manifest" href="manifest.json">
|
<link rel="manifest" href="manifest.json">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// The value below is injected by flutter build, do not touch.
|
||||||
|
var serviceWorkerVersion = null;
|
||||||
|
</script>
|
||||||
|
<!-- This script adds the flutter initialization JS code -->
|
||||||
|
<script src="flutter.js" defer></script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<!-- Load WASM modules -->
|
<!-- Load WASM modules -->
|
||||||
@ -49,72 +58,21 @@
|
|||||||
run();
|
run();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- This script installs service_worker.js to provide PWA functionality to
|
|
||||||
application. For more information, see:
|
|
||||||
https://developers.google.com/web/fundamentals/primers/service-workers -->
|
|
||||||
<script>
|
<script>
|
||||||
var serviceWorkerVersion = null;
|
window.addEventListener('load', function (ev) {
|
||||||
var scriptLoaded = false;
|
// Download main.dart.js
|
||||||
function loadMainDartJs() {
|
_flutter.loader.loadEntrypoint({
|
||||||
if (scriptLoaded) {
|
serviceWorker: {
|
||||||
return;
|
serviceWorkerVersion: serviceWorkerVersion,
|
||||||
}
|
|
||||||
scriptLoaded = true;
|
|
||||||
var scriptTag = document.createElement('script');
|
|
||||||
scriptTag.src = 'main.dart.js';
|
|
||||||
scriptTag.type = 'application/javascript';
|
|
||||||
document.body.append(scriptTag);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('serviceWorker' in navigator) {
|
|
||||||
// Service workers are supported. Use them.
|
|
||||||
window.addEventListener('load', function () {
|
|
||||||
// Wait for registration to finish before dropping the <script> tag.
|
|
||||||
// Otherwise, the browser will load the script multiple times,
|
|
||||||
// potentially different versions.
|
|
||||||
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
|
|
||||||
navigator.serviceWorker.register(serviceWorkerUrl)
|
|
||||||
.then((reg) => {
|
|
||||||
function waitForActivation(serviceWorker) {
|
|
||||||
serviceWorker.addEventListener('statechange', () => {
|
|
||||||
if (serviceWorker.state == 'activated') {
|
|
||||||
console.log('Installed new service worker.');
|
|
||||||
loadMainDartJs();
|
|
||||||
}
|
}
|
||||||
|
}).then(function (engineInitializer) {
|
||||||
|
return engineInitializer.initializeEngine();
|
||||||
|
}).then(function (appRunner) {
|
||||||
|
return appRunner.runApp();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
if (!reg.active && (reg.installing || reg.waiting)) {
|
|
||||||
// No active web worker and we have installed or are installing
|
|
||||||
// one for the first time. Simply wait for it to activate.
|
|
||||||
waitForActivation(reg.installing || reg.waiting);
|
|
||||||
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
|
|
||||||
// When the app updates the serviceWorkerVersion changes, so we
|
|
||||||
// need to ask the service worker to update.
|
|
||||||
console.log('New service worker available.');
|
|
||||||
reg.update();
|
|
||||||
waitForActivation(reg.installing);
|
|
||||||
} else {
|
|
||||||
// Existing service worker is still good.
|
|
||||||
console.log('Loading app from service worker.');
|
|
||||||
loadMainDartJs();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// If service worker doesn't succeed in a reasonable amount of time,
|
|
||||||
// fallback to plaint <script> tag.
|
|
||||||
setTimeout(() => {
|
|
||||||
if (!scriptLoaded) {
|
|
||||||
console.warn(
|
|
||||||
'Failed to load app from service worker. Falling back to plain <script> tag.',
|
|
||||||
);
|
|
||||||
loadMainDartJs();
|
|
||||||
}
|
|
||||||
}, 4000);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// Service workers not supported. Just drop the <script> tag.
|
|
||||||
loadMainDartJs();
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -1474,11 +1474,15 @@ class VeilidStateRoute {
|
|||||||
});
|
});
|
||||||
|
|
||||||
VeilidStateRoute.fromJson(Map<String, dynamic> json)
|
VeilidStateRoute.fromJson(Map<String, dynamic> json)
|
||||||
: deadRoutes = json['dead_routes'],
|
: deadRoutes = List<String>.from(json['dead_routes'].map((j) => j)),
|
||||||
deadRemoteRoutes = json['dead_remote_routes'];
|
deadRemoteRoutes =
|
||||||
|
List<String>.from(json['dead_remote_routes'].map((j) => j));
|
||||||
|
|
||||||
Map<String, dynamic> get json {
|
Map<String, dynamic> 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()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,8 +185,9 @@ class VeilidJS implements Veilid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<String> debug(String command) {
|
Future<String> debug(String command) async {
|
||||||
return _wrapApiPromise(js_util.callMethod(wasm, "debug", [command]));
|
return jsonDecode(
|
||||||
|
await _wrapApiPromise(js_util.callMethod(wasm, "debug", [command])));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
Loading…
Reference in New Issue
Block a user