mirror of
https://github.com/rustdesk/rustdesk-server.git
synced 2025-07-01 23:35:38 +00:00
nonce
This commit is contained in:
parent
9518ba3651
commit
26d926838f
82
Cargo.lock
generated
82
Cargo.lock
generated
@ -296,7 +296,7 @@ version = "0.2.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1b391911b9a786312a10cb9d2b3d0735adfd5a8113eb3648de26a75e91b0826c"
|
checksum = "1b391911b9a786312a10cb9d2b3d0735adfd5a8113eb3648de26a75e91b0826c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rand",
|
"rand 0.7.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -482,7 +482,18 @@ checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
"libc",
|
"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]]
|
[[package]]
|
||||||
@ -519,7 +530,7 @@ dependencies = [
|
|||||||
"protobuf",
|
"protobuf",
|
||||||
"protobuf-codegen-pure",
|
"protobuf-codegen-pure",
|
||||||
"quinn",
|
"quinn",
|
||||||
"rand",
|
"rand 0.7.3",
|
||||||
"regex",
|
"regex",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
@ -545,6 +556,7 @@ dependencies = [
|
|||||||
"mac_address",
|
"mac_address",
|
||||||
"machine-uid",
|
"machine-uid",
|
||||||
"minreq",
|
"minreq",
|
||||||
|
"rand 0.8.3",
|
||||||
"rocksdb",
|
"rocksdb",
|
||||||
"rust-ini",
|
"rust-ini",
|
||||||
"serde",
|
"serde",
|
||||||
@ -1014,7 +1026,7 @@ dependencies = [
|
|||||||
"bytes",
|
"bytes",
|
||||||
"ct-logs",
|
"ct-logs",
|
||||||
"err-derive",
|
"err-derive",
|
||||||
"rand",
|
"rand 0.7.3",
|
||||||
"ring",
|
"ring",
|
||||||
"rustls",
|
"rustls",
|
||||||
"rustls-native-certs",
|
"rustls-native-certs",
|
||||||
@ -1038,11 +1050,23 @@ version = "0.7.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
|
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom",
|
"getrandom 0.1.15",
|
||||||
"libc",
|
"libc",
|
||||||
"rand_chacha",
|
"rand_chacha 0.2.2",
|
||||||
"rand_core",
|
"rand_core 0.5.1",
|
||||||
"rand_hc",
|
"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]]
|
[[package]]
|
||||||
@ -1052,7 +1076,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
|
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ppv-lite86",
|
"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]]
|
[[package]]
|
||||||
@ -1061,7 +1095,16 @@ version = "0.5.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
||||||
dependencies = [
|
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]]
|
[[package]]
|
||||||
@ -1070,7 +1113,16 @@ version = "0.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
|
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
|
||||||
dependencies = [
|
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]]
|
[[package]]
|
||||||
@ -1085,7 +1137,7 @@ version = "0.3.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d"
|
checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom",
|
"getrandom 0.1.15",
|
||||||
"redox_syscall",
|
"redox_syscall",
|
||||||
"rust-argon2",
|
"rust-argon2",
|
||||||
]
|
]
|
||||||
@ -1502,6 +1554,12 @@ version = "0.9.0+wasi-snapshot-preview1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
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]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.68"
|
version = "0.2.68"
|
||||||
|
@ -25,6 +25,7 @@ mac_address = "1.1"
|
|||||||
whoami = "0.9"
|
whoami = "0.9"
|
||||||
base64 = "0.13"
|
base64 = "0.13"
|
||||||
cryptoxide = "0.3"
|
cryptoxide = "0.3"
|
||||||
|
rand = "0.8"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
hbb_common = { path = "libs/hbb_common" }
|
hbb_common = { path = "libs/hbb_common" }
|
||||||
|
16
src/lic.rs
16
src/lic.rs
@ -2,6 +2,7 @@ use hbb_common::{bail, log, ResultType};
|
|||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use rand::Rng;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Default, Serialize, Deserialize, Clone)]
|
#[derive(Debug, PartialEq, Default, Serialize, Deserialize, Clone)]
|
||||||
pub struct Machine {
|
pub struct Machine {
|
||||||
@ -25,6 +26,8 @@ pub struct Post {
|
|||||||
version: String,
|
version: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
next_check_time: u64,
|
next_check_time: u64,
|
||||||
|
#[serde(default)]
|
||||||
|
nonce: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
const LICENSE_FILE: &'static str = ".license.txt";
|
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<u64> {
|
fn check_email(machine: String, email: String, version: String) -> ResultType<u64> {
|
||||||
log::info!("Checking email with the license server ...");
|
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")
|
let resp = minreq::post("http://rustdesk.com/api/check-email")
|
||||||
.with_body(
|
.with_body(
|
||||||
serde_json::to_string(&Post {
|
serde_json::to_string(&Post {
|
||||||
machine: machine.clone(),
|
machine: machine.clone(),
|
||||||
version,
|
version,
|
||||||
email,
|
email,
|
||||||
|
nonce: nonce.clone(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
@ -106,10 +113,15 @@ fn check_email(machine: String, email: String, version: String) -> ResultType<u6
|
|||||||
if !p.status.is_empty() {
|
if !p.status.is_empty() {
|
||||||
bail!("{}", p.status);
|
bail!("{}", p.status);
|
||||||
}
|
}
|
||||||
if !verify(&p.machine, &machine) {
|
if !verify(&p.nonce, &nonce) {
|
||||||
bail!("Verification failure");
|
bail!("Verification failure");
|
||||||
}
|
}
|
||||||
write_lic(&p.machine);
|
if !machine.is_empty() {
|
||||||
|
if !verify(&p.machine, &machine) {
|
||||||
|
bail!("Verification failure");
|
||||||
|
}
|
||||||
|
write_lic(&p.machine);
|
||||||
|
}
|
||||||
log::info!("License OK");
|
log::info!("License OK");
|
||||||
let mut wait = p.next_check_time;
|
let mut wait = p.next_check_time;
|
||||||
if wait == 0 {
|
if wait == 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user