author | Wuzzy <Wuzzy2@mail.ru> |
Mon, 03 Sep 2018 20:01:50 +0200 | |
changeset 13757 | f1c66a34f2fe |
parent 13529 | 5359ff75da3a |
child 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) |
|
13421 | 23 |
} |