author | nemo |
Fri, 12 Apr 2019 11:41:35 -0400 | |
changeset 14813 | 38e66519e585 |
parent 14804 | b3adc030104b |
child 14824 | 92225a708bda |
permissions | -rw-r--r-- |
14478 | 1 |
use base64::encode; |
12126 | 2 |
use mio; |
14478 | 3 |
use std::iter::Iterator; |
12126 | 4 |
|
14804 | 5 |
pub const SERVER_VERSION: u32 = 3; |
14800
f43ab2bd76ae
add a thread for internal server IO and implement account checking with it
alfadur
parents:
14478
diff
changeset
|
6 |
pub const SERVER_TOKEN: mio::Token = mio::Token(1_000_000_000); |
f43ab2bd76ae
add a thread for internal server IO and implement account checking with it
alfadur
parents:
14478
diff
changeset
|
7 |
pub const IO_TOKEN: mio::Token = mio::Token(1_000_000_001); |
13416 | 8 |
|
14478 | 9 |
pub fn is_name_illegal(name: &str) -> bool { |
10 |
name.len() > 40 |
|
11 |
|| name.trim().is_empty() |
|
14802 | 12 |
|| name.trim() != name |
14478 | 13 |
|| name |
14 |
.chars() |
|
15 |
.any(|c| "$()*+?[]^{|}\x7F".contains(c) || '\x00' <= c && c <= '\x1F') |
|
13423 | 16 |
} |
17 |
||
18 |
pub fn to_engine_msg<T>(msg: T) -> String |
|
14478 | 19 |
where |
20 |
T: Iterator<Item = u8> + Clone, |
|
13423 | 21 |
{ |
22 |
let mut tmp = Vec::new(); |
|
23 |
tmp.push(msg.clone().count() as u8); |
|
24 |
tmp.extend(msg); |
|
25 |
encode(&tmp) |
|
13775 | 26 |
} |
27 |
||
28 |
pub fn protocol_version_string(protocol_number: u16) -> &'static str { |
|
29 |
match protocol_number { |
|
30 |
17 => "0.9.7-dev", |
|
31 |
19 => "0.9.7", |
|
32 |
20 => "0.9.8-dev", |
|
33 |
21 => "0.9.8", |
|
34 |
22 => "0.9.9-dev", |
|
35 |
23 => "0.9.9", |
|
36 |
24 => "0.9.10-dev", |
|
37 |
25 => "0.9.10", |
|
38 |
26 => "0.9.11-dev", |
|
39 |
27 => "0.9.11", |
|
40 |
28 => "0.9.12-dev", |
|
41 |
29 => "0.9.12", |
|
42 |
30 => "0.9.13-dev", |
|
43 |
31 => "0.9.13", |
|
44 |
32 => "0.9.14-dev", |
|
45 |
33 => "0.9.14", |
|
46 |
34 => "0.9.15-dev", |
|
47 |
35 => "0.9.14.1", |
|
48 |
37 => "0.9.15", |
|
49 |
38 => "0.9.16-dev", |
|
50 |
39 => "0.9.16", |
|
51 |
40 => "0.9.17-dev", |
|
52 |
41 => "0.9.17", |
|
53 |
42 => "0.9.18-dev", |
|
54 |
43 => "0.9.18", |
|
55 |
44 => "0.9.19-dev", |
|
56 |
45 => "0.9.19", |
|
57 |
46 => "0.9.20-dev", |
|
58 |
47 => "0.9.20", |
|
59 |
48 => "0.9.21-dev", |
|
60 |
49 => "0.9.21", |
|
61 |
50 => "0.9.22-dev", |
|
62 |
51 => "0.9.22", |
|
63 |
52 => "0.9.23-dev", |
|
64 |
53 => "0.9.23", |
|
65 |
54 => "0.9.24-dev", |
|
66 |
55 => "0.9.24", |
|
67 |
56 => "0.9.25-dev", |
|
14477 | 68 |
57 => "0.9.25", |
69 |
58 => "1.0.0-dev", |
|
14478 | 70 |
_ => "Unknown", |
13775 | 71 |
} |
14477 | 72 |
} |