Skip to content

Commit

Permalink
Merge pull request #435 from kinode-dao/release-candidate
Browse files Browse the repository at this point in the history
0.8.3 Release candidate
  • Loading branch information
dr-frmr authored Jul 15, 2024
2 parents 6ae6fb2 + ce00af0 commit a155bfc
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 54 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kinode_lib"
authors = ["KinodeDAO"]
version = "0.8.2"
version = "0.8.3"
edition = "2021"
description = "A general-purpose sovereign cloud computing platform"
homepage = "https://kinode.org"
Expand Down
2 changes: 1 addition & 1 deletion kinode/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kinode"
authors = ["KinodeDAO"]
version = "0.8.2"
version = "0.8.3"
edition = "2021"
description = "A general-purpose sovereign cloud computing platform"
homepage = "https://kinode.org"
Expand Down
9 changes: 7 additions & 2 deletions kinode/packages/kino_updates/widget/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,13 @@ fn fetch_most_recent_blog_posts(n: usize) -> Vec<KinodeBlogPost> {
60,
vec![],
) {
Ok(response) => serde_json::from_slice::<Vec<KinodeBlogPost>>(response.body())
.expect("Invalid UTF-8 from kinode.org"),
Ok(response) => match serde_json::from_slice::<Vec<KinodeBlogPost>>(response.body()) {
Ok(posts) => posts,
Err(e) => {
println!("Failed to parse blog posts: {e:?}");
vec![]
}
},
Err(e) => {
println!("Failed to fetch blog posts: {e:?}");
vec![]
Expand Down
77 changes: 72 additions & 5 deletions kinode/src/http/login.html

Large diffs are not rendered by default.

39 changes: 16 additions & 23 deletions kinode/src/http/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,19 +546,30 @@ async fn http_handler(
.into_response());
}
if request_subdomain != subdomain {
let query_string = if !query_params.is_empty() {
let params: Vec<String> = query_params
.iter()
.map(|(key, value)| format!("{}={}", key, value))
.collect();
format!("?{}", params.join("&"))
} else {
String::new()
};

return Ok(warp::http::Response::builder()
.status(StatusCode::TEMPORARY_REDIRECT)
.header(
"Location",
format!(
"{}://{}.{}{}",
"{}://{}.{}{}{}",
match headers.get("X-Forwarded-Proto") {
Some(proto) => proto.to_str().unwrap_or("http"),
None => "http",
},
subdomain,
host,
original_path,
query_string,
),
)
.body(vec![])
Expand All @@ -584,28 +595,10 @@ async fn http_handler(
&jwt_secret_bytes,
) {
// redirect to login page so they can get an auth token
if original_path == "" {
return Ok(warp::http::Response::builder()
.status(StatusCode::OK)
.body(login_html.to_string())
.into_response());
} else {
return Ok(warp::http::Response::builder()
.status(StatusCode::TEMPORARY_REDIRECT)
.header(
"Location",
format!(
"{}://{}",
match headers.get("X-Forwarded-Proto") {
Some(proto) => proto.to_str().unwrap_or("http"),
None => "http",
},
host,
),
)
.body(vec![])
.into_response());
}
return Ok(warp::http::Response::builder()
.status(StatusCode::OK)
.body(login_html.to_string())
.into_response());
}
}
}
Expand Down
15 changes: 1 addition & 14 deletions kinode/src/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,6 @@ pub async fn assign_routing(
let namehash = FixedBytes::<32>::from_slice(&keygen::namehash(&our.name));
let ip_call = ipCall { _0: namehash }.abi_encode();
let key_call = keyCall { _0: namehash }.abi_encode();
let router_call = routersCall { _0: namehash }.abi_encode();
let tx_input = TransactionInput::new(Bytes::from(ip_call));
let tx = TransactionRequest::default()
.to(kns_address)
Expand Down Expand Up @@ -737,18 +736,6 @@ pub async fn assign_routing(
));
}

let router_tx_input = TransactionInput::new(Bytes::from(router_call));
let router_tx = TransactionRequest::default()
.to(kns_address)
.input(router_tx_input);

