Add support for custom keyfile paths

This commit is contained in:
2022-05-25 13:49:27 +02:00
parent 0aa616d92b
commit 3f3c18b8b7
3 changed files with 27 additions and 7 deletions

5
Cargo.lock generated
View File

@ -543,7 +543,7 @@ dependencies = [
[[package]] [[package]]
name = "golgi" name = "golgi"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"async-std", "async-std",
"async-stream 0.3.2", "async-stream 0.3.2",
@ -639,8 +639,7 @@ dependencies = [
[[package]] [[package]]
name = "kuska-ssb" name = "kuska-ssb"
version = "0.4.0" version = "0.4.1"
source = "git+https://github.com/Kuska-ssb/ssb#fb7062de606e7c9cae8dd4df402a122db46c1b77"
dependencies = [ dependencies = [
"async-std", "async-std",
"async-stream 0.2.1", "async-stream 0.2.1",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "golgi" name = "golgi"
version = "0.1.1" version = "0.1.2"
edition = "2021" edition = "2021"
authors = ["Max Fowler <max@mfowler.info>", "Andrew Reid <glyph@mycelial.technology>"] authors = ["Max Fowler <max@mfowler.info>", "Andrew Reid <glyph@mycelial.technology>"]
readme = "README.md" readme = "README.md"
@ -19,7 +19,8 @@ futures = "0.3.21"
hex = "0.4.3" hex = "0.4.3"
kuska-handshake = { version = "0.2.0", features = ["async_std"] } kuska-handshake = { version = "0.2.0", features = ["async_std"] }
kuska-sodiumoxide = "0.2.5-0" 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 = { version = "1", features = ["derive"] }
serde_json = "1" serde_json = "1"
sha2 = "0.10.2" sha2 = "0.10.2"

View File

@ -20,6 +20,10 @@ pub enum Keystore {
Patchwork, Patchwork,
/// GoSbot default keystore path: `.ssb-go/secret` in the user's home directory. /// GoSbot default keystore path: `.ssb-go/secret` in the user's home directory.
GoSbot, 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. /// A struct representing a connection with a running sbot.
@ -69,10 +73,26 @@ impl Sbot {
let OwnedIdentity { pk, sk, id } = match keystore { let OwnedIdentity { pk, sk, id } = match keystore {
Keystore::Patchwork => keystore::from_patchwork_local() Keystore::Patchwork => keystore::from_patchwork_local()
.await .await
.expect("couldn't read local secret"), .expect("couldn't read local patchwork secret from default location"),
Keystore::GoSbot => keystore::from_gosbot_local() Keystore::GoSbot => keystore::from_gosbot_local()
.await .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 { Ok(Self {