From 3f3c18b8b7548882c7da6888cfe8a10f06f0b232 Mon Sep 17 00:00:00 2001 From: notplants Date: Wed, 25 May 2022 13:49:27 +0200 Subject: [PATCH 1/7] Add support for custom keyfile paths --- Cargo.lock | 5 ++--- Cargo.toml | 5 +++-- src/sbot.rs | 24 ++++++++++++++++++++++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2801b0a..656212e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -543,7 +543,7 @@ dependencies = [ [[package]] name = "golgi" -version = "0.1.1" +version = "0.1.2" dependencies = [ "async-std", "async-stream 0.3.2", @@ -639,8 +639,7 @@ dependencies = [ [[package]] name = "kuska-ssb" -version = "0.4.0" -source = "git+https://github.com/Kuska-ssb/ssb#fb7062de606e7c9cae8dd4df402a122db46c1b77" +version = "0.4.1" dependencies = [ "async-std", "async-stream 0.2.1", diff --git a/Cargo.toml b/Cargo.toml index 460122c..a2e2a1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "golgi" -version = "0.1.1" +version = "0.1.2" edition = "2021" authors = ["Max Fowler ", "Andrew Reid "] readme = "README.md" @@ -19,7 +19,8 @@ futures = "0.3.21" hex = "0.4.3" kuska-handshake = { version = "0.2.0", features = ["async_std"] } kuska-sodiumoxide = "0.2.5-0" -kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb" } +#kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb" } +kuska-ssb = { path = "../kuska-ssb" } serde = { version = "1", features = ["derive"] } serde_json = "1" sha2 = "0.10.2" diff --git a/src/sbot.rs b/src/sbot.rs index fdf1771..140b95d 100644 --- a/src/sbot.rs +++ b/src/sbot.rs @@ -20,6 +20,10 @@ pub enum Keystore { Patchwork, /// GoSbot default keystore path: `.ssb-go/secret` in the user's home directory. GoSbot, + /// GoSbot keystore in a custom location + CustomGoSbot(String), + /// Patchwork keystore in a custom location + CustomPatchwork(String), } /// A struct representing a connection with a running sbot. @@ -69,10 +73,26 @@ impl Sbot { let OwnedIdentity { pk, sk, id } = match keystore { Keystore::Patchwork => keystore::from_patchwork_local() .await - .expect("couldn't read local secret"), + .expect("couldn't read local patchwork secret from default location"), Keystore::GoSbot => keystore::from_gosbot_local() .await - .expect("couldn't read local secret"), + .expect("couldn't read local go-sbot secret from default location"), + Keystore::CustomGoSbot(key_path) => { + keystore::from_custom_gosbot_keypath(key_path.to_string()) + .await + .expect(&format!( + "couldn't read local go-sbot secret from: {}", + key_path + )) + } + Keystore::CustomPatchwork(key_path) => { + keystore::from_custom_patchwork_keypath(key_path.to_string()) + .await + .expect(&format!( + "couldn't read local patchwork secret from: {}", + key_path + )) + } }; Ok(Self { -- 2.49.0 From b4987d514a07810a87c939d330a6f9dcb4dc74f6 Mon Sep 17 00:00:00 2001 From: notplants Date: Wed, 25 May 2022 14:01:48 +0200 Subject: [PATCH 2/7] Cargo.toml --- Cargo.lock | 1 + Cargo.toml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 656212e..b00672f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -640,6 +640,7 @@ dependencies = [ [[package]] name = "kuska-ssb" version = "0.4.1" +source = "git+https://github.com/mhfowler/kuska-ssb.git#48adac914fd2288abcc267560c5a3e013a072003" dependencies = [ "async-std", "async-stream 0.2.1", diff --git a/Cargo.toml b/Cargo.toml index a2e2a1d..b0eaf99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,8 @@ hex = "0.4.3" kuska-handshake = { version = "0.2.0", features = ["async_std"] } kuska-sodiumoxide = "0.2.5-0" #kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb" } -kuska-ssb = { path = "../kuska-ssb" } +kuska-ssb = { git = "https://github.com/mhfowler/kuska-ssb.git" } +#kuska-ssb = { path = "../kuska-ssb" } serde = { version = "1", features = ["derive"] } serde_json = "1" sha2 = "0.10.2" -- 2.49.0 From fb115b280fd3de15172164108d263cae675c3bda Mon Sep 17 00:00:00 2001 From: notplants Date: Thu, 26 May 2022 22:54:19 +0200 Subject: [PATCH 3/7] Prefix 127.0.0.1 to address if starts with : --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/sbot.rs | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b00672f..fe11551 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -543,7 +543,7 @@ dependencies = [ [[package]] name = "golgi" -version = "0.1.2" +version = "0.1.3" dependencies = [ "async-std", "async-stream 0.3.2", diff --git a/Cargo.toml b/Cargo.toml index b0eaf99..39712ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "golgi" -version = "0.1.2" +version = "0.1.3" edition = "2021" authors = ["Max Fowler ", "Andrew Reid "] readme = "README.md" diff --git a/src/sbot.rs b/src/sbot.rs index 140b95d..4981fc2 100644 --- a/src/sbot.rs +++ b/src/sbot.rs @@ -58,12 +58,16 @@ impl Sbot { ip_port: Option, net_id: Option, ) -> Result { - let address = if ip_port.is_none() { + let mut address = if ip_port.is_none() { "127.0.0.1:8008".to_string() } else { ip_port.unwrap() }; + if address.starts_with(":") { + address = format!("127.0.0.1{}", address); + } + let network_id = if net_id.is_none() { discovery::ssb_net_id() } else { -- 2.49.0 From 6daddeab9e3d48713b2e29d2437535ad6cedb84d Mon Sep 17 00:00:00 2001 From: notplants Date: Thu, 26 May 2022 23:03:43 +0200 Subject: [PATCH 4/7] Debug address --- Cargo.lock | 3 ++- Cargo.toml | 3 ++- src/sbot.rs | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe11551..37c679e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -543,7 +543,7 @@ dependencies = [ [[package]] name = "golgi" -version = "0.1.3" +version = "0.1.4" dependencies = [ "async-std", "async-stream 0.3.2", @@ -553,6 +553,7 @@ dependencies = [ "kuska-handshake", "kuska-sodiumoxide", "kuska-ssb", + "log", "serde", "serde_json", "sha2", diff --git a/Cargo.toml b/Cargo.toml index 39712ba..39144e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "golgi" -version = "0.1.3" +version = "0.1.4" edition = "2021" authors = ["Max Fowler ", "Andrew Reid "] readme = "README.md" @@ -16,6 +16,7 @@ async-std = "1.10.0" async-stream = "0.3.2" base64 = "0.13.0" futures = "0.3.21" +log = "0.4" hex = "0.4.3" kuska-handshake = { version = "0.2.0", features = ["async_std"] } kuska-sodiumoxide = "0.2.5-0" diff --git a/src/sbot.rs b/src/sbot.rs index 4981fc2..314ec90 100644 --- a/src/sbot.rs +++ b/src/sbot.rs @@ -1,5 +1,6 @@ //! Sbot type and connection-related methods. use async_std::net::TcpStream; +use log::debug; use kuska_handshake::async_std::BoxStream; use kuska_sodiumoxide::crypto::{auth, sign::ed25519}; @@ -66,6 +67,7 @@ impl Sbot { if address.starts_with(":") { address = format!("127.0.0.1{}", address); + debug!("prefixing address: {}", address); } let network_id = if net_id.is_none() { -- 2.49.0 From 51dc82280af418f47bb2a80fb7c1dd3e43f9b051 Mon Sep 17 00:00:00 2001 From: notplants Date: Thu, 26 May 2022 23:11:18 +0200 Subject: [PATCH 5/7] Remove debug statements --- src/sbot.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sbot.rs b/src/sbot.rs index 314ec90..2e4a1bb 100644 --- a/src/sbot.rs +++ b/src/sbot.rs @@ -67,7 +67,6 @@ impl Sbot { if address.starts_with(":") { address = format!("127.0.0.1{}", address); - debug!("prefixing address: {}", address); } let network_id = if net_id.is_none() { -- 2.49.0 From 1fc56ac8f13bb0ecbdbbefaf6a194d65f90910b2 Mon Sep 17 00:00:00 2001 From: notplants Date: Wed, 15 Jun 2022 12:12:18 +0200 Subject: [PATCH 6/7] Update kuska-ssb dependency --- Cargo.lock | 2 +- Cargo.toml | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 37c679e..a6f8883 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -641,7 +641,7 @@ dependencies = [ [[package]] name = "kuska-ssb" version = "0.4.1" -source = "git+https://github.com/mhfowler/kuska-ssb.git#48adac914fd2288abcc267560c5a3e013a072003" +source = "git+https://github.com/Kuska-ssb/ssb#6b0457a8ddd0e86a8f84cffac2b5cb835723822f" dependencies = [ "async-std", "async-stream 0.2.1", diff --git a/Cargo.toml b/Cargo.toml index 39144e1..1742676 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,9 +20,7 @@ log = "0.4" hex = "0.4.3" kuska-handshake = { version = "0.2.0", features = ["async_std"] } kuska-sodiumoxide = "0.2.5-0" -#kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb" } -kuska-ssb = { git = "https://github.com/mhfowler/kuska-ssb.git" } -#kuska-ssb = { path = "../kuska-ssb" } +kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb" } serde = { version = "1", features = ["derive"] } serde_json = "1" sha2 = "0.10.2" -- 2.49.0 From 1651b7342609211ac2891375ae2a9a3909e4e89b Mon Sep 17 00:00:00 2001 From: notplants Date: Wed, 15 Jun 2022 12:27:04 +0200 Subject: [PATCH 7/7] Fix clippy warnings --- src/sbot.rs | 7 +++---- src/utils.rs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/sbot.rs b/src/sbot.rs index 2e4a1bb..e553d70 100644 --- a/src/sbot.rs +++ b/src/sbot.rs @@ -1,6 +1,5 @@ //! Sbot type and connection-related methods. use async_std::net::TcpStream; -use log::debug; use kuska_handshake::async_std::BoxStream; use kuska_sodiumoxide::crypto::{auth, sign::ed25519}; @@ -65,7 +64,7 @@ impl Sbot { ip_port.unwrap() }; - if address.starts_with(":") { + if address.starts_with(':') { address = format!("127.0.0.1{}", address); } @@ -85,7 +84,7 @@ impl Sbot { Keystore::CustomGoSbot(key_path) => { keystore::from_custom_gosbot_keypath(key_path.to_string()) .await - .expect(&format!( + .unwrap_or_else(|_| panic!( "couldn't read local go-sbot secret from: {}", key_path )) @@ -93,7 +92,7 @@ impl Sbot { Keystore::CustomPatchwork(key_path) => { keystore::from_custom_patchwork_keypath(key_path.to_string()) .await - .expect(&format!( + .unwrap_or_else(|_| panic!( "couldn't read local patchwork secret from: {}", key_path )) diff --git a/src/utils.rs b/src/utils.rs index 5871549..df3fe51 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -76,7 +76,7 @@ where if id == req_no { match msg { RecvMsg::RpcResponse(_type, body) => { - return f(&body).map_err(|err| err); + return f(&body); } RecvMsg::ErrorResponse(message) => { return Err(GolgiError::Sbot(message)); -- 2.49.0