let Ok(routers) = provider.call(&router_tx).await else {
return Err(anyhow::anyhow!("Failed to fetch node routers from PKI"));
};
let Ok(routers) = <Vec<FixedBytes<32>>>::abi_decode(&routers, false) else {
return Err(anyhow::anyhow!("Failed to decode node routers from PKI"));
};

let node_ip = format!(
"{}.{}.{}.{}",
(ip >> 24) & 0xFF,
Expand All @@ -757,7 +744,7 @@ pub async fn assign_routing(
ip & 0xFF
);

if !routers.is_empty() {
if !our.is_direct() {
// indirect node
return Ok(());
}
Expand Down
35 changes: 32 additions & 3 deletions kinode/src/terminal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,9 @@ pub async fn terminal(
)?;
},
//
// BACKSPACE or DELETE: delete a single character at cursor
// BACKSPACE: delete a single character at cursor
//
KeyCode::Backspace | KeyCode::Delete => {
KeyCode::Backspace => {
if line_col == prompt_len {
continue;
}
Expand Down Expand Up @@ -477,6 +477,35 @@ pub async fn terminal(
)?;
},
//
// DELETE: delete a single character at right of cursor
//
KeyCode::Delete => {
if line_col == current_line.len() {
continue;
}
current_line.remove(line_col);
if search_mode {
utils::execute_search(
&our,
&mut stdout,
&current_line,
prompt_len,
(win_cols, win_rows),
(line_col, cursor_col),
&mut command_history,
search_depth,
)?;
continue;
}
execute!(
stdout,
cursor::MoveTo(0, win_rows),
terminal::Clear(ClearType::CurrentLine),
Print(utils::truncate_in_place(&current_line, prompt_len, win_cols, (line_col, cursor_col))),
cursor::MoveTo(cursor_col, win_rows),
)?;
}
//
// LEFT: move cursor one spot left
//
KeyCode::Left => {
Expand Down Expand Up @@ -587,7 +616,7 @@ pub async fn terminal(
_ = sigalrm.recv() => return Err(anyhow::anyhow!("exiting due to SIGALRM")),
_ = sighup.recv() => return Err(anyhow::anyhow!("exiting due to SIGHUP")),
_ = sigint.recv() => return Err(anyhow::anyhow!("exiting due to SIGINT")),
_ = sigpipe.recv() => return Err(anyhow::anyhow!("exiting due to SIGPIPE")),
_ = sigpipe.recv() => continue, // IGNORE SIGPIPE!
_ = sigquit.recv() => return Err(anyhow::anyhow!("exiting due to SIGQUIT")),
_ = sigterm.recv() => return Err(anyhow::anyhow!("exiting due to SIGTERM")),
_ = sigusr1.recv() => return Err(anyhow::anyhow!("exiting due to SIGUSR1")),
Expand Down
2 changes: 1 addition & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "lib"
authors = ["KinodeDAO"]
version = "0.8.2"
version = "0.8.3"
edition = "2021"
description = "A general-purpose sovereign cloud computing platform"
homepage = "https://kinode.org"
Expand Down
11 changes: 10 additions & 1 deletion lib/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use ring::signature;
use rusqlite::types::{FromSql, FromSqlError, ToSql, ValueRef};
use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, HashMap, HashSet};
use std::hash::{Hash, Hasher};
use thiserror::Error;

lazy_static::lazy_static! {
Expand Down Expand Up @@ -470,7 +471,7 @@ pub enum Message {
Response((Response, Option<Context>)),
}

#[derive(Clone, Debug, Hash, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Capability {
pub issuer: Address,
pub params: String,
Expand All @@ -488,6 +489,14 @@ impl PartialEq for Capability {
}
}

impl Hash for Capability {
fn hash<H: Hasher>(&self, state: &mut H) {
self.issuer.hash(state);
let params: serde_json::Value = serde_json::from_str(&self.params).unwrap_or_default();
params.hash(state);
}
}

impl Capability {
pub fn new<T, U>(issuer: T, params: U) -> Self
where
Expand Down

0 comments on commit a155bfc

Please sign in to comment.