Skip to content

Commit

Permalink
feat: limit unwanted access (thanks tonylu00)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeltorio committed Oct 11, 2024
1 parent 8f44bf7 commit 584a356
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hbbs"
version = "1.1.99-45a"
version = "1.1.99-46"
authors = ["sctg <[email protected]>", "rustdesk <[email protected]>"]
edition = "2021"
build = "build.rs"
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ RestartSec=10
WantedBy=multi-user.target
```

# Limit unwanted access

The `--logged-in-only` option or the `LOGGED_IN_ONLY=Y` environment setting is available for the hbbs server. This option will limit the control to logged in users only.
Even if this option is set users will still be able to register in the Renvez-vous server but won't be able to control another one.

# RustDesk Server Program

[![build](https://github.com/sctg-development/sctgdesk-server/actions/workflows/multiarch-docker-hub.yml/badge.svg)](https://github.com/sctg-development/sctgdesk-server/actions/workflows/multiarch-docker-hub.yml)
Expand Down
3 changes: 3 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ pub fn init_args(args: &str, name: &str, about: &str) {
}
}
}
if matches.is_present("logged-in-only") {
std::env::set_var("LOGGED_IN_ONLY", "Y");
}
for (k, v) in matches.args {
if let Some(v) = v.vals.first() {
std::env::set_var(arg_name(k), v.to_string_lossy().to_string());
Expand Down
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ fn main() -> ResultType<()> {
-r, --relay-servers=[HOST] 'Sets the default relay servers, separated by comma'
-M, --rmem=[NUMBER(default={RMEM})] 'Sets UDP recv buffer size, set system rmem_max first, e.g., sudo sysctl -w net.core.rmem_max=52428800. vi /etc/sysctl.conf, net.core.rmem_max=52428800, sudo sysctl –p'
, --mask=[MASK] 'Determine if the connection comes from LAN, e.g. 192.168.0.0/16'
-k, --key=[KEY] 'Only allow the client with the same key'",
-k, --key=[KEY] 'Only allow the client with the same key'
, --logged-in-only 'Only allow logged in user to control'",
);
init_args(&args, "hbbs", "RustDesk ID/Rendezvous Server");
let port = get_arg_or("port", RENDEZVOUS_PORT.to_string()).parse::<i32>()?;
Expand All @@ -86,7 +87,7 @@ fn main() -> ResultType<()> {
}
let rmem = get_arg("rmem").parse::<usize>().unwrap_or(RMEM);
let serial: i32 = get_arg("serial").parse().unwrap_or(0);

std::env::set_var("MAIN_PKG_VERSION", env!("CARGO_PKG_VERSION"));
let handle = thread::spawn(|| {
let rt = rocket::tokio::runtime::Runtime::new().unwrap();
Expand Down
2 changes: 2 additions & 0 deletions src/rendezvous_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,8 @@ impl RendezvousServer {
});
return Ok((msg_out, None));
}
// For limiting abuse, only allow logged in users to punch hole
// if LOGGED_IN_ONLY=Y is set in env or --logged-in-only is passed
if ph.token.is_empty() && std::env::var("LOGGED_IN_ONLY")
.unwrap_or_default()
.to_uppercase()
Expand Down

0 comments on commit 584a356

Please sign in to comment.