From 89029967ec51285a71939a3bd907d7dbfbccb6c0 Mon Sep 17 00:00:00 2001 From: magine Date: Tue, 20 Aug 2024 17:13:28 +0800 Subject: [PATCH] chore: adjust access client api --- src/access.rs | 9 ++------- src/lib.rs | 3 +-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/access.rs b/src/access.rs index d5fbb0f..5ffda22 100644 --- a/src/access.rs +++ b/src/access.rs @@ -8,7 +8,6 @@ use serde::Deserialize; const ACCESS_TTL: Duration = Duration::from_secs(10 * 60); pub struct AccessClient { - local_id: libp2p::PeerId, endpoint: reqwest::Url, client: reqwest::Client, cache: HashMap, @@ -20,9 +19,8 @@ struct AccessClientResponse { } impl AccessClient { - pub fn new(local_id: libp2p::PeerId, endpoint: reqwest::Url) -> AccessClient { + pub fn new(endpoint: reqwest::Url) -> AccessClient { AccessClient { - local_id, endpoint, client: reqwest::Client::new(), cache: HashMap::default(), @@ -31,10 +29,7 @@ impl AccessClient { async fn request_endpoint(&mut self, peer: &PeerId) -> Result { let url = self.endpoint.join("access-control").unwrap(); - let params = [ - ("device", self.local_id.to_string()), - ("user", peer.to_string()), - ]; + let params = [("peer_id", peer.to_string())]; let response = self .client diff --git a/src/lib.rs b/src/lib.rs index 1116d5e..e9772da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -119,8 +119,7 @@ impl PProxy { let (command_tx, command_rx) = mpsc::channel(DEFAULT_CHANNEL_SIZE); let swarm = crate::p2p::new_swarm(keypair, listen_addr) .map_err(|e| Error::Libp2pSwarmCreateError(e.to_string()))?; - let access_client = access_server_endpoint - .map(|endpoint| AccessClient::new(*swarm.local_peer_id(), endpoint)); + let access_client = access_server_endpoint.map(AccessClient::new); Ok(( Self {