mirror of
https://github.com/rosenpass/rosenpass.git
synced 2026-02-27 22:13:12 -08:00
chore(rp): Move remaining sync io in exchange() into spawn_blocking
This commit is contained in:
@@ -428,13 +428,16 @@ impl Drop for WireGuardDevice {
|
|||||||
/// `options`.
|
/// `options`.
|
||||||
pub async fn exchange(options: ExchangeOptions) -> Result<()> {
|
pub async fn exchange(options: ExchangeOptions) -> Result<()> {
|
||||||
// Load the server parameter files
|
// Load the server parameter files
|
||||||
// TODO: Should be async, but right now its now
|
let wgsk = options.private_keys_dir.join("wgsk");
|
||||||
let wgsk = options
|
let rpsk = options.private_keys_dir.join("pqsk");
|
||||||
.private_keys_dir
|
let rppk = options.private_keys_dir.join("pqpk");
|
||||||
.join("wgsk")
|
let (wgsk, rpsk, rppk) = spawn_blocking(move || {
|
||||||
.apply(WgSecretKey::load_b64::<WG_B64_LEN, _>)?;
|
let wgsk = WgSecretKey::load_b64::<WG_B64_LEN, _>(wgsk)?;
|
||||||
let rpsk = options.private_keys_dir.join("pqsk").apply(SSk::load)?;
|
let rpsk = SSk::load(rpsk)?;
|
||||||
let rppk = options.private_keys_dir.join("pqpk").apply(SPk::load)?;
|
let wgpk = SPk::load(rppk)?;
|
||||||
|
anyhow::Ok((wgsk, rpsk, wgpk))
|
||||||
|
})
|
||||||
|
.await??;
|
||||||
|
|
||||||
// Setup the WireGuard device
|
// Setup the WireGuard device
|
||||||
let device = options.dev.as_deref().unwrap_or("rosenpass0");
|
let device = options.dev.as_deref().unwrap_or("rosenpass0");
|
||||||
@@ -471,12 +474,17 @@ pub async fn exchange(options: ExchangeOptions) -> Result<()> {
|
|||||||
.join("wgpk")
|
.join("wgpk")
|
||||||
.apply(tokio::fs::read_to_string)
|
.apply(tokio::fs::read_to_string)
|
||||||
.await?;
|
.await?;
|
||||||
let pqpk = peer.public_keys_dir.join("pqpk").apply(SPk::load)?;
|
let pqpk = peer.public_keys_dir.join("pqpk");
|
||||||
let psk = peer.public_keys_dir.join("psk");
|
let psk = peer.public_keys_dir.join("psk");
|
||||||
|
let (pqpk, psk) = spawn_blocking(move || {
|
||||||
|
let pqpk = SPk::load(pqpk)?;
|
||||||
let psk = psk
|
let psk = psk
|
||||||
.exists()
|
.exists()
|
||||||
.then(|| SymKey::load_b64::<WG_B64_LEN, _>(psk))
|
.then(|| SymKey::load_b64::<WG_B64_LEN, _>(psk))
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
anyhow::Ok((pqpk, psk))
|
||||||
|
})
|
||||||
|
.await??;
|
||||||
|
|
||||||
let mut extra_params: Vec<String> = Vec::with_capacity(6);
|
let mut extra_params: Vec<String> = Vec::with_capacity(6);
|
||||||
if let Some(endpoint) = peer.endpoint {
|
if let Some(endpoint) = peer.endpoint {
|
||||||
|
|||||||
Reference in New Issue
Block a user