it was just causing headaches
This commit is contained in:
parent
4422a9d2c7
commit
e4aa3525c0
8 changed files with 51 additions and 1972 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
|
@ -28,7 +28,6 @@ dependencies = [
|
|||
"lettre",
|
||||
"log",
|
||||
"md-5 0.11.0",
|
||||
"mii",
|
||||
"once_cell",
|
||||
"openssl",
|
||||
"p256",
|
||||
|
|
@ -2354,16 +2353,6 @@ version = "2.7.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "mii"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"bytemuck",
|
||||
"reqwest",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mime"
|
||||
version = "0.3.17"
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ aes = "0.8.4"
|
|||
hmac = "0.13.0"
|
||||
md-5 = "0.11.0"
|
||||
cbc = "0.1.2"
|
||||
mii = { path = "./mii" }
|
||||
crc32fast = "1.4.2"
|
||||
gxhash = "3.4.1"
|
||||
sentry = "0.48.0"
|
||||
|
|
|
|||
1818
mii/Cargo.lock
generated
1818
mii/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,10 +0,0 @@
|
|||
[package]
|
||||
name = "mii"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.22.1"
|
||||
bytemuck = { version = "1.21.0", features = ["derive"] }
|
||||
reqwest = "0.13.0"
|
||||
tokio = { version = "1.43.0", features = ["macros"] }
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
use std::str::FromStr;
|
||||
use bytemuck::{try_from_bytes, Pod, Zeroable};
|
||||
use base64::Engine;
|
||||
use base64::prelude::BASE64_STANDARD;
|
||||
use reqwest::Url;
|
||||
|
||||
#[derive(Pod, Zeroable, Copy, Clone)]
|
||||
#[repr(C, packed)]
|
||||
struct FFLStoreData{
|
||||
mii_data: FFLiMiiDataOfficial
|
||||
}
|
||||
|
||||
#[derive(Pod, Zeroable, Copy, Clone)]
|
||||
#[repr(C, packed)]
|
||||
struct FFLiMiiDataOfficial{
|
||||
core_data: FFLiMiiDataCore
|
||||
}
|
||||
|
||||
#[derive(Pod, Zeroable, Copy, Clone)]
|
||||
#[repr(C, packed)]
|
||||
struct FFLiMiiDataCore{
|
||||
stuff: u32,
|
||||
author_id: u64,
|
||||
create_id: [u8; 10],
|
||||
unk_1: u16,
|
||||
unk_2: u16,
|
||||
pub name: [u16; 10],
|
||||
|
||||
|
||||
}
|
||||
|
||||
pub struct MiiData{
|
||||
pub name: String
|
||||
}
|
||||
|
||||
impl MiiData{
|
||||
pub fn read(data: &str) -> Option<Self>{
|
||||
let data = BASE64_STANDARD.decode(data).ok()?;
|
||||
|
||||
let data: &FFLStoreData = try_from_bytes(data.get(0..size_of::<FFLStoreData>())?).ok()?;
|
||||
|
||||
let name = data.mii_data.core_data.name;
|
||||
let idx = name.iter().position(|v| *v == 0x0).unwrap_or(10);
|
||||
|
||||
let name = &name[0..idx];
|
||||
|
||||
let name = String::from_utf16(&name).ok()?;
|
||||
|
||||
Some(Self{
|
||||
name
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_image_png(data: &str) -> Option<Vec<u8>>{
|
||||
let mut url = Url::from_str("https://mii-unsecure.ariankordi.net/miis/image.png\
|
||||
").unwrap();
|
||||
|
||||
url.set_query(Some(&format!("data={}", data)));
|
||||
|
||||
reqwest::get(url).await.ok().map(|v| v.bytes())?.await.ok().map(|b| b.to_vec())
|
||||
}
|
||||
|
||||
pub async fn get_image_tga(data: &str) -> Option<Vec<u8>>{
|
||||
let mut url = Url::from_str("https://mii-unsecure.ariankordi.net/miis/image.tga\
|
||||
").unwrap();
|
||||
|
||||
url.set_query(Some(&format!("data={}", data)));
|
||||
|
||||
reqwest::get(url).await.ok().map(|v| v.bytes())?.await.ok().map(|b| b.to_vec())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test{
|
||||
use std::fs;
|
||||
use crate::get_image_png;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_image_get(){
|
||||
let image = get_image_png("AAEAQDrPvmeBxJIQ3cL/BYp4iCWDvgAA8FVEAEoATQByAFQAVgAAAGgAZQByAAB/BAApBBpK4xiXEqQMAhgXbAoACClQQkhQTQBFAAAALQBTAHcAaQB0AGMAaAAAAMqP").await.unwrap();
|
||||
|
||||
fs::write("heh.png", image).unwrap();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,55 @@
|
|||
use bytemuck::{try_from_bytes, Pod, Zeroable};
|
||||
use base64::Engine;
|
||||
use base64::prelude::BASE64_STANDARD;
|
||||
use std::env;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
#[derive(Pod, Zeroable, Copy, Clone)]
|
||||
#[repr(C, packed)]
|
||||
struct FFLStoreData{
|
||||
mii_data: FFLiMiiDataOfficial
|
||||
}
|
||||
|
||||
#[derive(Pod, Zeroable, Copy, Clone)]
|
||||
#[repr(C, packed)]
|
||||
struct FFLiMiiDataOfficial{
|
||||
core_data: FFLiMiiDataCore
|
||||
}
|
||||
|
||||
#[derive(Pod, Zeroable, Copy, Clone)]
|
||||
#[repr(C, packed)]
|
||||
struct FFLiMiiDataCore{
|
||||
stuff: u32,
|
||||
author_id: u64,
|
||||
create_id: [u8; 10],
|
||||
unk_1: u16,
|
||||
unk_2: u16,
|
||||
pub name: [u16; 10],
|
||||
}
|
||||
|
||||
pub struct MiiData{
|
||||
pub name: String
|
||||
}
|
||||
|
||||
impl MiiData{
|
||||
pub fn read(data: &str) -> Option<Self>{
|
||||
let data = BASE64_STANDARD.decode(data).ok()?;
|
||||
|
||||
let data: &FFLStoreData = try_from_bytes(data.get(0..size_of::<FFLStoreData>())?).ok()?;
|
||||
|
||||
let name = data.mii_data.core_data.name;
|
||||
let idx = name.iter().position(|v| *v == 0x0).unwrap_or(10);
|
||||
|
||||
let name = &name[0..idx];
|
||||
|
||||
let name = String::from_utf16(&name).ok()?;
|
||||
|
||||
Some(Self{
|
||||
name
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub static MII_PROVIDER_SERVER_URL: Lazy<Box<str>> = Lazy::new(||
|
||||
env::var("MII_PROVIDER_SERVER_URL").expect("MII_PROVIDER_SERVER_URL not specified").into_boxed_str()
|
||||
);
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ pub async fn get_miis(
|
|||
data: clean_mii_data,
|
||||
id: mii_id,
|
||||
images,
|
||||
name: mii::MiiData::read(&row.mii_data)
|
||||
name: crate::mii_util::MiiData::read(&row.mii_data)
|
||||
.map(|v| v.name)
|
||||
.unwrap_or_else(|| "Mii".to_string()),
|
||||
pid: row.pid,
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ use crate::Pool;
|
|||
use crate::xml::{Xml, YesNoVal};
|
||||
use crate::email::send_verification_email;
|
||||
use rand::prelude::*;
|
||||
// Not in use currently.
|
||||
//use mii::{get_image_png, get_image_tga};
|
||||
use crate::mii_util::get_mii_img_url;
|
||||
|
||||
const DATABASE_ERROR: Errors = Errors{
|
||||
|
|
@ -25,48 +23,6 @@ const DATABASE_ERROR: Errors = Errors{
|
|||
]
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
pub async fn generate_s3_images(pid: i32, mii_data: &str) {
|
||||
let auth = StaticProvider::new(&S3_USER, &S3_PASSWD, None);
|
||||
|
||||
let Ok(client) = ClientBuilder::new(S3_URL.clone())
|
||||
.provider(Some(Box::new(auth)))
|
||||
.build()
|
||||
else {
|
||||
println!("Failed to build S3 client for PID {}", pid);
|
||||
return;
|
||||
};
|
||||
|
||||
let Some(image) = mii::get_image_png(mii_data).await else {
|
||||
println!("Failed to fetch PNG image for PID {}", pid);
|
||||
return;
|
||||
};
|
||||
|
||||
let object_name = get_mii_img_url_path(pid, "png");
|
||||
let object_content = ObjectContent::from(image);
|
||||
|
||||
if let Err(e) = client.put_object_content(&**S3_BUCKET, &object_name, object_content).send().await {
|
||||
println!("Failed to upload PNG for PID {}: {:?}", pid, e);
|
||||
} else {
|
||||
println!("Successfully uploaded PNG for PID {}", pid);
|
||||
}
|
||||
|
||||
let Some(image) = mii::get_image_tga(mii_data).await else {
|
||||
println!("Failed to fetch TGA image for PID {}", pid);
|
||||
return;
|
||||
};
|
||||
|
||||
let object_name = get_mii_img_url_path(pid, "tga");
|
||||
let object_content = ObjectContent::from(image);
|
||||
|
||||
if let Err(e) = client.put_object_content(&**S3_BUCKET, &object_name, object_content).send().await {
|
||||
println!("Failed to upload TGA for PID {}: {:?}", pid, e);
|
||||
} else {
|
||||
println!("Successfully uploaded TGA for PID {}", pid);
|
||||
}
|
||||
}*/
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct Email{
|
||||
address: Box<str>
|
||||
|
|
@ -348,7 +304,7 @@ pub fn build_profile(user: User) -> GetOwnProfileData {
|
|||
mii_hash: hex::encode(bytemuck::bytes_of(
|
||||
&(gxhash64(mii_data.as_bytes(), 1) & !(0x1000000000000000))
|
||||
)),
|
||||
name: mii::MiiData::read(&mii_data)
|
||||
name: crate::mii_util::MiiData::read(&mii_data)
|
||||
.map(|v| v.name)
|
||||
.unwrap_or_else(|| "INVALID".to_string()),
|
||||
primary: YesNoVal(true),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue