mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-23 00:21:38 +03:00
fix: eth:distro:sys
close sub on any keepalive response, also improvements to settings app
This commit is contained in:
parent
0269191385
commit
b2de9ca0a1
46
Cargo.lock
generated
46
Cargo.lock
generated
@ -3149,28 +3149,6 @@ dependencies = [
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kinode_process_lib"
|
||||
version = "0.6.1"
|
||||
source = "git+https://github.com/kinode-dao/process_lib?tag=v0.6.1#37a20b0249dc2c86ae6c2c69cfb199fb177f1520"
|
||||
dependencies = [
|
||||
"alloy-json-rpc 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=6f8ebb4)",
|
||||
"alloy-primitives 0.6.4",
|
||||
"alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=6f8ebb4)",
|
||||
"alloy-transport 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=6f8ebb4)",
|
||||
"anyhow",
|
||||
"bincode",
|
||||
"http 1.1.0",
|
||||
"mime_guess",
|
||||
"rand 0.8.5",
|
||||
"rmp-serde",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"url",
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kinode_process_lib"
|
||||
version = "0.7.0"
|
||||
@ -3215,6 +3193,28 @@ dependencies = [
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kinode_process_lib"
|
||||
version = "0.7.1"
|
||||
source = "git+https://github.com/kinode-dao/process_lib?rev=61a8de9#61a8de975fd0a812a0a033ee0975fb83dd166224"
|
||||
dependencies = [
|
||||
"alloy-json-rpc 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cad7935)",
|
||||
"alloy-primitives 0.7.0",
|
||||
"alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cad7935)",
|
||||
"alloy-transport 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cad7935)",
|
||||
"anyhow",
|
||||
"bincode",
|
||||
"http 1.1.0",
|
||||
"mime_guess",
|
||||
"rand 0.8.5",
|
||||
"rmp-serde",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"url",
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kit"
|
||||
version = "0.3.1"
|
||||
@ -4965,7 +4965,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.22.0",
|
||||
"bincode",
|
||||
"kinode_process_lib 0.6.1",
|
||||
"kinode_process_lib 0.7.1",
|
||||
"rmp-serde",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
@ -12,45 +12,46 @@
|
||||
<body>
|
||||
<h1>system diagnostics & settings</h1>
|
||||
<main>
|
||||
<article id="net-diagnostics">
|
||||
<h2>networking diagnostics</h2>
|
||||
<p id="diagnostics"></p>
|
||||
</article>
|
||||
|
||||
<article id="node-info">
|
||||
<p>node info</p>
|
||||
<h2>node info</h2>
|
||||
<p id="node-name"></p>
|
||||
<p id="net-key"></p>
|
||||
<p id="ip-ports"></p>
|
||||
<p id="routers"></p>
|
||||
<button>reset networking key</button>
|
||||
<button>adjust networking info</button>
|
||||
<button>reset networking key (TODO)</button>
|
||||
<button>adjust networking info (TODO)</button>
|
||||
<button id="shutdown">shut down node</button>
|
||||
</article>
|
||||
|
||||
<article id="net-diagnostics">
|
||||
<p>networking diagnostics</p>
|
||||
<p id="diagnostics"></p>
|
||||
</article>
|
||||
<article id="pings">
|
||||
<p>fetch PKI data</p>
|
||||
<h2>fetch PKI data</h2>
|
||||
<form id="get-peer-pki">
|
||||
<input type="text" name="peer" placeholder="peer-name.os">
|
||||
<button type="submit">get peer info</button>
|
||||
</form>
|
||||
<p id="peer-pki-response"></p>
|
||||
<p>ping a node</p>
|
||||
<h2>ping a node</h2>
|
||||
<form id="ping-peer">
|
||||
<input type="text" name="peer" placeholder="peer-name.os">
|
||||
<input type="text" name="content" placeholder="message">
|
||||
<label><input type="number" name="timeout">timeout (seconds)</label>
|
||||
<input type="number" name="timeout" placeholder="timeout (seconds)">
|
||||
<button type="submit">ping</button>
|
||||
</form>
|
||||
<p id="peer-ping-response"></p>
|
||||
</article>
|
||||
|
||||
<article id="eth-rpc-providers">
|
||||
<p>ETH RPC providers</p>
|
||||
<h2>ETH RPC providers</h2>
|
||||
<ul id="providers"></ul>
|
||||
</article>
|
||||
|
||||
<article id="eth-rpc-settings">
|
||||
<p>ETH RPC settings</p>
|
||||
<h2>ETH RPC settings</h2>
|
||||
<p id="public"></p>
|
||||
<div>
|
||||
<p>nodes allowed to connect:</p>
|
||||
@ -63,7 +64,7 @@
|
||||
</article>
|
||||
|
||||
<article id="kernel">
|
||||
<p>running processes:</p>
|
||||
<h2>running processes</h2>
|
||||
<p>(TODO)</p>
|
||||
<ul></ul>
|
||||
</article>
|
||||
|
@ -56,17 +56,17 @@ function populate_eth_rpc_providers(providers) {
|
||||
ul.innerHTML = '';
|
||||
providers.forEach(provider => {
|
||||
const li = document.createElement('li');
|
||||
li.innerHTML = `<li>${JSON.stringify(provider)}</li>`;
|
||||
li.innerHTML = `${JSON.stringify(provider, undefined, 2)}`;
|
||||
ul.appendChild(li);
|
||||
});
|
||||
}
|
||||
|
||||
function populate_eth_rpc_settings(settings) {
|
||||
if (settings.public) {
|
||||
document.getElementById('public').innerText = 'public';
|
||||
document.getElementById('public').innerText = 'status: public';
|
||||
document.getElementById('allowed-nodes').style.display = 'none';
|
||||
} else {
|
||||
document.getElementById('public').innerText = 'private';
|
||||
document.getElementById('public').innerText = 'status: private';
|
||||
const ul = document.getElementById('allowed-nodes');
|
||||
ul.innerHTML = '';
|
||||
if (settings.allow.length === 0) {
|
||||
@ -119,7 +119,7 @@ document.getElementById('get-peer-pki').addEventListener('submit', (e) => {
|
||||
if (data === null) {
|
||||
document.getElementById('peer-pki-response').innerText = "no pki data for peer";
|
||||
} else {
|
||||
document.getElementById('peer-pki-response').innerText = JSON.stringify(data);
|
||||
document.getElementById('peer-pki-response').innerText = JSON.stringify(data, undefined, 2);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
@ -82,14 +82,51 @@ h1 {
|
||||
}
|
||||
|
||||
main {
|
||||
margin: 0 auto;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: 20px;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
gap: 20px 20px;
|
||||
grid-auto-flow: row;
|
||||
grid-template-areas:
|
||||
"diagnostics diagnostics diagnostics"
|
||||
"node-info pings pings"
|
||||
"eth-rpc-providers eth-rpc-providers eth-rpc-settings"
|
||||
"kernel kernel kernel";
|
||||
padding: 20px;
|
||||
max-width: 1200px;
|
||||
max-width: 1100px;
|
||||
min-width: 300px;
|
||||
}
|
||||
|
||||
article#net-diagnostics {
|
||||
grid-area: diagnostics;
|
||||
}
|
||||
|
||||
p#diagnostics,
|
||||
p#peer-pki-response,
|
||||
p#peer-ping-response {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
article#node-info {
|
||||
grid-area: node-info;
|
||||
}
|
||||
|
||||
article#pings {
|
||||
grid-area: pings;
|
||||
}
|
||||
|
||||
article#eth-rpc-providers {
|
||||
grid-area: eth-rpc-providers;
|
||||
}
|
||||
|
||||
article#eth-rpc-settings {
|
||||
grid-area: eth-rpc-settings;
|
||||
}
|
||||
|
||||
article#kernel {
|
||||
grid-area: kernel;
|
||||
}
|
||||
|
||||
article {
|
||||
background-color: #333;
|
||||
border: 1px solid #444;
|
||||
@ -129,11 +166,20 @@ button {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
button#shutdown {
|
||||
background-color: #f44336;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: white;
|
||||
color: #4CAF50;
|
||||
}
|
||||
|
||||
button#shutdown:hover {
|
||||
background-color: white;
|
||||
color: #f44336;
|
||||
}
|
||||
|
||||
input[type="text"],
|
||||
input[type="number"],
|
||||
select,
|
||||
@ -178,4 +224,5 @@ li {
|
||||
background-color: #2c2c2c;
|
||||
border-radius: 4px;
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
}
|
@ -10,7 +10,7 @@ simulation-mode = []
|
||||
anyhow = "1.0"
|
||||
base64 = "0.22.0"
|
||||
bincode = "1.3.3"
|
||||
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.1" }
|
||||
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "61a8de9" }
|
||||
rmp-serde = "1.2.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
|
@ -243,16 +243,18 @@ fn handle_http_request(
|
||||
state: &mut SettingsState,
|
||||
http_request: &http::IncomingHttpRequest,
|
||||
) -> anyhow::Result<()> {
|
||||
state.fetch()?;
|
||||
match http_request.method()?.as_str() {
|
||||
"GET" => Ok(http::send_response(
|
||||
http::StatusCode::OK,
|
||||
Some(HashMap::from([(
|
||||
String::from("Content-Type"),
|
||||
String::from("application/json"),
|
||||
)])),
|
||||
serde_json::to_vec(&state)?,
|
||||
)),
|
||||
"GET" => {
|
||||
state.fetch()?;
|
||||
Ok(http::send_response(
|
||||
http::StatusCode::OK,
|
||||
Some(HashMap::from([(
|
||||
String::from("Content-Type"),
|
||||
String::from("application/json"),
|
||||
)])),
|
||||
serde_json::to_vec(&state)?,
|
||||
))
|
||||
}
|
||||
"POST" => {
|
||||
let Some(blob) = get_blob() else {
|
||||
return Ok(http::send_response(
|
||||
@ -263,6 +265,7 @@ fn handle_http_request(
|
||||
};
|
||||
let request = serde_json::from_slice::<SettingsRequest>(&blob.bytes)?;
|
||||
let response = handle_settings_request(state, request);
|
||||
state.fetch()?;
|
||||
state.ws_update();
|
||||
Ok(http::send_response(
|
||||
http::StatusCode::OK,
|
||||
|
@ -411,13 +411,11 @@ async fn maintain_remote_subscription(
|
||||
&send_to_loop,
|
||||
).await;
|
||||
}
|
||||
incoming = net_error_rx.recv() => {
|
||||
if let Some(Err(_net_error)) = incoming {
|
||||
break EthSubError {
|
||||
id: sub_id,
|
||||
error: "subscription node-provider failed keepalive".to_string(),
|
||||
};
|
||||
}
|
||||
_incoming = net_error_rx.recv() => {
|
||||
break EthSubError {
|
||||
id: sub_id,
|
||||
error: "subscription node-provider failed keepalive".to_string(),
|
||||
};
|
||||
}
|
||||
_ = tokio::time::sleep_until(last_received + two_hours) => {
|
||||
break EthSubError {
|
||||
|
Loading…
Reference in New Issue
Block a user