feat(auth protocol): login(1) method
This commit is contained in:
parent
44bcad7eda
commit
6984a20bdd
3 changed files with 32 additions and 2 deletions
24
src/protocols/auth/method_login.rs
Normal file
24
src/protocols/auth/method_login.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
use std::io::Cursor;
|
||||||
|
use log::error;
|
||||||
|
use crate::nex::account::Account;
|
||||||
|
use crate::protocols::auth::method_login_ex::login_ex;
|
||||||
|
use crate::rmc::message::RMCMessage;
|
||||||
|
use crate::rmc::response::{ErrorCode, RMCResponseResult};
|
||||||
|
use crate::rmc::structures::any::Any;
|
||||||
|
use crate::rmc::structures::RmcSerialize;
|
||||||
|
|
||||||
|
pub fn login(rmcmessage: &RMCMessage, name: &str) -> RMCResponseResult{
|
||||||
|
rmcmessage.error_result_with_code(ErrorCode::Core_NotImplemented)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn login_raw_params(rmcmessage: &RMCMessage, account: &Account) -> RMCResponseResult{
|
||||||
|
let mut reader = Cursor::new(&rmcmessage.rest_of_data);
|
||||||
|
|
||||||
|
let Ok(str) = String::deserialize(&mut reader) else {
|
||||||
|
error!("error reading packet");
|
||||||
|
return rmcmessage.error_result_with_code(ErrorCode::Core_InvalidArgument);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
login(rmcmessage, &str)
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
|
use crate::nex::account::Account;
|
||||||
use crate::rmc::message::RMCMessage;
|
use crate::rmc::message::RMCMessage;
|
||||||
use crate::rmc::response::{ErrorCode, RMCResponse, RMCResponseResult};
|
use crate::rmc::response::{ErrorCode, RMCResponse, RMCResponseResult};
|
||||||
use crate::rmc::structures::{string, any, RmcSerialize};
|
use crate::rmc::structures::{string, any, RmcSerialize};
|
||||||
|
|
@ -8,10 +9,12 @@ use crate::rmc::structures::any::Any;
|
||||||
pub fn login_ex(rmcmessage: &RMCMessage, name: &str) -> RMCResponseResult{
|
pub fn login_ex(rmcmessage: &RMCMessage, name: &str) -> RMCResponseResult{
|
||||||
// todo: figure out how the AuthenticationInfo struct works, parse it and validate login info
|
// todo: figure out how the AuthenticationInfo struct works, parse it and validate login info
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return rmcmessage.error_result_with_code(ErrorCode::Core_InvalidArgument);
|
return rmcmessage.error_result_with_code(ErrorCode::Core_InvalidArgument);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn login_ex_raw_params(rmcmessage: &RMCMessage) -> RMCResponseResult{
|
pub fn login_ex_raw_params(rmcmessage: &RMCMessage, account: &Account) -> RMCResponseResult{
|
||||||
let mut reader = Cursor::new(&rmcmessage.rest_of_data);
|
let mut reader = Cursor::new(&rmcmessage.rest_of_data);
|
||||||
|
|
||||||
let Ok(str) = String::deserialize(&mut reader) else {
|
let Ok(str) = String::deserialize(&mut reader) else {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
mod method_login_ex;
|
mod method_login_ex;
|
||||||
|
mod method_login;
|
||||||
|
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use crate::define_protocol;
|
use crate::define_protocol;
|
||||||
use crate::nex::account::Account;
|
use crate::nex::account::Account;
|
||||||
|
use crate::protocols::auth::method_login::login_raw_params;
|
||||||
use crate::protocols::auth::method_login_ex::{login_ex, login_ex_raw_params};
|
use crate::protocols::auth::method_login_ex::{login_ex, login_ex_raw_params};
|
||||||
use crate::rmc::message::RMCMessage;
|
use crate::rmc::message::RMCMessage;
|
||||||
use crate::rmc::response::{ErrorCode, RMCResponse, RMCResponseResult};
|
use crate::rmc::response::{ErrorCode, RMCResponse, RMCResponseResult};
|
||||||
|
|
@ -10,6 +12,7 @@ use crate::rmc::response::{ErrorCode, RMCResponse, RMCResponseResult};
|
||||||
|
|
||||||
define_protocol!{
|
define_protocol!{
|
||||||
10<'a>(account: &'a Account) => {
|
10<'a>(account: &'a Account) => {
|
||||||
|
0x01 => login_raw_params,
|
||||||
0x02 => login_ex_raw_params
|
0x02 => login_ex_raw_params
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue