security_data -> session
This commit is contained in:
parent
fc7338356b
commit
8b8e4af0f3
@ -135,7 +135,7 @@ struct ClientState {
|
|||||||
user: Option<UserAccount>,
|
user: Option<UserAccount>,
|
||||||
characters: Option<[Option<Character>; 4]>,
|
characters: Option<[Option<Character>; 4]>,
|
||||||
guildcard_data_buffer: Option<Vec<u8>>,
|
guildcard_data_buffer: Option<Vec<u8>>,
|
||||||
security_data: [u8; 40],
|
session: Session,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClientState {
|
impl ClientState {
|
||||||
@ -145,7 +145,7 @@ impl ClientState {
|
|||||||
user: None,
|
user: None,
|
||||||
characters: None,
|
characters: None,
|
||||||
guildcard_data_buffer: None,
|
guildcard_data_buffer: None,
|
||||||
security_data: [0; 40],
|
session: Session::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,15 +197,15 @@ impl<EG: EntityGateway> CharacterServerState<EG> {
|
|||||||
let client = self.clients.get_mut(&id).ok_or(CharacterError::ClientNotFound(id))?;
|
let client = self.clients.get_mut(&id).ok_or(CharacterError::ClientNotFound(id))?;
|
||||||
Ok(match get_login_status(&self.entity_gateway, pkt) {
|
Ok(match get_login_status(&self.entity_gateway, pkt) {
|
||||||
Ok(user) => {
|
Ok(user) => {
|
||||||
let mut response = LoginResponse::by_status(AccountStatus::Ok, [0; 40]);
|
let mut response = LoginResponse::by_status(AccountStatus::Ok, Session::new());
|
||||||
response.guildcard = user.guildcard.map_or(0, |gc| gc) as u32;
|
response.guildcard = user.guildcard.map_or(0, |gc| gc) as u32;
|
||||||
response.team_id = user.team_id.map_or(0, |ti| ti) as u32;
|
response.team_id = user.team_id.map_or(0, |ti| ti) as u32;
|
||||||
client.user = Some(user);
|
client.user = Some(user);
|
||||||
client.security_data = pkt.security_data;
|
client.session = pkt.session;
|
||||||
vec![SendCharacterPacket::LoginResponse(response)]
|
vec![SendCharacterPacket::LoginResponse(response)]
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
vec![SendCharacterPacket::LoginResponse(LoginResponse::by_status(err, [0; 40]))]
|
vec![SendCharacterPacket::LoginResponse(LoginResponse::by_status(err, Session::new()))]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -264,12 +264,11 @@ impl<EG: EntityGateway> CharacterServerState<EG> {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let user = client.user.as_ref().unwrap();
|
let user = client.user.as_ref().unwrap();
|
||||||
client.security_data[0..4].clone_from_slice(&[1,3,3,7]);
|
client.session.action = SessionAction::SelectCharacter;
|
||||||
client.security_data[4] = select.slot as u8;
|
client.session.character_slot = select.slot as u8;
|
||||||
client.security_data[5] = 1;
|
|
||||||
Ok(vec![SendCharacterPacket::LoginResponse(LoginResponse::by_char_select(user.guildcard.unwrap_or(0),
|
Ok(vec![SendCharacterPacket::LoginResponse(LoginResponse::by_char_select(user.guildcard.unwrap_or(0),
|
||||||
user.team_id.unwrap_or(1),
|
user.team_id.unwrap_or(1),
|
||||||
client.security_data)),
|
client.session)),
|
||||||
SendCharacterPacket::CharAck(CharAck {
|
SendCharacterPacket::CharAck(CharAck {
|
||||||
slot: select.slot,
|
slot: select.slot,
|
||||||
code: 1,
|
code: 1,
|
||||||
@ -348,7 +347,7 @@ impl<EG: EntityGateway> ServerState for CharacterServerState<EG> {
|
|||||||
-> Result<Box<dyn Iterator<Item = (ClientId, SendCharacterPacket)>>, CharacterError> {
|
-> Result<Box<dyn Iterator<Item = (ClientId, SendCharacterPacket)>>, CharacterError> {
|
||||||
Ok(match pkt {
|
Ok(match pkt {
|
||||||
RecvCharacterPacket::Login(login) => {
|
RecvCharacterPacket::Login(login) => {
|
||||||
if login.security_data[0..4] == [1,3,3,7] {
|
if login.session.action == SessionAction::SelectCharacter {
|
||||||
Box::new(self.send_ship_list(id, login)?.into_iter().map(move |pkt| (id, pkt)))
|
Box::new(self.send_ship_list(id, login)?.into_iter().map(move |pkt| (id, pkt)))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -398,6 +397,7 @@ impl<EG: EntityGateway> ServerState for CharacterServerState<EG> {
|
|||||||
}
|
}
|
||||||
)].into_iter().map(move |pkt| (id, pkt)))
|
)].into_iter().map(move |pkt| (id, pkt)))
|
||||||
},
|
},
|
||||||
|
// TODO: move USERFLAGS over to SessionAction
|
||||||
RecvCharacterPacket::CharacterPreview(preview) => {
|
RecvCharacterPacket::CharacterPreview(preview) => {
|
||||||
let client = self.clients.get_mut(&id).ok_or(CharacterError::ClientNotFound(id))?;
|
let client = self.clients.get_mut(&id).ok_or(CharacterError::ClientNotFound(id))?;
|
||||||
let mut user = client.user.as_mut().unwrap();
|
let mut user = client.user.as_mut().unwrap();
|
||||||
@ -417,14 +417,13 @@ impl<EG: EntityGateway> ServerState for CharacterServerState<EG> {
|
|||||||
// TODO: dressing room stuff
|
// TODO: dressing room stuff
|
||||||
}
|
}
|
||||||
|
|
||||||
client.security_data[0..4].clone_from_slice(&[1,3,3,7]);
|
client.session.action = SessionAction::SelectCharacter;
|
||||||
client.security_data[4] = preview.slot as u8;
|
client.session.character_slot = preview.slot as u8;
|
||||||
client.security_data[5] = 1;
|
|
||||||
user.flags = 0;
|
user.flags = 0;
|
||||||
self.entity_gateway.set_user(&user);
|
self.entity_gateway.set_user(&user);
|
||||||
Box::new(vec![SendCharacterPacket::LoginResponse(LoginResponse::by_char_select(user.guildcard.unwrap_or(0),
|
Box::new(vec![SendCharacterPacket::LoginResponse(LoginResponse::by_char_select(user.guildcard.unwrap_or(0),
|
||||||
user.team_id.unwrap_or(1),
|
user.team_id.unwrap_or(1),
|
||||||
client.security_data)),
|
client.session)),
|
||||||
SendCharacterPacket::CharAck(CharAck {
|
SendCharacterPacket::CharAck(CharAck {
|
||||||
slot: preview.slot,
|
slot: preview.slot,
|
||||||
code: 0
|
code: 0
|
||||||
|
@ -82,14 +82,14 @@ impl<EG: EntityGateway> LoginServerState<EG> {
|
|||||||
fn validate_login(&mut self, pkt: &Login) -> Vec<SendLoginPacket> {
|
fn validate_login(&mut self, pkt: &Login) -> Vec<SendLoginPacket> {
|
||||||
match get_login_status(&self.entity_gateway, pkt) {
|
match get_login_status(&self.entity_gateway, pkt) {
|
||||||
Ok(_user) => {
|
Ok(_user) => {
|
||||||
let response = SendLoginPacket::LoginResponse(LoginResponse::by_status(AccountStatus::Ok, pkt.security_data));
|
let response = SendLoginPacket::LoginResponse(LoginResponse::by_status(AccountStatus::Ok, pkt.session));
|
||||||
let ip = net::Ipv4Addr::new(127,0,0,1);
|
let ip = net::Ipv4Addr::new(127,0,0,1);
|
||||||
let ip = u32::from_ne_bytes(ip.octets());
|
let ip = u32::from_ne_bytes(ip.octets());
|
||||||
vec![response,
|
vec![response,
|
||||||
SendLoginPacket::RedirectClient(RedirectClient::new(ip, crate::login::character::CHARACTER_PORT))]
|
SendLoginPacket::RedirectClient(RedirectClient::new(ip, crate::login::character::CHARACTER_PORT))]
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
vec![SendLoginPacket::LoginResponse(LoginResponse::by_status(err, pkt.security_data))]
|
vec![SendLoginPacket::LoginResponse(LoginResponse::by_status(err, pkt.session))]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,23 +134,28 @@ mod test {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const LOGIN_PACKET: RecvLoginPacket = RecvLoginPacket::Login(Login {
|
const LOGIN_PACKET: RecvLoginPacket = RecvLoginPacket::Login(Login {
|
||||||
flag: 0,
|
tag: 65536,
|
||||||
tag: 65536,
|
guildcard: 0,
|
||||||
guildcard: 0,
|
version: 65,
|
||||||
version: 65,
|
unknown1: [0, 0, 0, 255, 0, 14],
|
||||||
unknown1: [0, 0, 0, 255, 0, 14],
|
team: 0,
|
||||||
team: 0,
|
username: [116, 101, 115, 116, 117, 115, 101, 114, 0, 0, 0, 0, 0, 0, 0, 0], // utf8_to_array!("testuser", 16),
|
||||||
username: [116, 101, 115, 116, 117, 115, 101, 114, 0, 0, 0, 0, 0, 0, 0, 0], // utf8_to_array!("testuser", 16),
|
unknown2: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
unknown2: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
password: [109, 121, 112, 97, 115, 115, 119, 111, 114, 100, 0, 0, 0, 0, 0, 0], // utf8_to_array!("mypassword", 16),
|
||||||
password: [109, 121, 112, 97, 115, 115, 119, 111, 114, 100, 0, 0, 0, 0, 0, 0], // utf8_to_array!("mypassword", 16),
|
unknown3: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
unknown3: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
0, 0, 0, 0, 0, 0, 0, 0],
|
hwinfo: [129, 1, 1, 1, 1, 1, 1, 1],
|
||||||
hwinfo: [129, 1, 1, 1, 1, 1, 1, 1],
|
session: Session {
|
||||||
security_data: [74, 97, 107, 101, 115, 101, 114, 118, 50, 48, 50, 48, 0, 0, 0, 0,
|
version: [69, 108, 115, 101, 119, 97, 114, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // utf8_to_array!("Elseware", 30),
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
});
|
session_id: 0,
|
||||||
|
interserver_checksum: 0,
|
||||||
|
action: SessionAction::None,
|
||||||
|
character_slot: 0,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_correct_login() {
|
fn test_correct_login() {
|
||||||
@ -183,8 +188,14 @@ mod test {
|
|||||||
tag: 65536,
|
tag: 65536,
|
||||||
guildcard: 0,
|
guildcard: 0,
|
||||||
team_id: 0,
|
team_id: 0,
|
||||||
security_data: [74, 97, 107, 101, 115, 101, 114, 118, 50, 48, 50, 48, 0, 0, 0, 0,
|
session: Session {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
version: [69, 108, 115, 101, 119, 97, 114, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // utf8_to_array!("Elseware", 30),
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
|
session_id: 0,
|
||||||
|
interserver_checksum: 0,
|
||||||
|
action: SessionAction::None,
|
||||||
|
character_slot: 0,
|
||||||
|
},
|
||||||
caps: 258
|
caps: 258
|
||||||
})),
|
})),
|
||||||
(ClientId(1), SendLoginPacket::RedirectClient(RedirectClient {
|
(ClientId(1), SendLoginPacket::RedirectClient(RedirectClient {
|
||||||
@ -214,8 +225,14 @@ mod test {
|
|||||||
tag: 65536,
|
tag: 65536,
|
||||||
guildcard: 0,
|
guildcard: 0,
|
||||||
team_id: 0,
|
team_id: 0,
|
||||||
security_data: [74, 97, 107, 101, 115, 101, 114, 118, 50, 48, 50, 48, 0, 0, 0, 0,
|
session: Session {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
version: [69, 108, 115, 101, 119, 97, 114, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // utf8_to_array!("Elseware", 30),
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
|
session_id: 0,
|
||||||
|
interserver_checksum: 0,
|
||||||
|
action: SessionAction::None,
|
||||||
|
character_slot: 0,
|
||||||
|
},
|
||||||
caps: 258
|
caps: 258
|
||||||
}))])
|
}))])
|
||||||
}
|
}
|
||||||
@ -251,8 +268,14 @@ mod test {
|
|||||||
tag: 65536,
|
tag: 65536,
|
||||||
guildcard: 0,
|
guildcard: 0,
|
||||||
team_id: 0,
|
team_id: 0,
|
||||||
security_data: [74, 97, 107, 101, 115, 101, 114, 118, 50, 48, 50, 48, 0, 0, 0, 0,
|
session: Session {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
version: [69, 108, 115, 101, 119, 97, 114, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // utf8_to_array!("Elseware", 30),
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
|
session_id: 0,
|
||||||
|
interserver_checksum: 0,
|
||||||
|
action: SessionAction::None,
|
||||||
|
character_slot: 0,
|
||||||
|
},
|
||||||
caps: 258
|
caps: 258
|
||||||
}))])
|
}))])
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user