diff --git a/libs/hbb_common/src/config.rs b/libs/hbb_common/src/config.rs index 66ce5070a..c3d7d23dc 100644 --- a/libs/hbb_common/src/config.rs +++ b/libs/hbb_common/src/config.rs @@ -565,9 +565,6 @@ impl Config { pub fn set_option(k: String, v: String) { let mut config = CONFIG2.write().unwrap(); - if k == "custom-rendezvous-server" { - config.rendezvous_server = "".to_owned(); - } let v2 = if v.is_empty() { None } else { Some(&v) }; if v2 != config.options.get(&k) { if v2.is_none() { diff --git a/src/ipc.rs b/src/ipc.rs index d442362f8..5be2c590c 100644 --- a/src/ipc.rs +++ b/src/ipc.rs @@ -1,3 +1,4 @@ +use crate::rendezvous_mediator::RendezvousMediator; use hbb_common::{ allow_err, bail, bytes, bytes_codec::BytesCodec, @@ -213,7 +214,7 @@ async fn handle(data: Data, stream: &mut Connection) { Config::set_socks(Some(data)); } crate::common::test_nat_type(); - crate::rendezvous_mediator::RendezvousMediator::restart(); + RendezvousMediator::restart(); log::info!("socks updated"); } }, @@ -255,7 +256,14 @@ async fn handle(data: Data, stream: &mut Connection) { allow_err!(stream.send(&Data::Options(Some(v))).await); } Some(value) => { + let v0 = Config::get_option("stop-service"); + let v1 = Config::get_rendezvous_servers(); Config::set_options(value); + if v0 != Config::get_option("stop-service") + || v1 != Config::get_rendezvous_servers() + { + RendezvousMediator::restart(); + } } }, Data::NatType(_) => { diff --git a/src/rendezvous_mediator.rs b/src/rendezvous_mediator.rs index 0cf33e0a3..727a11824 100644 --- a/src/rendezvous_mediator.rs +++ b/src/rendezvous_mediator.rs @@ -37,7 +37,6 @@ pub struct RendezvousMediator { addr: TargetAddr<'static>, host: String, host_prefix: String, - rendezvous_servers: Vec<String>, last_id_pk_registry: String, } @@ -77,7 +76,7 @@ impl RendezvousMediator { let server = server.clone(); let servers = servers.clone(); futs.push(tokio::spawn(async move { - allow_err!(Self::start(server, host, servers).await); + allow_err!(Self::start(server, host).await); // SHOULD_EXIT here is to ensure once one exits, the others also exit. SHOULD_EXIT.store(true, Ordering::SeqCst); })); @@ -88,11 +87,7 @@ impl RendezvousMediator { } } - pub async fn start( - server: ServerPtr, - host: String, - rendezvous_servers: Vec<String>, - ) -> ResultType<()> { + pub async fn start(server: ServerPtr, host: String) -> ResultType<()> { log::info!("start rendezvous mediator of {}", host); let host_prefix: String = host .split(".") @@ -109,7 +104,6 @@ impl RendezvousMediator { addr: Config::get_any_listen_addr().into_target_addr()?, host: host.clone(), host_prefix, - rendezvous_servers, last_id_pk_registry: "".to_owned(), }; @@ -207,8 +201,12 @@ impl RendezvousMediator { }); } Some(rendezvous_message::Union::configure_update(cu)) => { + let v0 = Config::get_rendezvous_servers(); Config::set_option("rendezvous-servers".to_owned(), cu.rendezvous_servers.join(",")); Config::set_serial(cu.serial); + if v0 != Config::get_rendezvous_servers() { + Self::restart(); + } } _ => {} } @@ -223,12 +221,6 @@ impl RendezvousMediator { } }, _ = timer.tick() => { - if Config::get_rendezvous_servers() != rz.rendezvous_servers { - break; - } - if !Config::get_option("stop-service").is_empty() { - break; - } if SHOULD_EXIT.load(Ordering::SeqCst) { break; } diff --git a/src/ui/index.tis b/src/ui/index.tis index d44266b65..acf8dae00 100644 --- a/src/ui/index.tis +++ b/src/ui/index.tis @@ -151,8 +151,8 @@ class MyIdMenu: Reactor.Component { <li #enable-tunnel><span>{svg_checkmark}</span>{translate('Enable TCP Tunneling')}</li> <AudioInputs /> <div .separator /> - <li #whitelist title={translate('whitelist_tip')}>{translate('IP Whitelisting')}</li> <li #custom-server>{translate('ID/Relay Server')}</li> + <li #whitelist title={translate('whitelist_tip')}>{translate('IP Whitelisting')}</li> <li #socks5-server>{translate('Socks5 Proxy')}</li> <div .separator /> <li #stop-service class={service_stopped ? "line-through" : "selected"}><span>{svg_checkmark}</span>{translate("Enable Service")}</li>