|
|
@ -82,14 +82,14 @@ impl<EG: EntityGateway> LoginServerState<EG> { |
|
|
|
fn validate_login(&mut self, pkt: &Login) -> Vec<SendLoginPacket> {
|
|
|
|
match get_login_status(&self.entity_gateway, pkt) {
|
|
|
|
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 = u32::from_ne_bytes(ip.octets());
|
|
|
|
vec![response,
|
|
|
|
SendLoginPacket::RedirectClient(RedirectClient::new(ip, crate::login::character::CHARACTER_PORT))]
|
|
|
|
},
|
|
|
|
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::*;
|
|
|
|
|
|
|
|
const LOGIN_PACKET: RecvLoginPacket = RecvLoginPacket::Login(Login {
|
|
|
|
flag: 0,
|
|
|
|
tag: 65536,
|
|
|
|
guildcard: 0,
|
|
|
|
version: 65,
|
|
|
|
unknown1: [0, 0, 0, 255, 0, 14],
|
|
|
|
team: 0,
|
|
|
|
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,
|
|
|
|
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),
|
|
|
|
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],
|
|
|
|
hwinfo: [129, 1, 1, 1, 1, 1, 1, 1],
|
|
|
|
security_data: [74, 97, 107, 101, 115, 101, 114, 118, 50, 48, 50, 48, 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],
|
|
|
|
});
|
|
|
|
tag: 65536,
|
|
|
|
guildcard: 0,
|
|
|
|
version: 65,
|
|
|
|
unknown1: [0, 0, 0, 255, 0, 14],
|
|
|
|
team: 0,
|
|
|
|
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,
|
|
|
|
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),
|
|
|
|
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],
|
|
|
|
hwinfo: [129, 1, 1, 1, 1, 1, 1, 1],
|
|
|
|
session: Session {
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_correct_login() {
|
|
|
@ -183,8 +188,14 @@ mod test { |
|
|
|
tag: 65536,
|
|
|
|
guildcard: 0,
|
|
|
|
team_id: 0,
|
|
|
|
security_data: [74, 97, 107, 101, 115, 101, 114, 118, 50, 48, 50, 48, 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: Session {
|
|
|
|
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
|
|
|
|
})),
|
|
|
|
(ClientId(1), SendLoginPacket::RedirectClient(RedirectClient {
|
|
|
@ -214,8 +225,14 @@ mod test { |
|
|
|
tag: 65536,
|
|
|
|
guildcard: 0,
|
|
|
|
team_id: 0,
|
|
|
|
security_data: [74, 97, 107, 101, 115, 101, 114, 118, 50, 48, 50, 48, 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: Session {
|
|
|
|
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
|
|
|
|
}))])
|
|
|
|
}
|
|
|
@ -251,8 +268,14 @@ mod test { |
|
|
|
tag: 65536,
|
|
|
|
guildcard: 0,
|
|
|
|
team_id: 0,
|
|
|
|
security_data: [74, 97, 107, 101, 115, 101, 114, 118, 50, 48, 50, 48, 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: Session {
|
|
|
|
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
|
|
|
|
}))])
|
|
|
|
}
|
|
|
|