diff --git a/Cargo.lock b/Cargo.lock index 2801b0a..a6f8883 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -543,7 +543,7 @@ dependencies = [ [[package]] name = "golgi" -version = "0.1.1" +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", @@ -639,8 +640,8 @@ dependencies = [ [[package]] name = "kuska-ssb" -version = "0.4.0" -source = "git+https://github.com/Kuska-ssb/ssb#fb7062de606e7c9cae8dd4df402a122db46c1b77" +version = "0.4.1" +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 460122c..1742676 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "golgi" -version = "0.1.1" +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 fdf1771..e553d70 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. @@ -54,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 { @@ -69,10 +77,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 + .unwrap_or_else(|_| panic!( + "couldn't read local go-sbot secret from: {}", + key_path + )) + } + Keystore::CustomPatchwork(key_path) => { + keystore::from_custom_patchwork_keypath(key_path.to_string()) + .await + .unwrap_or_else(|_| panic!( + "couldn't read local patchwork secret from: {}", + key_path + )) + } }; Ok(Self { 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));