diff --git a/server/src/app/mod.rs b/server/src/app/mod.rs index dc2bd97..acad229 100644 --- a/server/src/app/mod.rs +++ b/server/src/app/mod.rs @@ -263,7 +263,7 @@ impl App { use tokio_tungstenite::tungstenite::Message; use futures::SinkExt; - let mut response = PacketStatusResponse::new(); + let mut response = PacketSummaryResponse::new(); if let Some(user) = self.get_user_by_id(user_id).cloned() { @@ -296,7 +296,7 @@ impl App { let mut socket = conn.stream.write().await; socket.send(Message::Binary( - encode_response(CODE_STATUS, response.encode()) + encode_response(CODE_SUMMARY, response.encode()) )).await.ok(); conn_id = conn.next; diff --git a/server/src/manager/data.rs b/server/src/manager/data.rs index 64edcfd..df2212d 100644 --- a/server/src/manager/data.rs +++ b/server/src/manager/data.rs @@ -143,7 +143,7 @@ pub async fn thread_system(mut app:App, bus:Bus) let mut is_valid = true; if request.code != crate::config::REGISTER_CODE.as_bytes() { response.status = STATUS_BAD_CODE; is_valid = false; } - if is_valid && request.handle.len() == 0 { response.status = STATUS_BAD_HANDLE; is_valid = false; } + if is_valid && request.handle.len() == 0 && request.handle.chars().count() <= 24 { response.status = STATUS_BAD_HANDLE; is_valid = false; } if is_valid && request.secret.len() == 0 { response.status = STATUS_BAD_SECRET; is_valid = false; } if is_valid { diff --git a/server/src/protocol/code.rs b/server/src/protocol/code.rs index 238c114..b2bb38c 100644 --- a/server/src/protocol/code.rs +++ b/server/src/protocol/code.rs @@ -29,7 +29,7 @@ pub const CODE_AUTH :u16 = 0x0011; pub const CODE_AUTH_RESUME :u16 = 0x0012; pub const CODE_AUTH_REVOKE :u16 = 0x0013; -pub const CODE_STATUS :u16 = 0x001F; +pub const CODE_SUMMARY :u16 = 0x001F; pub const CODE_SESSION_LIST :u16 = 0x0020; pub const CODE_SESSION_JOIN :u16 = 0x0021; diff --git a/server/src/protocol/packet/auth.rs b/server/src/protocol/packet/auth.rs index aeb972f..a900751 100644 --- a/server/src/protocol/packet/auth.rs +++ b/server/src/protocol/packet/auth.rs @@ -1,4 +1,4 @@ -use crate::util::pack::{pack_u16, unpack_u16}; +use crate::util::pack::{pack_u8, pack_u16, unpack_u16}; use super::Packet; @@ -58,6 +58,7 @@ pub struct PacketAuthResponse { pub status:u16, pub token:[u8; 8], pub secret:[u8; 16], + pub handle:String, } impl PacketAuthResponse { pub fn new() -> Self @@ -66,6 +67,7 @@ impl PacketAuthResponse { status:0, token:[0; 8], secret:[0; 16], + handle:String::new(), } } } @@ -74,10 +76,13 @@ impl Packet for PacketAuthResponse { fn encode(&self) -> Vec { + let handle_bytes = self.handle.as_bytes().to_vec(); [ pack_u16(self.status), self.token.to_vec(), self.secret.to_vec(), + pack_u8(handle_bytes.len() as u8), + handle_bytes, ].concat() } } diff --git a/server/src/protocol/packet/mod.rs b/server/src/protocol/packet/mod.rs index be588a8..25e6e37 100644 --- a/server/src/protocol/packet/mod.rs +++ b/server/src/protocol/packet/mod.rs @@ -5,7 +5,7 @@ mod register; pub use register::*; mod auth; pub use auth::*; mod resume; pub use resume::*; -mod status; pub use status::*; +mod summary; pub use summary::*; mod session_list; pub use session_list::*; //mod session_create; pub use session_create::*; diff --git a/server/src/protocol/packet/status.rs b/server/src/protocol/packet/summary.rs similarity index 82% rename from server/src/protocol/packet/status.rs rename to server/src/protocol/packet/summary.rs index 7d8f19d..fd329f6 100644 --- a/server/src/protocol/packet/status.rs +++ b/server/src/protocol/packet/summary.rs @@ -3,11 +3,11 @@ use crate::util::pack::pack_u16; use super::Packet; #[derive(Clone)] -pub struct PacketStatusResponse { +pub struct PacketSummaryResponse { pub challenge:u16, pub resume:u16, } -impl PacketStatusResponse { +impl PacketSummaryResponse { pub fn new() -> Self { Self { @@ -16,7 +16,7 @@ impl PacketStatusResponse { } } } -impl Packet for PacketStatusResponse { +impl Packet for PacketSummaryResponse { type Data = Self; fn encode(&self) -> Vec diff --git a/www/js/const.js b/www/js/const.js index da28d8f..9f84545 100644 --- a/www/js/const.js +++ b/www/js/const.js @@ -37,7 +37,7 @@ const OpCode = { Resume :0x0012, Deauthenticate :0x0013, - Status :0x001F, + Summary :0x001F, SessionList :0x0020, //SessionJoin :0x0021, @@ -54,6 +54,10 @@ const OpCode = { ChallengeList :0x0062, UserList :0x0100, + UserInfo :0x0101, + + AccountManage :0x1000, + AccountCommit :0x1001, TestResult :0xFFFF, }; diff --git a/www/js/scene.js b/www/js/scene.js index 16804c9..31017d7 100644 --- a/www/js/scene.js +++ b/www/js/scene.js @@ -142,8 +142,12 @@ const SCENES = { let container = document.createElement("section"); let form = document.createElement("form"); + + let tb_handle = UI.textbox("handle", ""); + tb_handle.setAttribute("maxlength", 18); + form.appendChild(UI.table(null, [ - [ UI.label(LANG("handle"), "handle"), UI.textbox("handle", "") ], + [ UI.label(LANG("handle"), "handle"), tb_handle ], [ UI.label(LANG("secret"), "secret"), UI.password("secret") ], ])); diff --git a/www/js/system.js b/www/js/system.js index 09bcdaf..34830e6 100644 --- a/www/js/system.js +++ b/www/js/system.js @@ -131,8 +131,8 @@ function MESSAGE(event) { console.log("RECV Deauthenticate"); } break; - case OpCode.Status: { - console.log("RECV Status"); + case OpCode.Summary: { + console.log("RECV Summary"); if(bytes.length - index == 4) { // Challenge count diff --git a/www/pages/about/main.md b/www/pages/about/main.md index 200f5f7..06b1899 100644 --- a/www/pages/about/main.md +++ b/www/pages/about/main.md @@ -11,17 +11,6 @@ Dzura is a work of [Project Kirisame](https://kirisame.com). © 2024 Yukiri Corporation -## Guidelines - -1. Be polite, respectful, and honorable. - -### Bots - -1. Bots are generally permitted, provided they abide by these rules. -2. While not manidatory, we prefer that bots be labeled as such (e.g. in their handles). -3. Bots should not initiate games or send challenges. - - ## User Privacy This website does not collect any information beyond that used to implement user accounts and gameplay.