author | Wuzzy <Wuzzy2@mail.ru> |
Tue, 07 Aug 2018 13:04:02 +0200 | |
changeset 13630 | fe7d2bbf5f3f |
parent 13500 | 5359ff75da3a |
child 13775 | 5fb40c8e5542 |
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; |
13500 | 6 |
pub const SERVER: mio::Token = mio::Token(1_000_000_000); |
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 |
} |