aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorrustdesk <[email protected]>2023-02-08 16:00:12 +0800
committerrustdesk <[email protected]>2023-02-08 16:00:12 +0800
commit7e307a5a1cc8cad6eaf2449309c0afbaa687024c (patch)
tree10078a5737c71a229df632f3319ff3bfd7a82806 /src
parent33f54ba5aae1c2a4a3cc5fc46160b41e6eb84c7b (diff)
downloadrustdesk-server-7e307a5a1cc8cad6eaf2449309c0afbaa687024c.tar.gz
rustdesk-server-7e307a5a1cc8cad6eaf2449309c0afbaa687024c.zip
CI
Diffstat (limited to 'src')
-rw-r--r--src/common.rs2
-rw-r--r--src/hbbr.rs3
-rw-r--r--src/lib.rs1
-rw-r--r--src/main.rs6
-rw-r--r--src/peer.rs2
-rw-r--r--src/relay_server.rs2
-rw-r--r--src/rendezvous_server.rs2
-rw-r--r--src/utils.rs17
8 files changed, 16 insertions, 19 deletions
diff --git a/src/common.rs b/src/common.rs
index 9ea4a1e..078ee6b 100644
--- a/src/common.rs
+++ b/src/common.rs
@@ -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) {
diff --git a/src/hbbr.rs b/src/hbbr.rs
index d7f7932..4c8a784 100644
--- a/src/hbbr.rs
+++ b/src/hbbr.rs
@@ -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)
diff --git a/src/lib.rs b/src/lib.rs
index 8da29a2..9218d32 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -3,4 +3,5 @@ pub use rendezvous_server::*;
pub mod common;
mod database;
mod peer;
+#[rustfmt::skip]
mod version;
diff --git a/src/main.rs b/src/main.rs
index 09119c7..b97fbec 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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>()?;
diff --git a/src/peer.rs b/src/peer.rs
index 4c3ab72..c3bf76c 100644
--- a/src/peer.rs
+++ b/src/peer.rs
@@ -77,7 +77,7 @@ impl PeerMap {
}
#[cfg(not(windows))]
{
- db = format!("./{}", db);
+ db = format!("./{db}");
}
db
});
diff --git a/src/relay_server.rs b/src/relay_server.rs
index 94a5cb3..5e17a56 100644
--- a/src/relay_server.rs
+++ b/src/relay_server.rs
@@ -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");
}
}
}
diff --git a/src/rendezvous_server.rs b/src/rendezvous_server.rs
index e7418db..924c1a2 100644
--- a/src/rendezvous_server.rs
+++ b/src/rendezvous_server.rs
@@ -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?;
diff --git a/src/utils.rs b/src/utils.rs
index b37878a..29d8c37 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -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");