Compare commits

...

6 Commits

Author SHA1 Message Date
Ethan O'Brien
6d541a81ef Add actions/checkout 2025-11-30 18:29:09 -06:00
Ethan O'Brien
b9f9929ea9 Print version to stdout 2025-11-30 18:27:30 -06:00
Ethan O'Brien
2cc2138eda Update docker build to push version tags 2025-11-30 18:16:03 -06:00
Ethan O'Brien
bab9868355 Update license 2025-11-30 18:09:47 -06:00
Ethan O'Brien
ad0d222c96 Add the (currently android) easter mode 2025-11-30 17:26:26 -06:00
Ethan O'Brien
60eb7d469b Add ability to set datapath outside of cli args 2025-11-30 16:51:08 -06:00
11 changed files with 150 additions and 130 deletions

View File

@@ -8,6 +8,9 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checking out branch
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v2
with:
@@ -26,7 +29,7 @@ jobs:
- name: Extract version from Cargo.toml
shell: bash
run: |
echo "EW_VERSION=$(grep "^version" Cargo.toml | sed -E 's/version\s*=\s*["]([^"]*)["]/\1/')" >> $GITHUB_ENV
echo "APP_VERSION=$(grep "^version" Cargo.toml | sed -E 's/version\s*=\s*["]([^"]*)["]/\1/')" >> $GITHUB_ENV
- name: Log in to DockerHub
uses: docker/login-action@v3
@@ -52,10 +55,12 @@ jobs:
push: true
labels: |
gitsha1=${{ github.sha }}
org.opencontainers.image.version=${{ env.EW_VERSION }}
tags: "${{ steps.set-tag.outputs.tags }}"
org.opencontainers.image.version=${{ env.APP_VERSION }}
tags: |
${{ steps.set-tag.outputs.tags }}
docker.io/ethanaobrien/ew:${{ env.APP_VERSION }}
file: "docker/Dockerfile"
platforms: linux/amd64 #,linux/arm64
platforms: linux/amd64, linux/arm64
# arm64 builds OOM without the git fetch setting. c.f.
# https://github.com/rust-lang/cargo/issues/10583

121
Cargo.lock generated
View File

@@ -65,7 +65,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb"
dependencies = [
"quote",
"syn 2.0.110",
"syn 2.0.111",
]
[[package]]
@@ -132,9 +132,9 @@ dependencies = [
[[package]]
name = "actix-web"
version = "4.12.0"
version = "4.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2233f53f6cb18ae038ce1f0713ca0c72ca0c4b71fe9aaeb59924ce2c89c6dd85"
checksum = "1654a77ba142e37f049637a3e5685f864514af11fcbc51cb51eb6596afe5b8d6"
dependencies = [
"actix-codec",
"actix-http",
@@ -182,7 +182,7 @@ dependencies = [
"actix-router",
"proc-macro2",
"quote",
"syn 2.0.110",
"syn 2.0.111",
]
[[package]]
@@ -392,9 +392,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.2.46"
version = "1.2.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97463e1064cb1b1c1384ad0a0b9c8abd0988e2a91f52606c80ef14aadb63e36"
checksum = "c481bdbf0ed3b892f6f806287d72acd515b352a4ec27a208489b8c1bc839633a"
dependencies = [
"find-msvc-tools",
"jobserver",
@@ -455,7 +455,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
"syn 2.0.110",
"syn 2.0.111",
]
[[package]]
@@ -577,7 +577,7 @@ checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.110",
"syn 2.0.111",
"unicode-xid",
]
@@ -611,7 +611,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.110",
"syn 2.0.111",
]
[[package]]
@@ -642,7 +642,6 @@ dependencies = [
"hex",
"hmac",
"include-flate-codegen",
"include_dir",
"jni",
"json",
"lazy_static",
@@ -869,12 +868,11 @@ dependencies = [
[[package]]
name = "http"
version = "1.3.1"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565"
checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a"
dependencies = [
"bytes",
"fnv",
"itoa",
]
@@ -1009,7 +1007,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.110",
"syn 2.0.111",
"zstd",
]
@@ -1023,25 +1021,6 @@ dependencies = [
"zstd",
]
[[package]]
name = "include_dir"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd"
dependencies = [
"include_dir_macros",
]
[[package]]
name = "include_dir_macros"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75"
dependencies = [
"proc-macro2",
"quote",
]
[[package]]
name = "indexmap"
version = "2.12.1"
@@ -1119,9 +1098,9 @@ dependencies = [
[[package]]
name = "js-sys"
version = "0.3.82"
version = "0.3.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65"
checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8"
dependencies = [
"once_cell",
"wasm-bindgen",
@@ -1719,9 +1698,9 @@ dependencies = [
[[package]]
name = "rustls-pki-types"
version = "1.13.0"
version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94182ad936a0c91c324cd46c6511b9510ed16af436d7b5bab34beab0afd55f7a"
checksum = "708c0f9d5f54ba0272468c1d306a52c495b31fa155e91bc25371e6df7996908c"
dependencies = [
"zeroize",
]
@@ -1791,7 +1770,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.110",
"syn 2.0.111",
]
[[package]]
@@ -1849,9 +1828,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "signal-hook-registry"
version = "1.4.6"
version = "1.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b"
checksum = "7664a098b8e616bdfcc2dc0e9ac44eb231eedf41db4e9fe95d8d32ec728dedad"
dependencies = [
"libc",
]
@@ -1959,9 +1938,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.110"
version = "2.0.111"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea"
checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87"
dependencies = [
"proc-macro2",
"quote",
@@ -1976,7 +1955,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.110",
"syn 2.0.111",
]
[[package]]
@@ -1996,7 +1975,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.110",
"syn 2.0.111",
]
[[package]]
@@ -2071,9 +2050,9 @@ dependencies = [
[[package]]
name = "tracing"
version = "0.1.41"
version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
checksum = "2d15d90a0b5c19378952d479dc858407149d7bb45a14de0142f6c534b16fc647"
dependencies = [
"log",
"pin-project-lite",
@@ -2083,20 +2062,20 @@ dependencies = [
[[package]]
name = "tracing-attributes"
version = "0.1.30"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903"
checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.110",
"syn 2.0.111",
]
[[package]]
name = "tracing-core"
version = "0.1.34"
version = "0.1.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678"
checksum = "7a04e24fab5c89c6a36eb8558c9656f30d81de51dfa4d3b45f26b21d61fa0a6c"
dependencies = [
"once_cell",
]
@@ -2144,12 +2123,12 @@ dependencies = [
[[package]]
name = "ureq-proto"
version = "0.5.2"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60b4531c118335662134346048ddb0e54cc86bd7e81866757873055f0e38f5d2"
checksum = "d81f9efa9df032be5934a46a068815a10a042b494b6a58cb0a1a97bb5467ed6f"
dependencies = [
"base64",
"http 1.3.1",
"http 1.4.0",
"httparse",
"log",
]
@@ -2240,9 +2219,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen"
version = "0.2.105"
version = "0.2.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60"
checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd"
dependencies = [
"cfg-if",
"once_cell",
@@ -2253,9 +2232,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.105"
version = "0.2.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2"
checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -2263,22 +2242,22 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.105"
version = "0.2.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc"
checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40"
dependencies = [
"bumpalo",
"proc-macro2",
"quote",
"syn 2.0.110",
"syn 2.0.111",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.105"
version = "0.2.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76"
checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4"
dependencies = [
"unicode-ident",
]
@@ -2582,28 +2561,28 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.110",
"syn 2.0.111",
"synstructure",
]
[[package]]
name = "zerocopy"
version = "0.8.28"
version = "0.8.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43fa6694ed34d6e57407afbccdeecfa268c470a7d2a5b0cf49ce9fcc345afb90"
checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.8.28"
version = "0.8.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c640b22cd9817fae95be82f0d2f90b11f7605f6c319d16705c459b27ac2cbc26"
checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.110",
"syn 2.0.111",
]
[[package]]
@@ -2623,7 +2602,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.110",
"syn 2.0.111",
"synstructure",
]
@@ -2663,7 +2642,7 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.110",
"syn 2.0.111",
]
[[package]]

View File

@@ -27,7 +27,6 @@ cbc = { version = "0.1.2", features = ["alloc"] }
aes = "0.8.4"
pem = "3.0.6"
ureq = "3.1.4"
include_dir = { version = "0.7.4", optional = true }
[target.aarch64-linux-android.dependencies]
jni = { version = "0.21.1", features = ["invocation", "default"] }
@@ -41,7 +40,7 @@ cc = "1.0"
# To enable this library you MUST comment out lib block below and add --features library
[features]
library = ["dep:include_dir"]
library = []
#[lib]
#crate-type = ["cdylib"]

View File

@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
ew Copyright (C) 2024-2025 Ethan O'Brien
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

View File

@@ -33,10 +33,10 @@ extern "C" fn Java_one_ethanthesleepy_androidew_BackgroundService_startServer<'l
data_path: JString<'local>,
easter: jboolean
) -> jstring {
//crate::runtime::set_easter_mode(easter != 0);
crate::runtime::set_easter_mode(easter != 0);
let data_path: String = env.get_string(&data_path).unwrap().into();
//crate::runtime::set_datapath(data_path);
crate::runtime::update_data_path(&data_path);
let output = env.new_string(String::from("Azunyannnn~")).unwrap();
thread::spawn(|| {
@@ -56,5 +56,5 @@ extern "C" fn Java_one_ethanthesleepy_androidew_BackgroundService_stopServer<'lo
#[unsafe(no_mangle)]
extern "C" fn Java_one_ethanthesleepy_androidew_BackgroundService_setEasterMode<'local>(_env: JNIEnv<'local>, _class: JClass<'local>, easter: jboolean) {
//crate::runtime::set_easter_mode(easter != 0);
crate::runtime::set_easter_mode(easter != 0);
}

View File

@@ -7,7 +7,7 @@ pub static INITIALIZER: extern "C" fn() = main;
#[unsafe(no_mangle)]
pub extern "C" fn main() {
let data_path = get_bundle_path().into_os_string().into_string().unwrap();
//set_datapath(data_path);
crate::runtime::update_data_path(&data_path);
std::thread::spawn(|| {
crate::run_server(true).unwrap();
@@ -18,7 +18,7 @@ pub extern "C" fn main() {
use objc2_foundation::{NSFileManager, NSSearchPathDirectory, NSSearchPathDomainMask};
#[cfg(target_os = "ios")]
fn get_bundle_path() -> std::path::PathBuf {
pub fn get_bundle_path() -> std::path::PathBuf {
unsafe {
let manager = NSFileManager::defaultManager();
let application_support = manager.URLsForDirectory_inDomains(NSSearchPathDirectory::ApplicationSupportDirectory, NSSearchPathDomainMask::UserDomainMask);

View File

@@ -3,7 +3,7 @@ mod options;
mod router;
mod encryption;
mod sql;
mod runtime;
pub mod runtime;
#[macro_use]
mod macros;
@@ -22,9 +22,9 @@ use actix_web::{
web,
dev::Service
};
use std::fs;
use std::time::Duration;
use options::get_args;
pub use options::get_args;
use runtime::get_data_path;
#[actix_web::main]
pub async fn run_server(in_thread: bool) -> std::io::Result<()> {
@@ -39,7 +39,12 @@ pub async fn run_server(in_thread: bool) -> std::io::Result<()> {
let rv = HttpServer::new(|| App::new()
.wrap_fn(|req, srv| {
println!("Request: {}", req.path());
println!("Request: {} {}", req.method(), req.path());
#[cfg(feature = "library")]
#[cfg(target_os = "android")]
log_to_logcat!("ew", "Request: {} {}", req.method(), req.path());
srv.call(req)
})
.app_data(web::PayloadConfig::default().limit(1024 * 1024 * 25))
@@ -78,13 +83,3 @@ pub async fn stop_server() {
runtime::set_running(false);
println!("Stopping");
}
pub fn get_data_path(file_name: &str) -> String {
let args = get_args();
let mut path = args.path;
while path.ends_with('/') {
path.pop();
}
fs::create_dir_all(&path).unwrap();
format!("{}/{}", path, file_name)
}

View File

@@ -1,6 +1,7 @@
#[cfg(not(feature = "library"))]
fn main() -> std::io::Result<()> {
ew::runtime::update_data_path(&ew::get_args().path);
ew::run_server(false)
}

View File

@@ -9,40 +9,54 @@ use uuid::Uuid;
use crate::encryption;
use crate::router::{userdata, gree, items};
use crate::runtime::get_easter_mode;
pub const ASSET_VERSION: &str = "5260ff15dff8ba0c00ad91400f515f55";
pub const ASSET_HASH_ANDROID: &str = "d210b28037885f3ef56b8f8aa45ac95b";
pub const ASSET_HASH_IOS: &str = "dd7175e4bcdab476f38c33c7f34b5e4d";
pub const ASSET_VERSION_GL: &str = "5260ff15dff8ba0c00ad91400f515f55";
pub const ASSET_HASH_ANDROID_GL: &str = "d210b28037885f3ef56b8f8aa45ac95b";
pub const ASSET_HASH_IOS_GL: &str = "dd7175e4bcdab476f38c33c7f34b5e4d";
pub const ASSET_VERSION_JP: &str = "4c921d2443335e574a82e04ec9ea243c";
pub const ASSET_HASH_ANDROID_JP: &str = "67f8f261c16b3cca63e520a25aad6c1c";
pub const ASSET_HASH_IOS_JP: &str = "b8975be8300013a168d061d3fdcd4a16";
pub const ASSET_HASH_ANDROID_EASTER_GL: &str = "da7ae831381c3f29337caa9891db7e6a";
pub const ASSET_HASH_ANDROID_EASTER_JP: &str = "eac0cad61c82bf2e31fc596555747d11";
pub fn get_asset_hash(asset_version: String, android: bool) -> String {
let args = crate::get_args();
if asset_version == ASSET_VERSION_JP {
if android {
if asset_version == ASSET_VERSION_JP {
if args.jp_android_asset_hash != String::new() {
args.jp_android_asset_hash
&args.jp_android_asset_hash
} else if get_easter_mode() {
ASSET_HASH_ANDROID_EASTER_JP
} else {
ASSET_HASH_ANDROID_JP.to_string()
ASSET_HASH_ANDROID_JP
}
} else if args.jp_ios_asset_hash != String::new() {
args.jp_ios_asset_hash
} else {
ASSET_HASH_IOS_JP.to_string()
}
} else if android {
if args.en_android_asset_hash != String::new() {
args.en_android_asset_hash
&args.en_android_asset_hash
} else if get_easter_mode() {
ASSET_HASH_ANDROID_EASTER_GL
} else {
ASSET_HASH_ANDROID.to_string()
ASSET_HASH_ANDROID_GL
}
}
} else if args.en_ios_asset_hash != String::new() {
args.en_ios_asset_hash
} else {
ASSET_HASH_IOS.to_string()
if asset_version == ASSET_VERSION_JP {
if args.jp_ios_asset_hash != String::new() {
&args.jp_ios_asset_hash
} else {
ASSET_HASH_IOS_JP
}
} else {
if args.en_ios_asset_hash != String::new() {
&args.en_ios_asset_hash
} else {
ASSET_HASH_IOS_GL
}
}
}.to_string()
}
pub fn create_token() -> String {

View File

@@ -5,7 +5,7 @@ use crate::encryption;
use crate::router::{userdata, global};
fn get_asset_hash(req: &HttpRequest, body: &JsonValue) -> String {
if body["asset_version"] != global::ASSET_VERSION && body["asset_version"] != global::ASSET_VERSION_JP {
if body["asset_version"] != global::ASSET_VERSION_GL && body["asset_version"] != global::ASSET_VERSION_JP {
println!("Warning! Asset version is not what was expected. (Did the app update?)");
}

View File

@@ -1,17 +1,44 @@
use crate::lock_onto_mutex;
use lazy_static::lazy_static;
use std::sync::Mutex;
use std::sync::RwLock;
use std::fs;
lazy_static! {
static ref RUNNING: Mutex<bool> = Mutex::new(false);
static ref RUNNING: RwLock<bool> = RwLock::new(false);
static ref DATAPATH: RwLock<String> = RwLock::new(String::new());
static ref EASTER: RwLock<bool> = RwLock::new(false);
}
pub fn set_running(running: bool) {
let mut result = lock_onto_mutex!(RUNNING);
*result = running;
let mut w = RUNNING.write().unwrap();
*w = running;
}
pub fn get_running() -> bool {
let result = lock_onto_mutex!(RUNNING);
*result
*RUNNING.read().unwrap()
}
pub fn get_data_path(file_name: &str) -> String {
let mut path = {
DATAPATH.read().unwrap().clone()
};
while path.ends_with('/') {
path.pop();
}
fs::create_dir_all(&path).unwrap();
format!("{}/{}", path, file_name)
}
pub fn update_data_path(path: &str) {
let mut w = DATAPATH.write().unwrap();
*w = path.to_string();
}
// Only currently editable by the android so
pub fn set_easter_mode(enabled: bool) {
let mut w = EASTER.write().unwrap();
*w = enabled;
}
pub fn get_easter_mode() -> bool {
*EASTER.read().unwrap()
}