aboutsummaryrefslogtreecommitdiff
path: root/src/server/auto/cmd
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-04-23 18:27:51 +0000
committerFuwn <[email protected]>2021-04-23 18:27:51 +0000
commit70e6a577025651639c745f029fbeb36922438939 (patch)
tree354756327afab7744392752db12f421a0040e4f3 /src/server/auto/cmd
parentMerge branch 'tokio-re' of https://github.com/Whirlsplash/whirl into tokio-re (diff)
downloadwhirl-70e6a577025651639c745f029fbeb36922438939.tar.xz
whirl-70e6a577025651639c745f029fbeb36922438939.zip
major: :star:
Diffstat (limited to 'src/server/auto/cmd')
-rw-r--r--src/server/auto/cmd/property.rs51
-rw-r--r--src/server/auto/cmd/room.rs53
-rw-r--r--src/server/auto/cmd/session.rs50
3 files changed, 70 insertions, 84 deletions
diff --git a/src/server/auto/cmd/property.rs b/src/server/auto/cmd/property.rs
index b8d0085..e266757 100644
--- a/src/server/auto/cmd/property.rs
+++ b/src/server/auto/cmd/property.rs
@@ -1,37 +1,24 @@
pub fn create_property_update_command() -> [u8; 147] {
- [
- 0x93, 0xFF, 0x10, 0x1B, 0x80, 0x01, 0x0C, 0x77, 0x6F,
- 0x72, 0x6C, 0x64, 0x73, 0x33, 0x64, 0x2E, 0x63, 0x6F,
- 0x6D, 0x1A, 0x80, 0x01, 0x12, 0x6D, 0x61, 0x69, 0x6C,
- 0x2E, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x73, 0x2E, 0x6E,
- 0x65, 0x74, 0x3A, 0x32, 0x35, 0x19, 0x80, 0x01, 0x28,
- 0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x77, 0x77,
- 0x77, 0x2D, 0x64, 0x79, 0x6E, 0x61, 0x6D, 0x69, 0x63,
- 0x2E, 0x75, 0x73, 0x2E, 0x77, 0x6F, 0x72, 0x6C, 0x64,
- 0x73, 0x2E, 0x6E, 0x65, 0x74, 0x2F, 0x63, 0x67, 0x69,
- 0x2D, 0x62, 0x69, 0x6E, 0x18, 0x80, 0x01, 0x1F, 0x68,
- 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x77, 0x77, 0x77,
- 0x2D, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x2E, 0x75,
- 0x73, 0x2E, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x73, 0x2E,
- 0x6E, 0x65, 0x74, 0x0F, 0x80, 0x01, 0x01, 0x31, 0x03,
- 0x80, 0x01, 0x02, 0x32, 0x34, 0x01, 0x80, 0x01, 0x0C,
- 0x57, 0x4F, 0x52, 0x4C, 0x44, 0x53, 0x4D, 0x41, 0x53,
- 0x54, 0x45, 0x52
- ]: [u8; 147]
+ [
+ 0x93, 0xFF, 0x10, 0x1B, 0x80, 0x01, 0x0C, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x73, 0x33, 0x64, 0x2E,
+ 0x63, 0x6F, 0x6D, 0x1A, 0x80, 0x01, 0x12, 0x6D, 0x61, 0x69, 0x6C, 0x2E, 0x77, 0x6F, 0x72, 0x6C,
+ 0x64, 0x73, 0x2E, 0x6E, 0x65, 0x74, 0x3A, 0x32, 0x35, 0x19, 0x80, 0x01, 0x28, 0x68, 0x74, 0x74,
+ 0x70, 0x3A, 0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2D, 0x64, 0x79, 0x6E, 0x61, 0x6D, 0x69, 0x63, 0x2E,
+ 0x75, 0x73, 0x2E, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x73, 0x2E, 0x6E, 0x65, 0x74, 0x2F, 0x63, 0x67,
+ 0x69, 0x2D, 0x62, 0x69, 0x6E, 0x18, 0x80, 0x01, 0x1F, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F,
+ 0x77, 0x77, 0x77, 0x2D, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x2E, 0x75, 0x73, 0x2E, 0x77, 0x6F,
+ 0x72, 0x6C, 0x64, 0x73, 0x2E, 0x6E, 0x65, 0x74, 0x0F, 0x80, 0x01, 0x01, 0x31, 0x03, 0x80, 0x01,
+ 0x02, 0x32, 0x34, 0x01, 0x80, 0x01, 0x0C, 0x57, 0x4F, 0x52, 0x4C, 0x44, 0x53, 0x4D, 0x41, 0x53,
+ 0x54, 0x45, 0x52,
+ ]: [u8; 147]
}
pub fn create_property_request_command() -> [u8; 61] {
- [
- 0x3D, 0x01, 0x06, 0x04, 0x01, 0x30, 0x01, 0x0C,
- 0x57, 0x4F, 0x52, 0x4C, 0x44, 0x53, 0x4D, 0x41,
- 0x53, 0x54, 0x45, 0x52, 0x03, 0x02, 0x32, 0x34,
- 0x0F, 0x01, 0x31, 0x0A, 0x10,
-
- // VAR_SERIAL
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x16, 0x01, 0x30, 0x05, 0x0B, 0x64, 0x69, 0x6D,
- 0x65, 0x6E, 0x73, 0x69, 0x6F, 0x6E, 0x2D, 0x31
- ]: [u8; 61]
+ [
+ 0x3D, 0x01, 0x06, 0x04, 0x01, 0x30, 0x01, 0x0C, 0x57, 0x4F, 0x52, 0x4C, 0x44, 0x53, 0x4D, 0x41,
+ 0x53, 0x54, 0x45, 0x52, 0x03, 0x02, 0x32, 0x34, 0x0F, 0x01, 0x31, 0x0A, 0x10,
+ // VAR_SERIAL: DWLV000000000000
+ 0x44, 0x57, 0x4c, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x16, 0x01, 0x30, 0x05, 0x0B, 0x64, 0x69, 0x6D, 0x65, 0x6E, 0x73, 0x69, 0x6F, 0x6E, 0x2D, 0x31,
+ ]: [u8; 61]
}
diff --git a/src/server/auto/cmd/room.rs b/src/server/auto/cmd/room.rs
index 16c27b8..79786ef 100644
--- a/src/server/auto/cmd/room.rs
+++ b/src/server/auto/cmd/room.rs
@@ -1,36 +1,33 @@
pub fn create_room_id_redirect_command(room_name: &str, room_id: usize) -> Vec<u8> {
- let mut room_id_redirect = vec![
- 0x01, // ?
- 0x1A, // Command type
- ];
+ let mut room_id_redirect = vec![
+ 0x01, // ?
+ 0x1A, // Command type
+ ];
- // room_id_redirect.push(room_id_redirect.len() as u8 + 1); // Data length
- room_id_redirect.push(room_name.len() as u8); // UTF/ room name length
- for i in room_name.bytes() { room_id_redirect.push(i); } // Push `room_name`
- // for i in "<dimension-1>".bytes() { room_id_redirect.push(i); } // Push room number
+ // room_id_redirect.push(room_id_redirect.len() as u8 + 1); // Data length
+ room_id_redirect.push(room_name.len() as u8); // UTF/ room name length
+ for i in room_name.bytes() {
+ room_id_redirect.push(i);
+ } // Push `room_name`
+ // for i in "<dimension-1>".bytes() { room_id_redirect.push(i); } // Push room
+ // number
- // Room number
- room_id_redirect.push(0x00);
- room_id_redirect.push(room_id as u8);
+ // Room number
+ room_id_redirect.push(0x00);
+ room_id_redirect.push(room_id as u8);
- // IP
- room_id_redirect.push(0x00);
- room_id_redirect.push(0x00);
- room_id_redirect.push(0x00);
- room_id_redirect.push(0x00);
+ // IP
+ room_id_redirect.push(0x00);
+ room_id_redirect.push(0x00);
+ room_id_redirect.push(0x00);
+ room_id_redirect.push(0x00);
- // Port
- // for byte in convert_u16_to_two_u8s_be(0x1629).iter() {
- // room_id_redirect.push(*byte);
- // }
- // Port
- // for byte in convert_u16_to_two_u8s_be(5673_i32 as u16).iter() {
- // room_id_redirect.push(*byte);
- // }
- room_id_redirect.push(0x16);
- room_id_redirect.push(0x29);
+ // Port
+ for byte in 5673_u16.to_be_bytes().iter() {
+ room_id_redirect.push(*byte);
+ }
- room_id_redirect.insert(0, room_id_redirect.len() as u8 + 1); // Data length
+ room_id_redirect.insert(0, room_id_redirect.len() as u8 + 1); // Data length
- room_id_redirect
+ room_id_redirect
}
diff --git a/src/server/auto/cmd/session.rs b/src/server/auto/cmd/session.rs
index 5592886..19969dc 100644
--- a/src/server/auto/cmd/session.rs
+++ b/src/server/auto/cmd/session.rs
@@ -1,34 +1,36 @@
-use crate::server::cmd::session::SessionInitializationCommand;
-use bytes::BytesMut;
use std::str::from_utf8;
+use bytes::BytesMut;
+
+use crate::server::cmd::session::SessionInitializationCommand;
+
struct _SessionInitializationCommandServer {
- pub error: usize,
- pub app_name: String,
- pub protocol: usize,
- pub server_type: usize,
- pub serial: String,
- pub private: usize,
- pub channel: String,
+ pub error: usize,
+ pub app_name: String,
+ pub protocol: usize,
+ pub server_type: usize,
+ pub serial: String,
+ pub private: usize,
+ pub channel: String,
}
-pub fn parse_session_initialization_command(
- command: BytesMut
-) -> SessionInitializationCommand {
- SessionInitializationCommand {
- // protocol: command.get(4..4 + command.get(4)).unwrap().to_owned() as usize,
- // client: "".to_string(),
- username: from_utf8(
- command.get(
- 21..(20 + command.get(20).unwrap().to_owned() as usize + 1)
- ).unwrap()
- ).unwrap().to_string(),
- // password: "".to_string()
- }
+pub fn parse_session_initialization_command(command: BytesMut) -> SessionInitializationCommand {
+ SessionInitializationCommand {
+ // protocol: command.get(4..4 + command.get(4)).unwrap().to_owned() as usize,
+ // client: "".to_string(),
+ username: from_utf8(
+ command
+ .get(21..(20 + command.get(20).unwrap().to_owned() as usize + 1))
+ .unwrap(),
+ )
+ .unwrap()
+ .to_string(),
+ // password: "".to_string()
+ }
}
-// pub fn create_session_initialization_command() -> SessionInitializationCommandServer {
-// SessionInitializationCommandServer {
+// pub fn create_session_initialization_command() ->
+// SessionInitializationCommandServer { SessionInitializationCommandServer {
//
// }
// }