This commit is contained in:
rustdesk 2023-02-08 16:00:12 +08:00
parent 33f54ba5aa
commit 7e307a5a1c
11 changed files with 19 additions and 21 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@ debian/debhelper-build-stamp
.vscode
src/version.rs
db_v2.sqlite3
test.*

View File

@ -2,7 +2,7 @@ fn main() {
let out_dir = format!("{}/protos", std::env::var("OUT_DIR").unwrap());
std::fs::create_dir_all(&out_dir).unwrap();
protobuf_codegen::Codegen::new()
.pure()
.out_dir(out_dir)

View File

@ -1 +1 @@
include!(concat!(env!("OUT_DIR"), "/protos/mod.rs"));
include!(concat!(env!("OUT_DIR"), "/protos/mod.rs"));

View File

@ -134,7 +134,7 @@ pub fn gen_sk(wait: u64) -> (String, Option<sign::SecretKey>) {
}
(pk, sk) = gen_func();
}
let pub_file = format!("{}.pub", sk_file);
let pub_file = format!("{sk_file}.pub");
if let Ok(mut f) = std::fs::File::create(&pub_file) {
f.write_all(pk.as_bytes()).ok();
if let Ok(mut f) = std::fs::File::create(sk_file) {

View File

@ -13,10 +13,9 @@ fn main() -> ResultType<()> {
.write_mode(WriteMode::Async)
.start()?;
let args = format!(
"-p, --port=[NUMBER(default={})] 'Sets the listening port'
"-p, --port=[NUMBER(default={RELAY_PORT})] 'Sets the listening port'
-k, --key=[KEY] 'Only allow the client with the same key'
",
RELAY_PORT,
);
let matches = App::new("hbbr")
.version(version::VERSION)

View File

@ -3,4 +3,5 @@ pub use rendezvous_server::*;
pub mod common;
mod database;
mod peer;
#[rustfmt::skip]
mod version;

View File

@ -15,16 +15,14 @@ fn main() -> ResultType<()> {
.start()?;
let args = format!(
"-c --config=[FILE] +takes_value 'Sets a custom config file'
-p, --port=[NUMBER(default={})] 'Sets the listening port'
-p, --port=[NUMBER(default={RENDEZVOUS_PORT})] 'Sets the listening port'
-s, --serial=[NUMBER(default=0)] 'Sets configure update serial number'
-R, --rendezvous-servers=[HOSTS] 'Sets rendezvous servers, seperated by colon'
-u, --software-url=[URL] 'Sets download url of RustDesk software of newest version'
-r, --relay-servers=[HOST] 'Sets the default relay servers, seperated by colon'
-M, --rmem=[NUMBER(default={})] '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'
-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'",
RENDEZVOUS_PORT,
RMEM,
);
init_args(&args, "hbbs", "RustDesk ID/Rendezvous Server");
let port = get_arg_or("port", RENDEZVOUS_PORT.to_string()).parse::<i32>()?;

View File

@ -77,7 +77,7 @@ impl PeerMap {
}
#[cfg(not(windows))]
{
db = format!("./{}", db);
db = format!("./{db}");
}
db
});

View File

@ -240,7 +240,7 @@ async fn check_cmd(cmd: &str, limiter: Limiter) -> String {
}
} else {
unsafe {
res = format!("{}\n", DOWNGRADE_THRESHOLD);
res = format!("{DOWNGRADE_THRESHOLD}\n");
}
}
}

View File

@ -93,7 +93,7 @@ impl RendezvousServer {
#[tokio::main(flavor = "multi_thread")]
pub async fn start(port: i32, serial: i32, key: &str, rmem: usize) -> ResultType<()> {
let (key, sk) = Self::get_server_sk(key);
let addr = format!("0.0.0.0:{}", port);
let addr = format!("0.0.0.0:{port}");
let nat_port = port - 1;
let ws_port = port + 2;
let pm = PeerMap::new().await?;

View File

@ -20,7 +20,7 @@ Available Commands:
}
fn error_then_help(msg: &str) {
println!("ERROR: {}\n", msg);
println!("ERROR: {msg}\n");
print_help();
}
@ -74,7 +74,7 @@ fn validate_keypair(pk: &str, sk: &str) -> ResultType<()> {
fn doctor_tcp(address: std::net::IpAddr, port: &str, desc: &str) {
let start = std::time::Instant::now();
let conn = format!("{}:{}", address, port);
let conn = format!("{address}:{port}");
if let Ok(_stream) = TcpStream::connect(conn.as_str()) {
let elapsed = std::time::Instant::now().duration_since(start);
println!(
@ -84,12 +84,12 @@ fn doctor_tcp(address: std::net::IpAddr, port: &str, desc: &str) {
elapsed.as_millis()
);
} else {
println!("TCP Port {} ({}): ERROR", port, desc);
println!("TCP Port {port} ({desc}): ERROR");
}
}
fn doctor_ip(server_ip_address: std::net::IpAddr, server_address: Option<&str>) {
println!("\nChecking IP address: {}", server_ip_address);
println!("\nChecking IP address: {server_ip_address}");
println!("Is IPV4: {}", server_ip_address.is_ipv4());
println!("Is IPV6: {}", server_ip_address.is_ipv6());
@ -98,11 +98,10 @@ fn doctor_ip(server_ip_address: std::net::IpAddr, server_address: Option<&str>)
let reverse = lookup_addr(&server_ip_address).unwrap();
if let Some(server_address) = server_address {
if reverse == server_address {
println!("Reverse DNS lookup: '{}' MATCHES server address", reverse);
println!("Reverse DNS lookup: '{reverse}' MATCHES server address");
} else {
println!(
"Reverse DNS lookup: '{}' DOESN'T MATCH server address '{}'",
reverse, server_address
"Reverse DNS lookup: '{reverse}' DOESN'T MATCH server address '{server_address}'"
);
}
}
@ -124,7 +123,7 @@ fn doctor(server_address_unclean: &str) {
let server_address3 = server_address_unclean.trim();
let server_address2 = server_address3.to_lowercase();
let server_address = server_address2.as_str();
println!("Checking server: {}\n", server_address);
println!("Checking server: {server_address}\n");
if let Ok(server_ipaddr) = server_address.parse::<IpAddr>() {
// user requested an ip address
doctor_ip(server_ipaddr, None);
@ -155,7 +154,7 @@ fn main() {
}
let res = validate_keypair(args[2].as_str(), args[3].as_str());
if let Err(e) = res {
println!("{}", e);
println!("{e}");
process::exit(0x0001);
}
println!("Key pair is VALID");