|
|
@@ -21,11 +21,20 @@ pub struct Post {
|
|
21
|
21
|
email: String,
|
|
22
|
22
|
#[serde(default)]
|
|
23
|
23
|
status: String,
|
|
|
24
|
+ #[serde(default)]
|
|
|
25
|
+ version: String,
|
|
|
26
|
+ #[serde(default)]
|
|
|
27
|
+ next_check_time: u32,
|
|
24
|
28
|
}
|
|
25
|
29
|
|
|
26
|
30
|
const LICENSE_FILE: &'static str = ".license.txt";
|
|
27
|
31
|
|
|
28
|
|
-pub fn check_lic(email: &str) -> bool {
|
|
|
32
|
+pub fn check_lic(email: &str, version: &str) -> bool {
|
|
|
33
|
+ if email.is_empty() {
|
|
|
34
|
+ log::error!("Registered email required (-m option). Please visit https://rustdesk.com/server for more infomration.");
|
|
|
35
|
+ return false;
|
|
|
36
|
+ }
|
|
|
37
|
+
|
|
29
|
38
|
let machine = get_lic();
|
|
30
|
39
|
let path = Path::new(LICENSE_FILE);
|
|
31
|
40
|
if Path::is_file(&path) {
|
|
|
@@ -35,14 +44,9 @@ pub fn check_lic(email: &str) -> bool {
|
|
35
|
44
|
}
|
|
36
|
45
|
}
|
|
37
|
46
|
|
|
38
|
|
- if email.is_empty() {
|
|
39
|
|
- log::error!("Registered email required (-m option). Please visit https://rustdesk.com/server for more infomration.");
|
|
40
|
|
- return false;
|
|
41
|
|
- }
|
|
42
|
|
-
|
|
43
|
|
- match check_email(machine, email.to_owned()) {
|
|
|
47
|
+ match check_email(machine, email.to_owned(), version.to_owned()) {
|
|
44
|
48
|
Ok(v) => {
|
|
45
|
|
- return v;
|
|
|
49
|
+ return true;
|
|
46
|
50
|
}
|
|
47
|
51
|
Err(err) => {
|
|
48
|
52
|
log::error!("{}", err);
|
|
|
@@ -58,12 +62,13 @@ fn write_lic(lic: &str) {
|
|
58
|
62
|
}
|
|
59
|
63
|
}
|
|
60
|
64
|
|
|
61
|
|
-fn check_email(machine: String, email: String) -> ResultType<bool> {
|
|
|
65
|
+fn check_email(machine: String, email: String, version: String) -> ResultType<u32> {
|
|
62
|
66
|
log::info!("Checking email with the server ...");
|
|
63
|
67
|
let resp = minreq::post("http://rustdesk.com/api/check-email")
|
|
64
|
68
|
.with_body(
|
|
65
|
69
|
serde_json::to_string(&Post {
|
|
66
|
70
|
machine: machine.clone(),
|
|
|
71
|
+ version,
|
|
67
|
72
|
email,
|
|
68
|
73
|
..Default::default()
|
|
69
|
74
|
})
|
|
|
@@ -79,10 +84,10 @@ fn check_email(machine: String, email: String) -> ResultType<bool> {
|
|
79
|
84
|
bail!("Verification failure");
|
|
80
|
85
|
}
|
|
81
|
86
|
write_lic(&p.machine);
|
|
|
87
|
+ Ok(p.next_check_time)
|
|
82
|
88
|
} else {
|
|
83
|
89
|
bail!("Server error: {}", resp.reason_phrase);
|
|
84
|
90
|
}
|
|
85
|
|
- Ok(true)
|
|
86
|
91
|
}
|
|
87
|
92
|
|
|
88
|
93
|
fn get_lic() -> String {
|