mirror of
https://github.com/rustdesk/rustdesk-server.git
synced 2024-11-27 23:29:00 +08:00
rendezvous_servers
This commit is contained in:
parent
ba9862cd7f
commit
33accfb2ca
46
Cargo.lock
generated
46
Cargo.lock
generated
@ -1,5 +1,10 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "ahash"
|
||||||
|
version = "0.3.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
version = "0.7.13"
|
version = "0.7.13"
|
||||||
@ -298,6 +303,14 @@ dependencies = [
|
|||||||
"libloading 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libloading 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dlv-list"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "downcast-rs"
|
name = "downcast-rs"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
@ -481,6 +494,15 @@ name = "glob"
|
|||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.7.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"ahash 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbb_common"
|
name = "hbb_common"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@ -521,6 +543,7 @@ dependencies = [
|
|||||||
"clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"hbb_common 0.1.0",
|
"hbb_common 0.1.0",
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"rust-ini 0.15.3 (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)",
|
||||||
"serde_derive 1.0.115 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_derive 1.0.115 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 1.0.57 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 1.0.57 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -840,6 +863,15 @@ dependencies = [
|
|||||||
"num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ordered-multimap"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"dlv-list 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"hashbrown 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parking_lot"
|
name = "parking_lot"
|
||||||
version = "0.10.2"
|
version = "0.10.2"
|
||||||
@ -1118,6 +1150,15 @@ dependencies = [
|
|||||||
"crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rust-ini"
|
||||||
|
version = "0.15.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"ordered-multimap 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls"
|
name = "rustls"
|
||||||
version = "0.17.0"
|
version = "0.17.0"
|
||||||
@ -1748,6 +1789,7 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
|
"checksum ahash 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217"
|
||||||
"checksum aho-corasick 0.7.13 (registry+https://github.com/rust-lang/crates.io-index)" = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86"
|
"checksum aho-corasick 0.7.13 (registry+https://github.com/rust-lang/crates.io-index)" = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86"
|
||||||
"checksum andrew 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9b7f09f89872c2b6b29e319377b1fbe91c6f5947df19a25596e121cf19a7b35e"
|
"checksum andrew 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9b7f09f89872c2b6b29e319377b1fbe91c6f5947df19a25596e121cf19a7b35e"
|
||||||
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
||||||
@ -1786,6 +1828,7 @@ dependencies = [
|
|||||||
"checksum dirs-sys 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a"
|
"checksum dirs-sys 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a"
|
||||||
"checksum dirs-sys-next 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c60f7b8a8953926148223260454befb50c751d3c50e1c178c4fd1ace4083c9a"
|
"checksum dirs-sys-next 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c60f7b8a8953926148223260454befb50c751d3c50e1c178c4fd1ace4083c9a"
|
||||||
"checksum dlib 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b11f15d1e3268f140f68d390637d5e76d849782d971ae7063e0da69fe9709a76"
|
"checksum dlib 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b11f15d1e3268f140f68d390637d5e76d849782d971ae7063e0da69fe9709a76"
|
||||||
|
"checksum dlv-list 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1b391911b9a786312a10cb9d2b3d0735adfd5a8113eb3648de26a75e91b0826c"
|
||||||
"checksum downcast-rs 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
"checksum downcast-rs 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
||||||
"checksum either 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cd56b59865bce947ac5958779cfa508f6c3b9497cc762b7e24a12d11ccde2c4f"
|
"checksum either 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cd56b59865bce947ac5958779cfa508f6c3b9497cc762b7e24a12d11ccde2c4f"
|
||||||
"checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
|
"checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
|
||||||
@ -1807,6 +1850,7 @@ dependencies = [
|
|||||||
"checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
|
"checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
|
||||||
"checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
|
"checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
|
||||||
"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||||
|
"checksum hashbrown 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96282e96bfcd3da0d3aa9938bedf1e50df3269b6db08b4876d2da0bb1a0841cf"
|
||||||
"checksum hermit-abi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
|
"checksum hermit-abi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
|
||||||
"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
|
"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
|
||||||
"checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
|
"checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
|
||||||
@ -1844,6 +1888,7 @@ dependencies = [
|
|||||||
"checksum once_cell 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad"
|
"checksum once_cell 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad"
|
||||||
"checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
|
"checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
|
||||||
"checksum ordered-float 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3741934be594d77de1c8461ebcbbe866f585ea616a9753aa78f2bdc69f0e4579"
|
"checksum ordered-float 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3741934be594d77de1c8461ebcbbe866f585ea616a9753aa78f2bdc69f0e4579"
|
||||||
|
"checksum ordered-multimap 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e88f947c6799d5eff50e6cf8a2365c17ac4aa8f8f43aceeedc29b616d872a358"
|
||||||
"checksum parking_lot 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e"
|
"checksum parking_lot 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e"
|
||||||
"checksum parking_lot_core 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3"
|
"checksum parking_lot_core 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3"
|
||||||
"checksum pin-project 0.4.23 (registry+https://github.com/rust-lang/crates.io-index)" = "ca4433fff2ae79342e497d9f8ee990d174071408f28f726d6d83af93e58e48aa"
|
"checksum pin-project 0.4.23 (registry+https://github.com/rust-lang/crates.io-index)" = "ca4433fff2ae79342e497d9f8ee990d174071408f28f726d6d83af93e58e48aa"
|
||||||
@ -1876,6 +1921,7 @@ dependencies = [
|
|||||||
"checksum regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)" = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
|
"checksum regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)" = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
|
||||||
"checksum ring 0.16.15 (registry+https://github.com/rust-lang/crates.io-index)" = "952cd6b98c85bbc30efa1ba5783b8abf12fec8b3287ffa52605b9432313e34e4"
|
"checksum ring 0.16.15 (registry+https://github.com/rust-lang/crates.io-index)" = "952cd6b98c85bbc30efa1ba5783b8abf12fec8b3287ffa52605b9432313e34e4"
|
||||||
"checksum rust-argon2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19"
|
"checksum rust-argon2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19"
|
||||||
|
"checksum rust-ini 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7a3679dd538c876a7b606f3bb951c8a20fc281a0ff7795f59f7cb490e3f979e1"
|
||||||
"checksum rustls 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d4a31f5d68413404705d6982529b0e11a9aacd4839d1d6222ee3b8cb4015e1"
|
"checksum rustls 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d4a31f5d68413404705d6982529b0e11a9aacd4839d1d6222ee3b8cb4015e1"
|
||||||
"checksum rustls-native-certs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a75ffeb84a6bd9d014713119542ce415db3a3e4748f0bfce1e1416cd224a23a5"
|
"checksum rustls-native-certs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a75ffeb84a6bd9d014713119542ce415db3a3e4748f0bfce1e1416cd224a23a5"
|
||||||
"checksum rusttype 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "310942406a39981bed7e12b09182a221a29e0990f3e7e0c971f131922ed135d5"
|
"checksum rusttype 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "310942406a39981bed7e12b09182a221a29e0990f3e7e0c971f131922ed135d5"
|
||||||
|
@ -18,6 +18,7 @@ serde = "1.0"
|
|||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
clap = "2.33"
|
clap = "2.33"
|
||||||
|
rust-ini = "0.15"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["libs/hbb_common"]
|
members = ["libs/hbb_common"]
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 4b0de359f90425ce9c72903b7a9e5fcbe505a5cc
|
Subproject commit 0a95f37bb329b43ab6ac7c1b1753e39e10bc3c74
|
60
src/main.rs
60
src/main.rs
@ -4,14 +4,18 @@
|
|||||||
use clap::App;
|
use clap::App;
|
||||||
use hbb_common::{env_logger::*, log, tokio, ResultType};
|
use hbb_common::{env_logger::*, log, tokio, ResultType};
|
||||||
use hbbs::*;
|
use hbbs::*;
|
||||||
|
use ini::Ini;
|
||||||
const DEFAULT_PORT: &'static str = "21116";
|
const DEFAULT_PORT: &'static str = "21116";
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> ResultType<()> {
|
async fn main() -> ResultType<()> {
|
||||||
init_from_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "info"));
|
init_from_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "info"));
|
||||||
let args = format!(
|
let args = format!(
|
||||||
"-p, --port=[default={}] 'Sets the listening port'
|
"-c --config=[FILE] +takes_value 'Sets a custom config file'
|
||||||
-r, --relay-server=[] 'Sets the default relay server'",
|
-p, --port=[NUMBER(default={})] 'Sets the listening port'
|
||||||
|
-s, --serial=[NUMBER(default={0})] 'Sets configure update serial number'
|
||||||
|
-R, --rendezvous-servers=[HOSTS] 'Sets rendezvous servers, seperated by colon'
|
||||||
|
-r, --relay-server=[HOST] 'Sets the default relay server'",
|
||||||
DEFAULT_PORT
|
DEFAULT_PORT
|
||||||
);
|
);
|
||||||
let matches = App::new("hbbs")
|
let matches = App::new("hbbs")
|
||||||
@ -20,15 +24,49 @@ async fn main() -> ResultType<()> {
|
|||||||
.about("RustDesk Rendezvous Server")
|
.about("RustDesk Rendezvous Server")
|
||||||
.args_from_usage(&args)
|
.args_from_usage(&args)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
let addr = format!(
|
let mut section = None;
|
||||||
"0.0.0.0:{}",
|
let conf; // for holding section
|
||||||
matches.value_of("port").unwrap_or(DEFAULT_PORT)
|
if let Some(config) = matches.value_of("config") {
|
||||||
);
|
if let Ok(v) = Ini::load_from_file(config) {
|
||||||
|
conf = v;
|
||||||
|
section = conf.section(None::<String>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let get_arg = |name: &str, default: &str| -> String {
|
||||||
|
if let Some(v) = matches.value_of(name) {
|
||||||
|
return v.to_owned();
|
||||||
|
} else if let Some(section) = section {
|
||||||
|
if let Some(v) = section.get(name) {
|
||||||
|
return v.to_owned();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return default.to_owned();
|
||||||
|
};
|
||||||
|
let port = get_arg("port", DEFAULT_PORT);
|
||||||
|
let mut relay_server = get_arg("relay-server", "");
|
||||||
|
if !relay_server.contains(":") {
|
||||||
|
relay_server = format!("{}:21117", relay_server);
|
||||||
|
}
|
||||||
|
if !relay_server.parse::<std::net::SocketAddr>().is_ok() {
|
||||||
|
relay_server = "".to_owned();
|
||||||
|
}
|
||||||
|
let serial: i32 = get_arg("serial", "").parse().unwrap_or(0);
|
||||||
|
let rendezvous_servers: Vec<String> = get_arg("rendezvous-servers", "")
|
||||||
|
.split(",")
|
||||||
|
.map(|x| {
|
||||||
|
if !x.contains(":") {
|
||||||
|
format!("{}:21116", x)
|
||||||
|
} else {
|
||||||
|
x.to_owned()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter(|x| x.parse::<std::net::SocketAddr>().is_ok())
|
||||||
|
.collect();
|
||||||
|
let addr = format!("0.0.0.0:{}", port);
|
||||||
log::info!("Listening on {}", addr);
|
log::info!("Listening on {}", addr);
|
||||||
RendezvousServer::start(
|
log::info!("relay-server={}", relay_server);
|
||||||
&addr,
|
log::info!("serial={}", serial);
|
||||||
matches.value_of("relay-server").unwrap_or("").to_owned(),
|
log::info!("rendzvous-servers={:?}", rendezvous_servers);
|
||||||
)
|
RendezvousServer::start(&addr, relay_server, serial, rendezvous_servers).await?;
|
||||||
.await?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -126,10 +126,17 @@ pub struct RendezvousServer {
|
|||||||
pm: PeerMap,
|
pm: PeerMap,
|
||||||
tx: Sender,
|
tx: Sender,
|
||||||
relay_server: String,
|
relay_server: String,
|
||||||
|
serial: i32,
|
||||||
|
rendezvous_servers: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RendezvousServer {
|
impl RendezvousServer {
|
||||||
pub async fn start(addr: &str, relay_server: String) -> ResultType<()> {
|
pub async fn start(
|
||||||
|
addr: &str,
|
||||||
|
relay_server: String,
|
||||||
|
serial: i32,
|
||||||
|
rendezvous_servers: Vec<String>,
|
||||||
|
) -> ResultType<()> {
|
||||||
let mut socket = FramedSocket::new(addr).await?;
|
let mut socket = FramedSocket::new(addr).await?;
|
||||||
let (tx, mut rx) = mpsc::unbounded_channel::<(RendezvousMessage, SocketAddr)>();
|
let (tx, mut rx) = mpsc::unbounded_channel::<(RendezvousMessage, SocketAddr)>();
|
||||||
let mut rs = Self {
|
let mut rs = Self {
|
||||||
@ -137,6 +144,8 @@ impl RendezvousServer {
|
|||||||
pm: PeerMap::new()?,
|
pm: PeerMap::new()?,
|
||||||
tx: tx.clone(),
|
tx: tx.clone(),
|
||||||
relay_server,
|
relay_server,
|
||||||
|
serial,
|
||||||
|
rendezvous_servers,
|
||||||
};
|
};
|
||||||
let mut listener = new_listener(addr, true).await?;
|
let mut listener = new_listener(addr, true).await?;
|
||||||
loop {
|
loop {
|
||||||
@ -219,6 +228,17 @@ impl RendezvousServer {
|
|||||||
if rp.id.len() > 0 {
|
if rp.id.len() > 0 {
|
||||||
log::debug!("New peer registered: {:?} {:?}", &rp.id, &addr);
|
log::debug!("New peer registered: {:?} {:?}", &rp.id, &addr);
|
||||||
self.update_addr(rp.id, addr, socket).await?;
|
self.update_addr(rp.id, addr, socket).await?;
|
||||||
|
if self.serial != rp.serial {
|
||||||
|
let mut msg_out = RendezvousMessage::new();
|
||||||
|
let mut mi = MiscInfo::new();
|
||||||
|
mi.set_configure_update(ConfigUpdate {
|
||||||
|
serial: self.serial,
|
||||||
|
rendezvous_servers: self.rendezvous_servers.clone(),
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
msg_out.set_misc_info(mi);
|
||||||
|
socket.send(&msg_out, addr).await?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(rendezvous_message::Union::register_pk(rk)) => {
|
Some(rendezvous_message::Union::register_pk(rk)) => {
|
||||||
@ -267,9 +287,6 @@ impl RendezvousServer {
|
|||||||
Some(rendezvous_message::Union::local_addr(la)) => {
|
Some(rendezvous_message::Union::local_addr(la)) => {
|
||||||
self.handle_local_addr(&la, addr, Some(socket)).await?;
|
self.handle_local_addr(&la, addr, Some(socket)).await?;
|
||||||
}
|
}
|
||||||
Some(rendezvous_message::Union::system_info(info)) => {
|
|
||||||
log::info!("{}", info.value);
|
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user