author | alfadur |
Wed, 27 Jun 2018 02:34:46 +0300 | |
changeset 13428 | 87a6cad20c90 |
parent 13421 | cdf69667593b |
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 |
} |