mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew.git
synced 2025-05-13 11:37:33 -05:00
Added configurable NPPS4 server address for sif1 account linking
This commit is contained in:
parent
88dfaed1a0
commit
66ad791ff8
3 changed files with 20 additions and 10 deletions
10
docker/start.sh
Normal file → Executable file
10
docker/start.sh
Normal file → Executable file
|
@ -3,8 +3,8 @@
|
||||||
port="${PORT:-8080}"
|
port="${PORT:-8080}"
|
||||||
directory="${DIRECTORY:-/data/}"
|
directory="${DIRECTORY:-/data/}"
|
||||||
|
|
||||||
if [ "$HTTPS" = "true" ]; then
|
npps4="${NPPS4_ADDRESS:-http://127.0.0.1:51376}"
|
||||||
/root/ew/ew --path $directory --port $port --https
|
|
||||||
else
|
https=$([ "$HTTPS" = "true" ] && echo "--https" || echo "")
|
||||||
/root/ew/ew --path $directory --port $port
|
|
||||||
fi
|
/root/ew/ew --path $directory --port $port --npps4 $npps4 $https
|
||||||
|
|
|
@ -211,7 +211,10 @@ pub struct Args {
|
||||||
path: String,
|
path: String,
|
||||||
|
|
||||||
#[arg(long, default_value_t = false, help = "Serve gree headers with https. WILL NOT ACCEPT HTTPS REQUESTS")]
|
#[arg(long, default_value_t = false, help = "Serve gree headers with https. WILL NOT ACCEPT HTTPS REQUESTS")]
|
||||||
https: bool
|
https: bool,
|
||||||
|
|
||||||
|
#[arg(long, default_value = "http://127.0.0.1:51376", help = "Address to NPPS4 server for sif account linking")]
|
||||||
|
npps4: String
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_args() -> Args {
|
pub fn get_args() -> Args {
|
||||||
|
@ -236,6 +239,8 @@ async fn main() -> std::io::Result<()> {
|
||||||
|
|
||||||
println!("Server started: http://0.0.0.0:{}", port);
|
println!("Server started: http://0.0.0.0:{}", port);
|
||||||
println!("Data path is set to {}", args.path);
|
println!("Data path is set to {}", args.path);
|
||||||
|
println!("Sif1 transfer requests will attempt to contact NPPS4 at {}", host);
|
||||||
|
|
||||||
if args.https {
|
if args.https {
|
||||||
println!("Note: gree is set to https mode. http requests will fail on jp clients.");
|
println!("Note: gree is set to https mode. http requests will fail on jp clients.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,11 +322,16 @@ fn generate_passcode_sha1(transfer_id: String, transfer_code: String) -> String
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn npps4_req(sha_id: String) -> Option<JsonValue> {
|
async fn npps4_req(sha_id: String) -> Option<JsonValue> {
|
||||||
|
let args = crate::get_args();
|
||||||
|
|
||||||
|
let mut host = args.npps4;
|
||||||
|
while host.ends_with("/") {
|
||||||
|
host.pop();
|
||||||
|
}
|
||||||
|
let url = format!("{}/ewexport?sha1={}", host, sha_id);
|
||||||
|
println!("Polling NPPS4 at {}", host);
|
||||||
|
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
// TODO - ability to configure in admin webui?
|
|
||||||
let hostname = "http://127.0.0.1:51376";
|
|
||||||
let url = format!("{}/ewexport?sha1={}", hostname, sha_id);
|
|
||||||
println!("Polling NPPS4 at {}", hostname);
|
|
||||||
let response = client.get(url);
|
let response = client.get(url);
|
||||||
let response_body = response.send().await.ok()?.text().await.ok()?;
|
let response_body = response.send().await.ok()?.text().await.ok()?;
|
||||||
Some(json::parse(&response_body).ok()?)
|
Some(json::parse(&response_body).ok()?)
|
||||||
|
|
Loading…
Add table
Reference in a new issue