protocol16 -> photon-protocol
This commit is contained in:
Generated
+8
-8
@@ -337,7 +337,7 @@ dependencies = [
|
|||||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"packet_sniffer 0.1.0",
|
"packet_sniffer 0.1.0",
|
||||||
"protocol16 0.1.0",
|
"photon_protocol 0.1.0",
|
||||||
"simplelog 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"simplelog 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"timer 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"timer 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
@@ -429,6 +429,13 @@ dependencies = [
|
|||||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "photon_protocol"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pnet"
|
name = "pnet"
|
||||||
version = "0.22.0"
|
version = "0.22.0"
|
||||||
@@ -518,13 +525,6 @@ dependencies = [
|
|||||||
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "protocol16"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "python3-sys"
|
name = "python3-sys"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ version = "0.3"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
packet_sniffer = { path = "./lib/packet-sniffer" }
|
packet_sniffer = { path = "./lib/packet-sniffer" }
|
||||||
protocol16 = { path = "./lib/protocol16" }
|
photon_protocol = { path = "./lib/photon-protocol" }
|
||||||
bytes = "0.4"
|
bytes = "0.4"
|
||||||
simplelog = "0.6"
|
simplelog = "0.6"
|
||||||
timer = "0.1"
|
timer = "0.1"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "protocol16"
|
name = "photon_protocol"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Wiktor Mazur <wiktormazur1@gmail.com>"]
|
authors = ["Wiktor Mazur <wiktormazur1@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
use log::*;
|
use log::*;
|
||||||
|
|
||||||
use super::packet::Packet;
|
use super::packet::Packet;
|
||||||
use protocol16::Parameters;
|
use photon_protocol::Parameters;
|
||||||
use protocol16::Value;
|
use photon_protocol::Value;
|
||||||
|
|
||||||
macro_rules! deserialize_number {
|
macro_rules! deserialize_number {
|
||||||
($val:expr, $index:expr, $name:expr) => {
|
($val:expr, $index:expr, $name:expr) => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use protocol16::Parameters;
|
use photon_protocol::Parameters;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Packet {
|
pub struct Packet {
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ pub fn decode(payload: &[u8]) -> Vec<Message>
|
|||||||
let mut cursor = Cursor::new(payload);
|
let mut cursor = Cursor::new(payload);
|
||||||
cursor.advance(3);
|
cursor.advance(3);
|
||||||
|
|
||||||
let cmd_cnt = protocol16::deserialize_byte(&mut cursor).unwrap();
|
let cmd_cnt = photon_protocol::deserialize_byte(&mut cursor).unwrap();
|
||||||
cursor.advance(8);
|
cursor.advance(8);
|
||||||
|
|
||||||
for _ in 0..cmd_cnt {
|
for _ in 0..cmd_cnt {
|
||||||
let cmd_type = protocol16::deserialize_byte(&mut cursor).unwrap();
|
let cmd_type = photon_protocol::deserialize_byte(&mut cursor).unwrap();
|
||||||
cursor.advance(3);
|
cursor.advance(3);
|
||||||
let cmd_length = protocol16::deserialize_integer(&mut cursor).unwrap();
|
let cmd_length = photon_protocol::deserialize_integer(&mut cursor).unwrap();
|
||||||
cursor.advance(4);
|
cursor.advance(4);
|
||||||
|
|
||||||
if cmd_type == LOG_OUT {
|
if cmd_type == LOG_OUT {
|
||||||
@@ -62,15 +62,15 @@ fn on_message(cursor: &mut Cursor<&[u8]>, msg_len: u32) -> Option<Message> {
|
|||||||
let init = cursor.bytes().len();
|
let init = cursor.bytes().len();
|
||||||
cursor.advance(SIGNIFIER_BYTE_LENGTH);
|
cursor.advance(SIGNIFIER_BYTE_LENGTH);
|
||||||
|
|
||||||
let msg_type = protocol16::deserialize_byte(cursor).unwrap();
|
let msg_type = photon_protocol::deserialize_byte(cursor).unwrap();
|
||||||
let operation_length = msg_len - CMD_HEADER_LENGTH - 2;
|
let operation_length = msg_len - CMD_HEADER_LENGTH - 2;
|
||||||
|
|
||||||
let mut payload = Cursor::new(&cursor.bytes()[0..operation_length as usize]);
|
let mut payload = Cursor::new(&cursor.bytes()[0..operation_length as usize]);
|
||||||
|
|
||||||
if msg_type == MSG_TYPE_EVENT {
|
if msg_type == MSG_TYPE_EVENT {
|
||||||
if let Some(event_data) = protocol16::deserialize_event_data(&mut payload) {
|
if let Some(event_data) = photon_protocol::deserialize_event_data(&mut payload) {
|
||||||
if event_data.code != 2 && event_data.parameters.get(&252u8).is_some() {
|
if event_data.code != 2 && event_data.parameters.get(&252u8).is_some() {
|
||||||
if let protocol16::Value::Short(code) = event_data.parameters.get(&252u8)? {
|
if let photon_protocol::Value::Short(code) = event_data.parameters.get(&252u8)? {
|
||||||
let packet = Packet{code: *code as usize, parameters: event_data.parameters};
|
let packet = Packet{code: *code as usize, parameters: event_data.parameters};
|
||||||
debug!("EVENT: [{}] {:?}", packet.code, packet);
|
debug!("EVENT: [{}] {:?}", packet.code, packet);
|
||||||
message = packet.decode();
|
message = packet.decode();
|
||||||
@@ -78,7 +78,7 @@ fn on_message(cursor: &mut Cursor<&[u8]>, msg_len: u32) -> Option<Message> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if msg_type == MSG_TYPE_REQUEST {
|
} else if msg_type == MSG_TYPE_REQUEST {
|
||||||
if let Some(request) = protocol16::deserialize_operation_request(&mut payload) {
|
if let Some(request) = photon_protocol::deserialize_operation_request(&mut payload) {
|
||||||
let code = request.code as usize + REQUEST_CONSTANT;
|
let code = request.code as usize + REQUEST_CONSTANT;
|
||||||
let packet = Packet{code, parameters: request.parameters};
|
let packet = Packet{code, parameters: request.parameters};
|
||||||
debug!("REQUEST: [{}] {:?}", packet.code, packet);
|
debug!("REQUEST: [{}] {:?}", packet.code, packet);
|
||||||
@@ -86,7 +86,7 @@ fn on_message(cursor: &mut Cursor<&[u8]>, msg_len: u32) -> Option<Message> {
|
|||||||
message = packet.decode();
|
message = packet.decode();
|
||||||
}
|
}
|
||||||
} else if msg_type == MSG_TYPE_RESPONSE {
|
} else if msg_type == MSG_TYPE_RESPONSE {
|
||||||
if let Some(response) = protocol16::deserialize_operation_response(&mut payload) {
|
if let Some(response) = photon_protocol::deserialize_operation_response(&mut payload) {
|
||||||
let code = response.code as usize + RESPONSE_CONSTANT;
|
let code = response.code as usize + RESPONSE_CONSTANT;
|
||||||
let packet = Packet{code, parameters: response.parameters};
|
let packet = Packet{code, parameters: response.parameters};
|
||||||
debug!("RESPONSE: [{}] {:?}", packet.code, packet);
|
debug!("RESPONSE: [{}] {:?}", packet.code, packet);
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ extern crate cpython;
|
|||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
extern crate bytes;
|
extern crate bytes;
|
||||||
extern crate packet_sniffer;
|
extern crate packet_sniffer;
|
||||||
extern crate protocol16;
|
extern crate photon_protocol;
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||||
|
|||||||
Reference in New Issue
Block a user