aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/peer.rs
diff options
context:
space:
mode:
authorrustdesk <[email protected]>2022-07-22 00:28:10 +0800
committerrustdesk <[email protected]>2022-07-22 00:28:10 +0800
commit51d8cd80c1e0b0c1cfb08b139b7e92866389cb48 (patch)
tree0990bde9bfd4def3dde5ecaa12a95f1d7e7f7bd0 /src/peer.rs
parent2d385d88d3769267b9a1011cb877be072202b623 (diff)
downloadrustdesk-server-51d8cd80c1e0b0c1cfb08b139b7e92866389cb48.tar.gz
rustdesk-server-51d8cd80c1e0b0c1cfb08b139b7e92866389cb48.zip
protbuf 3.1 with_bytes
Diffstat (limited to 'src/peer.rs')
-rw-r--r--src/peer.rs23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/peer.rs b/src/peer.rs
index 72999b7..49d440d 100644
--- a/src/peer.rs
+++ b/src/peer.rs
@@ -4,6 +4,7 @@ use hbb_common::{
log,
rendezvous_proto::*,
tokio::sync::{Mutex, RwLock},
+ bytes::Bytes,
ResultType,
};
use serde_derive::{Deserialize, Serialize};
@@ -25,13 +26,12 @@ pub(crate) struct PeerInfo {
pub(crate) ip: String,
}
-#[derive(Clone, Debug)]
pub(crate) struct Peer {
pub(crate) socket_addr: SocketAddr,
pub(crate) last_reg_time: Instant,
pub(crate) guid: Vec<u8>,
- pub(crate) uuid: Vec<u8>,
- pub(crate) pk: Vec<u8>,
+ pub(crate) uuid: Bytes,
+ pub(crate) pk: Bytes,
pub(crate) user: Option<Vec<u8>>,
pub(crate) info: PeerInfo,
pub(crate) disabled: bool,
@@ -44,8 +44,8 @@ impl Default for Peer {
socket_addr: "0.0.0.0:0".parse().unwrap(),
last_reg_time: get_expired_time(),
guid: Vec::new(),
- uuid: Vec::new(),
- pk: Vec::new(),
+ uuid: Bytes::new(),
+ pk: Bytes::new(),
info: Default::default(),
user: None,
disabled: false,
@@ -93,8 +93,8 @@ impl PeerMap {
id: String,
peer: LockPeer,
addr: SocketAddr,
- uuid: Vec<u8>,
- pk: Vec<u8>,
+ uuid: Bytes,
+ pk: Bytes,
ip: String,
) -> register_pk_response::Result {
log::info!("update_pk {} {:?} {:?} {:?}", id, addr, uuid, pk);
@@ -139,8 +139,8 @@ impl PeerMap {
if let Ok(Some(v)) = self.db.get_peer(id).await {
let peer = Peer {
guid: v.guid,
- uuid: v.uuid,
- pk: v.pk,
+ uuid: v.uuid.into(),
+ pk: v.pk.into(),
user: v.user,
info: serde_json::from_str::<PeerInfo>(&v.info).unwrap_or_default(),
disabled: v.status == Some(0),
@@ -177,9 +177,4 @@ impl PeerMap {
pub(crate) async fn is_in_memory(&self, id: &str) -> bool {
self.map.read().await.contains_key(id)
}
-
- #[inline]
- pub(crate) async fn remove(&self, id: &str) {
- self.map.write().await.remove(id);
- }
}