author | alfadur |
Fri, 05 Oct 2018 21:43:48 -0400 | |
changeset 13876 | 5df16be168ff |
parent 13806 | 5fb40c8e5542 |
permissions | -rw-r--r-- |
13428 | 1 |
use std::iter::Iterator; |
12131 | 2 |
use mio; |
13428 | 3 |
use base64::{encode}; |
12131 | 4 |
|
12142
193dfdcb0620
- Use logging facilities instead of plain println!
unc0rr
parents:
12131
diff
changeset
|
5 |
pub const PROTOCOL_VERSION : u32 = 3; |
13529 | 6 |
pub const SERVER: mio::Token = mio::Token(1_000_000_000); |
13421 | 7 |
|
8 |
pub fn is_name_illegal(name: &str ) -> bool{ |
|
9 |
name.len() > 40 || |
|
10 |
name.trim().is_empty() || |
|
11 |
name.chars().any(|c| |
|
12 |
"$()*+?[]^{|}\x7F".contains(c) || |
|
13 |
'\x00' <= c && c <= '\x1F') |
|
13428 | 14 |
} |
15 |
||
16 |
pub fn to_engine_msg<T>(msg: T) -> String |
|
17 |
where T: Iterator<Item = u8> + Clone |
|
18 |
{ |
|
19 |
let mut tmp = Vec::new(); |
|
20 |
tmp.push(msg.clone().count() as u8); |
|
21 |
tmp.extend(msg); |
|
22 |
encode(&tmp) |
|
13806 | 23 |
} |
24 |
||
25 |
pub fn protocol_version_string(protocol_number: u16) -> &'static str { |
|
26 |
match protocol_number { |
|
27 |
17 => "0.9.7-dev", |
|
28 |
19 => "0.9.7", |
|
29 |
20 => "0.9.8-dev", |
|
30 |
21 => "0.9.8", |
|
31 |
22 => "0.9.9-dev", |
|
32 |
23 => "0.9.9", |
|
33 |
24 => "0.9.10-dev", |
|
34 |
25 => "0.9.10", |
|
35 |
26 => "0.9.11-dev", |
|
36 |
27 => "0.9.11", |
|
37 |
28 => "0.9.12-dev", |
|
38 |
29 => "0.9.12", |
|
39 |
30 => "0.9.13-dev", |
|
40 |
31 => "0.9.13", |
|
41 |
32 => "0.9.14-dev", |
|
42 |
33 => "0.9.14", |
|
43 |
34 => "0.9.15-dev", |
|
44 |
35 => "0.9.14.1", |
|
45 |
37 => "0.9.15", |
|
46 |
38 => "0.9.16-dev", |
|
47 |
39 => "0.9.16", |
|
48 |
40 => "0.9.17-dev", |
|
49 |
41 => "0.9.17", |
|
50 |
42 => "0.9.18-dev", |
|
51 |
43 => "0.9.18", |
|
52 |
44 => "0.9.19-dev", |
|
53 |
45 => "0.9.19", |
|
54 |
46 => "0.9.20-dev", |
|
55 |
47 => "0.9.20", |
|
56 |
48 => "0.9.21-dev", |
|
57 |
49 => "0.9.21", |
|
58 |
50 => "0.9.22-dev", |
|
59 |
51 => "0.9.22", |
|
60 |
52 => "0.9.23-dev", |
|
61 |
53 => "0.9.23", |
|
62 |
54 => "0.9.24-dev", |
|
63 |
55 => "0.9.24", |
|
64 |
56 => "0.9.25-dev", |
|
65 |
_ => "Unknown" |
|
66 |
} |
|
13421 | 67 |
} |