From 68586d6e580477df13911e9bbe42fa2d87a20fec Mon Sep 17 00:00:00 2001 From: Tony Date: Sat, 12 Oct 2024 00:13:06 +0800 Subject: [PATCH] feat: control end need to login before access --- src/rendezvous_server.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/rendezvous_server.rs b/src/rendezvous_server.rs index 75457df2..8eb58e01 100644 --- a/src/rendezvous_server.rs +++ b/src/rendezvous_server.rs @@ -813,6 +813,18 @@ impl RendezvousServer { }); return Ok((msg_out, None)); } + if ph.token.is_empty() && std::env::var("LOGGED_IN_ONLY") + .unwrap_or_default() + .to_uppercase() + == "Y" + { + let mut msg_out = RendezvousMessage::new(); + msg_out.set_punch_hole_response(PunchHoleResponse { + other_failure: String::from("The connection is not allowed. You have not logged in."), + ..Default::default() + }); + return Ok((msg_out, None)); + } let id = ph.id; // punch hole request from A, relay to B, // check if in same intranet first,