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