mirror of
https://github.com/rustdesk/rustdesk-server.git
synced 2025-07-04 00:35:35 +00:00
uuid
This commit is contained in:
parent
8295278479
commit
2ee99e6140
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -141,7 +141,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "confy"
|
name = "confy"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/open-trade/confy#a95119c82d1e4e3f1d4b46bd668990eff5dce2c8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"directories 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"directories 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.115 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.115 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -465,7 +465,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
"anyhow 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"confy 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"confy 0.4.0 (git+https://github.com/open-trade/confy)",
|
||||||
"copypasta 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"copypasta 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"directories-next 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"directories-next 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"dirs-next 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"dirs-next 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -1722,7 +1722,7 @@ dependencies = [
|
|||||||
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||||
"checksum clipboard-win 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3a093d6fed558e5fe24c3dfc85a68bb68f1c824f440d3ba5aca189e2998786b"
|
"checksum clipboard-win 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3a093d6fed558e5fe24c3dfc85a68bb68f1c824f440d3ba5aca189e2998786b"
|
||||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||||
"checksum confy 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2913470204e9e8498a0f31f17f90a0de801ae92c8c5ac18c49af4819e6786697"
|
"checksum confy 0.4.0 (git+https://github.com/open-trade/confy)" = "<none>"
|
||||||
"checksum constant_time_eq 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
"checksum constant_time_eq 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
||||||
"checksum copypasta 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "865e9675691e2a7dfc806b16ef2dd5dd536e26ea9b8046519767d79be03aeb6a"
|
"checksum copypasta 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "865e9675691e2a7dfc806b16ef2dd5dd536e26ea9b8046519767d79be03aeb6a"
|
||||||
"checksum core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
|
"checksum core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 3ac832109bb75284a1d195a47300498e3bddc277
|
Subproject commit dc39de26981c2916c053762eef6961f6b659fb0c
|
@ -27,6 +27,7 @@ use std::{
|
|||||||
struct Peer {
|
struct Peer {
|
||||||
socket_addr: SocketAddr,
|
socket_addr: SocketAddr,
|
||||||
last_reg_time: Instant,
|
last_reg_time: Instant,
|
||||||
|
uuid: Vec<u8>,
|
||||||
pk: Vec<u8>,
|
pk: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ impl Default for Peer {
|
|||||||
last_reg_time: Instant::now()
|
last_reg_time: Instant::now()
|
||||||
.checked_sub(std::time::Duration::from_secs(3600))
|
.checked_sub(std::time::Duration::from_secs(3600))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
uuid: Vec::new(),
|
||||||
pk: Vec::new(),
|
pk: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,6 +49,8 @@ struct PeerSerde {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
ip: String,
|
ip: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
uuid: Vec<u8>,
|
||||||
|
#[serde(default)]
|
||||||
pk: Vec<u8>,
|
pk: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,18 +69,19 @@ impl PeerMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn update_pk(&mut self, id: String, socket_addr: SocketAddr, pk: Vec<u8>) {
|
fn update_pk(&mut self, id: String, socket_addr: SocketAddr, uuid: Vec<u8>, pk: Vec<u8>) {
|
||||||
let mut lock = self.map.write().unwrap();
|
let mut lock = self.map.write().unwrap();
|
||||||
lock.insert(
|
lock.insert(
|
||||||
id.clone(),
|
id.clone(),
|
||||||
Peer {
|
Peer {
|
||||||
socket_addr,
|
socket_addr,
|
||||||
last_reg_time: Instant::now(),
|
last_reg_time: Instant::now(),
|
||||||
|
uuid: uuid.clone(),
|
||||||
pk: pk.clone(),
|
pk: pk.clone(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
let ip = socket_addr.ip().to_string();
|
let ip = socket_addr.ip().to_string();
|
||||||
self.db.insert(id, PeerSerde { ip, pk });
|
self.db.insert(id, PeerSerde { ip, uuid, pk });
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -91,6 +96,7 @@ impl PeerMap {
|
|||||||
self.map.write().unwrap().insert(
|
self.map.write().unwrap().insert(
|
||||||
id,
|
id,
|
||||||
Peer {
|
Peer {
|
||||||
|
uuid: v.uuid,
|
||||||
pk: v.pk,
|
pk: v.pk,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
@ -189,16 +195,14 @@ impl RendezvousServer {
|
|||||||
let id = rk.id;
|
let id = rk.id;
|
||||||
let mut res = register_pk_response::Result::OK;
|
let mut res = register_pk_response::Result::OK;
|
||||||
if let Some(peer) = self.pm.get(&id).await {
|
if let Some(peer) = self.pm.get(&id).await {
|
||||||
if peer.pk.is_empty() {
|
if peer.uuid != rk.uuid {
|
||||||
self.pm.update_pk(id, addr, rk.pk);
|
log::warn!("Peer {} pk mismatch: {:?} vs {:?}", id, rk.uuid, peer.uuid);
|
||||||
} else {
|
res = register_pk_response::Result::UUID_MISMATCH;
|
||||||
if peer.pk != rk.pk {
|
} else if peer.pk != rk.pk {
|
||||||
log::warn!("Peer {} pk mismatch: {:?} vs {:?}", id, rk.pk, peer.pk);
|
self.pm.update_pk(id, addr, rk.uuid, rk.pk);
|
||||||
res = register_pk_response::Result::PK_MISMATCH;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.pm.update_pk(id, addr, rk.pk);
|
self.pm.update_pk(id, addr, rk.uuid, rk.pk);
|
||||||
}
|
}
|
||||||
let mut msg_out = RendezvousMessage::new();
|
let mut msg_out = RendezvousMessage::new();
|
||||||
msg_out.set_register_pk_response(RegisterPkResponse {
|
msg_out.set_register_pk_response(RegisterPkResponse {
|
||||||
@ -260,11 +264,11 @@ impl RendezvousServer {
|
|||||||
let tx = self.tx.clone();
|
let tx = self.tx.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let v = pm.db.get(id.clone()).await;
|
let v = pm.db.get(id.clone()).await;
|
||||||
let pk = {
|
let (uuid, pk) = {
|
||||||
if let Some(v) = super::SledAsync::deserialize::<PeerSerde>(&v) {
|
if let Some(v) = super::SledAsync::deserialize::<PeerSerde>(&v) {
|
||||||
v.pk
|
(v.uuid, v.pk)
|
||||||
} else {
|
} else {
|
||||||
Vec::new()
|
(Vec::new(), Vec::new())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let mut msg_out = RendezvousMessage::new();
|
let mut msg_out = RendezvousMessage::new();
|
||||||
@ -278,6 +282,7 @@ impl RendezvousServer {
|
|||||||
Peer {
|
Peer {
|
||||||
socket_addr,
|
socket_addr,
|
||||||
last_reg_time,
|
last_reg_time,
|
||||||
|
uuid,
|
||||||
pk,
|
pk,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user