diff --git a/Cargo.lock b/Cargo.lock index 6b4e29f..e0fd4b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -296,7 +296,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b391911b9a786312a10cb9d2b3d0735adfd5a8113eb3648de26a75e91b0826c" dependencies = [ - "rand", + "rand 0.7.3", ] [[package]] @@ -482,7 +482,18 @@ checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" dependencies = [ "cfg-if 0.1.10", "libc", - "wasi", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] @@ -519,7 +530,7 @@ dependencies = [ "protobuf", "protobuf-codegen-pure", "quinn", - "rand", + "rand 0.7.3", "regex", "serde", "serde_derive", @@ -545,6 +556,7 @@ dependencies = [ "mac_address", "machine-uid", "minreq", + "rand 0.8.3", "rocksdb", "rust-ini", "serde", @@ -1014,7 +1026,7 @@ dependencies = [ "bytes", "ct-logs", "err-derive", - "rand", + "rand 0.7.3", "ring", "rustls", "rustls-native-certs", @@ -1038,11 +1050,23 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom", + "getrandom 0.1.15", "libc", - "rand_chacha", - "rand_core", - "rand_hc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + +[[package]] +name = "rand" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" +dependencies = [ + "libc", + "rand_chacha 0.3.0", + "rand_core 0.6.2", + "rand_hc 0.3.0", ] [[package]] @@ -1052,7 +1076,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.2", ] [[package]] @@ -1061,7 +1095,16 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.15", +] + +[[package]] +name = "rand_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" +dependencies = [ + "getrandom 0.2.2", ] [[package]] @@ -1070,7 +1113,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_hc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +dependencies = [ + "rand_core 0.6.2", ] [[package]] @@ -1085,7 +1137,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ - "getrandom", + "getrandom 0.1.15", "redox_syscall", "rust-argon2", ] @@ -1502,6 +1554,12 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + [[package]] name = "wasm-bindgen" version = "0.2.68" diff --git a/Cargo.toml b/Cargo.toml index f48d688..2ee84bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ mac_address = "1.1" whoami = "0.9" base64 = "0.13" cryptoxide = "0.3" +rand = "0.8" [build-dependencies] hbb_common = { path = "libs/hbb_common" } diff --git a/src/lic.rs b/src/lic.rs index 68cf5f3..6b7b78e 100644 --- a/src/lic.rs +++ b/src/lic.rs @@ -2,6 +2,7 @@ use hbb_common::{bail, log, ResultType}; use serde_derive::{Deserialize, Serialize}; use std::io::prelude::*; use std::path::Path; +use rand::Rng; #[derive(Debug, PartialEq, Default, Serialize, Deserialize, Clone)] pub struct Machine { @@ -25,6 +26,8 @@ pub struct Post { version: String, #[serde(default)] next_check_time: u64, + #[serde(default)] + nonce: String, } const LICENSE_FILE: &'static str = ".license.txt"; @@ -90,12 +93,16 @@ fn write_lic(lic: &str) { fn check_email(machine: String, email: String, version: String) -> ResultType { log::info!("Checking email with the license server ..."); + let mut rng = rand::thread_rng(); + let nonce: usize = rng.gen(); + let nonce = nonce.to_string(); let resp = minreq::post("http://rustdesk.com/api/check-email") .with_body( serde_json::to_string(&Post { machine: machine.clone(), version, email, + nonce: nonce.clone(), ..Default::default() }) .unwrap(), @@ -106,10 +113,15 @@ fn check_email(machine: String, email: String, version: String) -> ResultType