Merge pull request 'Add support for custom keyfile paths' (#41) from keypaths into main
Reviewed-on: #41
This commit is contained in:
commit
ca4c1114dd
|
@ -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",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "golgi"
|
||||
version = "0.1.1"
|
||||
version = "0.1.4"
|
||||
edition = "2021"
|
||||
authors = ["Max Fowler <max@mfowler.info>", "Andrew Reid <glyph@mycelial.technology>"]
|
||||
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"
|
||||
|
|
30
src/sbot.rs
30
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<String>,
|
||||
net_id: Option<String>,
|
||||
) -> Result<Sbot, GolgiError> {
|
||||
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 {
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue