forked from spacebar/account
fix email confirmation html and remove nasc
nasc is now a seperate server so its no longer needed
This commit is contained in:
parent
9b0160871c
commit
5eeb97b912
6 changed files with 5 additions and 157 deletions
|
|
@ -38,7 +38,7 @@
|
|||
color: #B60000 !important;
|
||||
}
|
||||
img.logo {
|
||||
content: url("https://cdn.abmanagement.al/perditumgames.png") !important;
|
||||
content: url("https://spfn.net/res/img/spfn.png") !important;
|
||||
}
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
|
|
@ -91,8 +91,8 @@
|
|||
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="https://spfn.cc">
|
||||
<img class="logo" width="auto" height="48px" src="https://cdn.abmanagement.al/SPFN.png" alt="SPFN">
|
||||
<a href="https://spfn.net">
|
||||
<img class="logo" width="auto" height="48px" src="https://spfn.net/res/img/spfn.png" alt="SPFN">
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -179,7 +179,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="notice" style="color: #8990c1; font-size: 12px;">
|
||||
Note: this email message was auto-generated, please do not respond. For further assistance, please join our <a href="https://discord.gg/splatfestival" style="text-decoration: none; color: #ffffff; ">Discord server</a> or make a post on our <a href="https://forum.perditum.com" style="text-decoration: none; color: #ffffff; ">Forum</a>.
|
||||
Note: this email message was auto-generated, please do not respond. For further assistance, please join our <a href="https://discord.gg/grMSxZf" style="text-decoration: none; color: #ffffff; ">Discord server</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
// use serde::{Deserialize, Serialize};
|
||||
// Don't generate warnings for no reason, DJ. :P
|
||||
// Don't generate warnings for no reason, Maple. :P
|
||||
|
|
@ -22,7 +22,6 @@ mod graphql;
|
|||
mod email;
|
||||
mod mii_util;
|
||||
mod json_api;
|
||||
mod nasc;
|
||||
|
||||
type Pool = sqlx::Pool<Postgres>;
|
||||
|
||||
|
|
@ -113,7 +112,6 @@ async fn launch() -> _ {
|
|||
nnid::provider::get_service_token,
|
||||
nnid::admin::mapped_ids,
|
||||
nnid::admin::get_time,
|
||||
nasc::ac::nasc_ac,
|
||||
json_api::oauth::generate_token::generate_token,
|
||||
json_api::users::profile::get_own_profile,
|
||||
json_api::users::mii::get_mii_data_by_pid,
|
||||
|
|
|
|||
108
src/nasc/ac.rs
108
src/nasc/ac.rs
|
|
@ -1,108 +0,0 @@
|
|||
use rocket::FromForm;
|
||||
use rocket::{post, State, form::Form};
|
||||
use std::net::Ipv4Addr;
|
||||
use sqlx::types::ipnetwork::IpNetwork::V4;
|
||||
use crate::Pool;
|
||||
use crate::nnid::oauth::generate_token::create_token;
|
||||
use crate::nnid::oauth::generate_token::token_type::AUTH_TOKEN;
|
||||
use crate::nasc::util::{
|
||||
nintendo_base64_decode,
|
||||
nintendo_base64_encode,
|
||||
nasc_date_time,
|
||||
nasc_error
|
||||
};
|
||||
|
||||
#[derive(FromForm)]
|
||||
pub struct NascRequestParams {
|
||||
pub action: String,
|
||||
pub titleid: String,
|
||||
pub gameid: String,
|
||||
}
|
||||
|
||||
#[post("/ac", data = "<params>")]
|
||||
pub async fn nasc_ac(
|
||||
pool: &State<Pool>,
|
||||
params: Form<NascRequestParams>,
|
||||
) -> String {
|
||||
|
||||
let action = nintendo_base64_decode(¶ms.action);
|
||||
let title_id = nintendo_base64_decode(¶ms.titleid);
|
||||
let game_server_id = nintendo_base64_decode(¶ms.gameid);
|
||||
|
||||
let server_row = match sqlx::query!(
|
||||
"SELECT game_server_id, maintenance_mode, address, port FROM nex_servers WHERE title_id = $1",
|
||||
title_id,
|
||||
)
|
||||
.fetch_optional(pool.inner())
|
||||
.await
|
||||
.expect("system error") {
|
||||
Some(row) => row,
|
||||
None => return nasc_error("110"),
|
||||
};
|
||||
|
||||
if game_server_id != server_row.game_server_id {
|
||||
return nasc_error("152");
|
||||
}
|
||||
|
||||
if server_row.maintenance_mode {
|
||||
return nasc_error("101");
|
||||
}
|
||||
|
||||
let V4(ip_net) = server_row.address else {
|
||||
return nasc_error("110");
|
||||
};
|
||||
let ip = ip_net.ip();
|
||||
let port = server_row.port as u16;
|
||||
|
||||
if action == "LOGIN" && port == 0 && ip != Ipv4Addr::new(0, 0, 0, 0) {
|
||||
return nasc_error("110");
|
||||
}
|
||||
|
||||
match action.as_str() {
|
||||
//"LOGIN" => process_login_request(pool, nex_account.pid, &title_id, ip, port).await,
|
||||
//"SVCLOC" => process_service_token_request(pool, nex_account.pid, &title_id).await,
|
||||
_ => nasc_error("nullnt"),
|
||||
}
|
||||
}
|
||||
|
||||
async fn process_login_request(
|
||||
pool: &State<Pool>,
|
||||
pid: i32,
|
||||
title_id: &str,
|
||||
ip: Ipv4Addr,
|
||||
port: u16,
|
||||
) -> String {
|
||||
let nex_token_raw = create_token(pool.inner(), pid, AUTH_TOKEN, Some(title_id)).await;
|
||||
let nex_token = nintendo_base64_encode(nex_token_raw.as_bytes());
|
||||
|
||||
let locator_str = format!("{}:{}", ip, port);
|
||||
let locator = nintendo_base64_encode(locator_str.as_bytes());
|
||||
|
||||
format!(
|
||||
"locator={}&retry={}&returncd={}&token={}&datetime={}",
|
||||
locator,
|
||||
nintendo_base64_encode(b"0"),
|
||||
nintendo_base64_encode(b"001"),
|
||||
nex_token,
|
||||
nintendo_base64_encode(nasc_date_time().as_bytes())
|
||||
)
|
||||
}
|
||||
|
||||
async fn process_service_token_request(
|
||||
pool: &State<Pool>,
|
||||
pid: i32,
|
||||
title_id: &str,
|
||||
) -> String {
|
||||
let service_token_raw = create_token(pool.inner(), pid, AUTH_TOKEN, Some(title_id)).await;
|
||||
let service_token = nintendo_base64_encode(service_token_raw.as_bytes());
|
||||
|
||||
format!(
|
||||
"retry={}&returncd={}&servicetoken={}&statusdata={}&svchost={}&datetime={}",
|
||||
nintendo_base64_encode(b"0"),
|
||||
nintendo_base64_encode(b"007"),
|
||||
service_token,
|
||||
nintendo_base64_encode(b"Y"),
|
||||
nintendo_base64_encode(b"n/a"),
|
||||
nintendo_base64_encode(nasc_date_time().as_bytes())
|
||||
)
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
pub mod util;
|
||||
pub mod ac;
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
use chrono::Local;
|
||||
|
||||
pub fn nintendo_base64_decode(encoded: &str) -> String {
|
||||
let standard_b64 = encoded
|
||||
.replace('.', "+")
|
||||
.replace('-', "/")
|
||||
.replace('*', "=");
|
||||
|
||||
match base64::Engine::decode(&base64::engine::general_purpose::STANDARD, standard_b64) {
|
||||
Ok(bytes) => String::from_utf8_lossy(&bytes).into_owned(),
|
||||
Err(_) => String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn nintendo_base64_encode(decoded: &[u8]) -> String {
|
||||
let standard_b64 = base64::Engine::encode(&base64::engine::general_purpose::STANDARD, decoded);
|
||||
standard_b64
|
||||
.replace('+', ".")
|
||||
.replace('/', "-")
|
||||
.replace('=', "*")
|
||||
}
|
||||
|
||||
pub fn nasc_date_time() -> String {
|
||||
Local::now().format("%Y%m%d%H%M%S").to_string()
|
||||
}
|
||||
|
||||
pub fn nasc_error(error_code: &str) -> String {
|
||||
let return_cd = if error_code == "null" {
|
||||
error_code.to_string()
|
||||
} else {
|
||||
nintendo_base64_encode(error_code.as_bytes())
|
||||
};
|
||||
|
||||
format!(
|
||||
"retry={}&returncd={}&datetime={}",
|
||||
nintendo_base64_encode(b"1"),
|
||||
return_cd,
|
||||
nintendo_base64_encode(nasc_date_time().as_bytes())
|
||||
)
|
||||
}
|
||||
Loading…
Reference in a new issue