Function qsocket::new_knock_sequence
source · pub fn new_knock_sequence(secret: &str, tag: u8) -> Result<[u8; 20], Error>Expand description
Create a new knock packet structure with the given secret and tag.
secret value can be considered as the password for the QSocket connection,
It will be used for generating a 128bit unique identifier (UID) for the connection.
tag value is used internally for QoS purposes.
It specifies the type of connection to the relay server for
more optimized connection performance.
Examples
use qsocket;
use std::iter::Iterator;
let test_case: [u8; 20] = [
0xC0, 0xDE, 0x30, 0x20, 0x2c, 0xb9, 0x62, 0xac, 0x59, 0x07, 0x5b, 0x96, 0x4b, 0x07,
0x15, 0x2d, 0x23, 0x4b, 0x70, 0x1,
];
let knock = match qsocket::new_knock_sequence("123", 0) {
Ok(k) => k,
Err(e) => panic!("{}", e),
};
assert!(knock.iter().eq(test_case.iter()));