mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-24 16:17:44 +00:00
Fix various Clippy warnings
This commit is contained in:
parent
9ca46c53cd
commit
ca5fa8e8b9
6 changed files with 27 additions and 29 deletions
|
@ -23,7 +23,7 @@ async fn get_world_status() -> Json<GateStatus> {
|
|||
|
||||
let config = get_config();
|
||||
Json(GateStatus {
|
||||
status: config.login_open.into(),
|
||||
status: config.worlds_open.into(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ struct Params {
|
|||
launchver: String,
|
||||
}
|
||||
|
||||
async fn top(Query(params): Query<Params>) -> Html<&'static str> {
|
||||
async fn top(Query(_): Query<Params>) -> Html<&'static str> {
|
||||
Html(
|
||||
"\r\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n<html lang=en-GB id=gb>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /></head><form action=\"login.send\" method=\"post\" name=\"mainForm\">\r\n\t\r\n\t\t\r\n\t\t<input type=\"hidden\" name=\"_STORED_\" value=\"42f06e5f4194001a9ad61c8481f435e8b9eac79242f9221d463aa492ab2b3373655adadff3e72dd16a798ee8a222c519848743c97084f1af71854f06050a1f2813e5c3aaf66e5f0ef24dc18588a8cf06758992e42035f7e4f99f85c8b6082200dcabc6a37c7f76ce542eefc1f1798da5e23fd4b46ed17489de5eb8e8a222c5198487433bff5f3433c061ded661b3f33b5f2d2807f5db74747f4dfe8f1fe89f9388f717347bbea9e9ec2931bb6fdc4b11648dfa9e726cdf690d74970a36f7482c12593a5ad7b966c4cf14655e11641f0bb67b8e807377edfa81055480da52031e0ba86ec52f991eb3cb8913c8f807287f3cb5ac4143326f33a4503cf31e021c8f41a5eec01870e0004acc0d0bf2bed65da5eeae3703ae878c20bd7f1167745e96770979146463fa40235e6bba8bdac1273dcbc1256cda0caacbdaad\">\n\r\n\t\t\r\n\t\t<div class=\"form-item type-id\">\r\n\t\t\t<label class=\"item-label\" for=\"sqexid\"><span class=\"label-image-text\" title=\"Square Enix ID\"></span></label>\r\n\t\t\t<input class=\"item-input\" name=\"sqexid\" id=\"sqexid\" type=\"text\" value=\"\" tabindex=\"1\" placeholder=\"ID (Required)\" maxLength=\"16\"\r\n\t\t\t\r\n\t\t\t\t />\r\n\t\t\t\r\n\t\t</div>\r\n\r\n\t\t <div class=\"form-item type-pw\">\r\n\t\t\t<label class=\"item-label\" for=\"password\"><span class=\"label-image-text\" title=\"Square Enix Password\"></span></label>\r\n\t\t\t<input class=\"item-password\" name=\"password\" id=\"password\" type=\"password\" value=\"\" tabindex=\"2\" placeholder=\"Password (Required)\" maxLength=\"32\" autocomplete=\"off\"/>\r\n\t\t</div>\r\n\t\r\n\t\t<div class=\"form-item type-otpw\">\r\n\t\t\t<label class=\"item-label\" for=\"otppw\"><span class=\"label-image-text\" title=\"One-Time Password\"></span></label>\r\n\t\t\t<input class=\"item-otpw\" name=\"otppw\" id=\"otppw\" type=\"text\" value=\"\" tabindex=\"3\" autocomplete=\"off\" maxLength=\"6\" placeholder=\"Password (Optional)\" />\r\n\t\t</div>\r\n\r\n\t\t\r\n\t\t<div class=\"form-item type-remember-id\">\r\n\t\t\t<input name=\"saveid\" id=\"saveid\" type=\"checkbox\" value=\"1\" class=\"item-checkbox\" tabindex=\"4\" />\r\n\t\t\t<label class=\"item-checkbox-label\" for=\"saveid\"><span class=\"label-checkbox-image-text\" title=\"Remember Square Enix ID\"></span></label>\r\n\t\t</div>\r\n\t\t\r\n\r\n\t\t<div class=\"form-item type-submit\">\r\n\t\t\t<button class=\"item-button\" type=\"submit\" tabindex=\"5\" onClick=\"ctrEvent('mainForm')\" id=\"btLogin\"><span class=\"button-image-text\" title=\"Login\"></span></button>\r\n\t\t</div>\r\n\r\n\t</form>\r\n</div>\r\n</body>\r\n</html>\r\n\r\n</html>",
|
||||
)
|
||||
|
@ -33,7 +33,7 @@ struct Input {
|
|||
otppw: String,
|
||||
}
|
||||
|
||||
async fn login_send(Form(input): Form<Input>) -> Html<String> {
|
||||
async fn login_send(Form(_): Form<Input>) -> Html<String> {
|
||||
let sid = generate_sid();
|
||||
Html(format!(
|
||||
"window.external.user(\"login=auth,ok,sid,{sid},terms,1,region,2,etmadd,0,playable,1,ps3pkg,0,maxex,4,product,1\");"
|
||||
|
|
|
@ -63,7 +63,7 @@ fn list_patch_files(dir_path: &str) -> Vec<String> {
|
|||
}
|
||||
|
||||
async fn verify_session(
|
||||
Path((platform, game_version, sid)): Path<(String, String, String)>,
|
||||
Path((platform, _, sid)): Path<(String, String, String)>,
|
||||
) -> impl IntoResponse {
|
||||
let config = get_config();
|
||||
if !config.supports_platform(&platform) {
|
||||
|
|
|
@ -14,24 +14,18 @@ struct GateStatus {
|
|||
}
|
||||
|
||||
async fn root() -> Html<String> {
|
||||
let config = get_config();
|
||||
|
||||
let environment = setup_default_environment();
|
||||
let template = environment.get_template("web.html").unwrap();
|
||||
Html(template.render(context! {}).unwrap())
|
||||
}
|
||||
|
||||
async fn login() -> Html<String> {
|
||||
let config = get_config();
|
||||
|
||||
let environment = setup_default_environment();
|
||||
let template = environment.get_template("login.html").unwrap();
|
||||
Html(template.render(context! {}).unwrap())
|
||||
}
|
||||
|
||||
async fn register() -> Html<String> {
|
||||
let config = get_config();
|
||||
|
||||
let environment = setup_default_environment();
|
||||
let template = environment.get_template("register.html").unwrap();
|
||||
Html(template.render(context! {}).unwrap())
|
||||
|
@ -52,13 +46,16 @@ async fn world_status() -> Html<String> {
|
|||
#[derive(Deserialize, Debug)]
|
||||
#[allow(dead_code)]
|
||||
struct Input {
|
||||
gate_open: Option<String>,
|
||||
login_open: Option<String>,
|
||||
worlds_open: Option<String>,
|
||||
}
|
||||
|
||||
async fn apply(Form(input): Form<Input>) -> Redirect {
|
||||
tracing::info!("Apply config changes...");
|
||||
|
||||
let config = get_config();
|
||||
let mut config = get_config();
|
||||
config.login_open = input.login_open == Some("1".to_string());
|
||||
config.worlds_open = input.worlds_open == Some("1".to_string());
|
||||
|
||||
serde_json::to_writer(&std::fs::File::create("config.json").unwrap(), &config)
|
||||
.expect("TODO: panic message");
|
||||
|
|
|
@ -41,8 +41,7 @@ where
|
|||
|
||||
let size = size - (std::mem::size_of::<u32>() * 4) as u32; // 16 = header size
|
||||
|
||||
let mut data = Vec::new();
|
||||
data.resize(size as usize, 0x0);
|
||||
let mut data = vec![0; size as usize];
|
||||
reader.read_exact(&mut data)?;
|
||||
|
||||
unsafe {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use std::{
|
||||
cmp::{max, min},
|
||||
cmp::min,
|
||||
fs::write,
|
||||
io::Cursor,
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
|
@ -44,7 +44,7 @@ enum SegmentType {
|
|||
key: [u8; 4],
|
||||
},
|
||||
#[brw(magic = 0x3u32)]
|
||||
IPC {
|
||||
Ipc {
|
||||
#[br(parse_with = decrypt, args(size, encryption_key))]
|
||||
#[bw(write_with = encrypt, args(size, encryption_key))]
|
||||
data: IPCSegment,
|
||||
|
@ -98,7 +98,7 @@ impl PacketSegment {
|
|||
+ match &self.segment_type {
|
||||
SegmentType::InitializeEncryption { .. } => 616,
|
||||
SegmentType::InitializationEncryptionResponse { .. } => 640,
|
||||
SegmentType::IPC { data } => data.calc_size(),
|
||||
SegmentType::Ipc { data } => data.calc_size(),
|
||||
SegmentType::KeepAlive { .. } => todo!(),
|
||||
SegmentType::KeepAliveResponse { .. } => 0x8,
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ struct Packet {
|
|||
}
|
||||
|
||||
fn dump(msg: &str, data: &[u8]) {
|
||||
write("packet.bin", data);
|
||||
write("packet.bin", data).unwrap();
|
||||
panic!("{msg} Dumped to packet.bin.");
|
||||
}
|
||||
|
||||
|
@ -152,18 +152,20 @@ async fn send_packet(socket: &mut WriteHalf<TcpStream>, segments: &[PacketSegmen
|
|||
};
|
||||
|
||||
let mut cursor = Cursor::new(Vec::new());
|
||||
packet.write_le_args(
|
||||
packet
|
||||
.write_le_args(
|
||||
&mut cursor,
|
||||
(state.client_key.as_ref().map(|s: &[u8; 16]| s.as_slice()),),
|
||||
);
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let buffer = cursor.into_inner();
|
||||
|
||||
tracing::info!("Wrote response packet to outpacket.bin");
|
||||
write("outpacket.bin", &buffer);
|
||||
write("outpacket.bin", &buffer).unwrap();
|
||||
|
||||
socket
|
||||
.write(&buffer)
|
||||
.write_all(&buffer)
|
||||
.await
|
||||
.expect("Failed to write packet!");
|
||||
}
|
||||
|
@ -216,7 +218,7 @@ pub async fn parse_packet(socket: &mut WriteHalf<TcpStream>, data: &[u8], state:
|
|||
};
|
||||
send_packet(socket, &[response_packet], state).await;
|
||||
}
|
||||
SegmentType::IPC { data } => {
|
||||
SegmentType::Ipc { data } => {
|
||||
match &data.data {
|
||||
IPCStructData::ClientVersionInfo {
|
||||
session_id,
|
||||
|
@ -262,7 +264,7 @@ pub async fn parse_packet(socket: &mut WriteHalf<TcpStream>, data: &[u8], state:
|
|||
let response_packet = PacketSegment {
|
||||
source_actor: 0,
|
||||
target_actor: 0,
|
||||
segment_type: SegmentType::IPC { data: ipc },
|
||||
segment_type: SegmentType::Ipc { data: ipc },
|
||||
};
|
||||
send_packet(socket, &[response_packet], state).await;
|
||||
}
|
||||
|
@ -310,7 +312,7 @@ pub async fn parse_packet(socket: &mut WriteHalf<TcpStream>, data: &[u8], state:
|
|||
let response_packet = PacketSegment {
|
||||
source_actor: 0,
|
||||
target_actor: 0,
|
||||
segment_type: SegmentType::IPC { data: ipc },
|
||||
segment_type: SegmentType::Ipc { data: ipc },
|
||||
};
|
||||
packets.push(response_packet);
|
||||
}
|
||||
|
@ -332,7 +334,7 @@ pub async fn parse_packet(socket: &mut WriteHalf<TcpStream>, data: &[u8], state:
|
|||
let response_packet = PacketSegment {
|
||||
source_actor: 0,
|
||||
target_actor: 0,
|
||||
segment_type: SegmentType::IPC { data: ipc },
|
||||
segment_type: SegmentType::Ipc { data: ipc },
|
||||
};
|
||||
packets.push(response_packet);
|
||||
}
|
||||
|
@ -420,7 +422,7 @@ pub async fn parse_packet(socket: &mut WriteHalf<TcpStream>, data: &[u8], state:
|
|||
let response_packet = PacketSegment {
|
||||
source_actor: 0,
|
||||
target_actor: 0,
|
||||
segment_type: SegmentType::IPC { data: ipc },
|
||||
segment_type: SegmentType::Ipc { data: ipc },
|
||||
};
|
||||
send_packet(socket, &[response_packet], state).await;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue