Skip to content

Commit

Permalink
Add parse_url_for_rpc function to extract keys from URL
Browse files Browse the repository at this point in the history
  • Loading branch information
tripledoublev committed Nov 28, 2024
1 parent 842d53e commit bfa1b3c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ pub struct RpcClient {
descriptor: RpcServiceDescriptor,
}

pub fn parse_url_for_rpc(url_string: &str) -> Result<RpcKeys> {
let url = Url::parse(url_string)?;

let dht_key = crypto_key_from_query(&url, URL_DHT_KEY)
.map_err(|_| anyhow!("Missing 'dht' key in the URL"))?;
let encryption_key = crypto_key_from_query(&url, URL_ENCRYPTION_KEY)
.map_err(|_| anyhow!("Missing 'enc' key in the URL"))?;

Ok(RpcKeys {
dht_key,
encryption_key,
})
}


impl RpcClient {
pub async fn from_veilid(veilid: VeilidAPI, url: &str) -> Result<Self> {
let routing_context = veilid.routing_context()?;
Expand Down

0 comments on commit bfa1b3c

Please sign in to comment.