author | Wuzzy <Wuzzy2@mail.ru> |
Tue, 17 Jul 2018 20:13:41 +0200 | |
changeset 13500 | d9f9e66543d7 |
parent 13423 | 87a6cad20c90 |
child 13524 | 5359ff75da3a |
permissions | -rw-r--r-- |
13423 | 1 |
use std::iter::Iterator; |
12126 | 2 |
use mio; |
13423 | 3 |
use base64::{encode}; |
12126 | 4 |
|
12137
193dfdcb0620
- Use logging facilities instead of plain println!
unc0rr
parents:
12126
diff
changeset
|
5 |
pub const PROTOCOL_VERSION : u32 = 3; |
12126 | 6 |
pub const SERVER: mio::Token = mio::Token(1000000000 + 0); |
13416 | 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') |
|
13423 | 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) |
|
13416 | 23 |
} |