author | Wuzzy <Wuzzy2@mail.ru> |
Wed, 18 Jul 2018 02:05:05 +0200 | |
changeset 13512 | 7e188a28f078 |
parent 13428 | 87a6cad20c90 |
child 13529 | 5359ff75da3a |
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; |
12131 | 6 |
pub const SERVER: mio::Token = mio::Token(1000000000 + 0); |
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) |
|
13421 | 23 |
} |