From e7de53929d4bbf857eebae6108652b546a713680 Mon Sep 17 00:00:00 2001 From: "NG (Graham)" Date: Sat, 24 May 2025 13:42:53 -0400 Subject: [PATCH] Replace rc_static_data with general CDN implementation --- Cargo.lock | 443 +++++++++++++++++++++- Cargo.toml | 6 +- assets/robocraft/live_data.json | 47 +++ assets/robocraft/servenvmulti.config | 2 +- {rc_static_data => cdn}/Cargo.toml | 12 +- {rc_static_data => cdn}/build_arm64.sh | 0 {rc_static_data => cdn}/run_debug.sh | 2 +- cdn/src/cli.rs | 27 ++ cdn/src/main.rs | 29 ++ cdn/src/robocraft/live_data.rs | 7 + cdn/src/robocraft/mod.rs | 1 + rc_static_data/Rocket.toml | 12 - rc_static_data/src/cli.rs | 18 - rc_static_data/src/main.rs | 23 -- rc_static_data/src/robocraft/live_data.rs | 58 --- rc_static_data/src/robocraft/mod.rs | 7 - 16 files changed, 553 insertions(+), 141 deletions(-) create mode 100644 assets/robocraft/live_data.json rename {rc_static_data => cdn}/Cargo.toml (62%) rename {rc_static_data => cdn}/build_arm64.sh (100%) rename {rc_static_data => cdn}/run_debug.sh (74%) create mode 100644 cdn/src/cli.rs create mode 100644 cdn/src/main.rs create mode 100644 cdn/src/robocraft/live_data.rs create mode 100644 cdn/src/robocraft/mod.rs delete mode 100644 rc_static_data/Rocket.toml delete mode 100644 rc_static_data/src/cli.rs delete mode 100644 rc_static_data/src/main.rs delete mode 100644 rc_static_data/src/robocraft/live_data.rs delete mode 100644 rc_static_data/src/robocraft/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 3a87dec..022bf27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,212 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "actix-codec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f7b0a21988c1bf877cf4759ef5ddaac04c1c9fe808c9142ecb78ba97d97a28a" +dependencies = [ + "bitflags 2.8.0", + "bytes", + "futures-core", + "futures-sink", + "memchr", + "pin-project-lite", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "actix-files" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0773d59061dedb49a8aed04c67291b9d8cf2fe0b60130a381aab53c6dd86e9be" +dependencies = [ + "actix-http", + "actix-service", + "actix-utils", + "actix-web", + "bitflags 2.8.0", + "bytes", + "derive_more 0.99.20", + "futures-core", + "http-range", + "log", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite", + "v_htmlescape", +] + +[[package]] +name = "actix-http" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44dfe5c9e0004c623edc65391dfd51daa201e7e30ebd9c9bedf873048ec32bc2" +dependencies = [ + "actix-codec", + "actix-rt", + "actix-service", + "actix-utils", + "base64 0.22.1", + "bitflags 2.8.0", + "brotli", + "bytes", + "bytestring", + "derive_more 2.0.1", + "encoding_rs", + "flate2", + "foldhash", + "futures-core", + "h2", + "http 0.2.12", + "httparse", + "httpdate", + "itoa", + "language-tags", + "local-channel", + "mime", + "percent-encoding", + "pin-project-lite", + "rand 0.9.0", + "sha1", + "smallvec", + "tokio", + "tokio-util", + "tracing", + "zstd", +] + +[[package]] +name = "actix-macros" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" +dependencies = [ + "quote", + "syn 2.0.96", +] + +[[package]] +name = "actix-router" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d324164c51f63867b57e73ba5936ea151b8a41a1d23d1031eeb9f70d0236f8" +dependencies = [ + "bytestring", + "cfg-if", + "http 0.2.12", + "regex", + "regex-lite", + "serde", + "tracing", +] + +[[package]] +name = "actix-rt" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eda4e2a6e042aa4e55ac438a2ae052d3b5da0ecf83d7411e1a368946925208" +dependencies = [ + "futures-core", + "tokio", +] + +[[package]] +name = "actix-server" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6398974fd4284f4768af07965701efbbb5fdc0616bff20cade1bb14b77675e24" +dependencies = [ + "actix-rt", + "actix-service", + "actix-utils", + "futures-core", + "futures-util", + "mio 1.0.3", + "socket2", + "tokio", + "tracing", +] + +[[package]] +name = "actix-service" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e46f36bf0e5af44bdc4bdb36fbbd421aa98c79a9bce724e1edeb3894e10dc7f" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "actix-utils" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88a1dcdff1466e3c2488e1cb5c36a71822750ad43839937f85d2f4d9f8b705d8" +dependencies = [ + "local-waker", + "pin-project-lite", +] + +[[package]] +name = "actix-web" +version = "4.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2e3b15b3dc6c6ed996e4032389e9849d4ab002b1e92fbfe85b5f307d1479b4d" +dependencies = [ + "actix-codec", + "actix-http", + "actix-macros", + "actix-router", + "actix-rt", + "actix-server", + "actix-service", + "actix-utils", + "actix-web-codegen", + "bytes", + "bytestring", + "cfg-if", + "cookie 0.16.2", + "derive_more 2.0.1", + "encoding_rs", + "foldhash", + "futures-core", + "futures-util", + "impl-more", + "itoa", + "language-tags", + "log", + "mime", + "once_cell", + "pin-project-lite", + "regex", + "regex-lite", + "serde", + "serde_json", + "serde_urlencoded", + "smallvec", + "socket2", + "time", + "tracing", + "url", +] + +[[package]] +name = "actix-web-codegen" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f591380e2e68490b5dfaf1dd1aa0ebe78d84ba7067078512b4ea6e4492d622b8" +dependencies = [ + "actix-router", + "proc-macro2", + "quote", + "syn 2.0.96", +] + [[package]] name = "addr2line" version = "0.24.2" @@ -43,6 +249,21 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +dependencies = [ + "alloc-no-stdlib", +] + [[package]] name = "allocator-api2" version = "0.2.21" @@ -349,6 +570,27 @@ dependencies = [ "syn 2.0.96", ] +[[package]] +name = "brotli" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9991eea70ea4f293524138648e41ee89b0b2b12ddef3b255effa43c8056e0e0d" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "874bb8112abecc98cbd6d81ea4fa7e94fb9449648c93cc89aa40c81c24d7de03" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + [[package]] name = "bumpalo" version = "3.16.0" @@ -395,15 +637,35 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" +[[package]] +name = "bytestring" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e465647ae23b2823b0753f50decb2d5a86d2bb2cac04788fafd1f80e45378e5f" +dependencies = [ + "bytes", +] + [[package]] name = "cc" version = "1.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" dependencies = [ + "jobserver", + "libc", "shlex", ] +[[package]] +name = "cdn" +version = "0.2.0" +dependencies = [ + "actix-files", + "actix-web", + "clap", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -514,6 +776,23 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "cookie" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + [[package]] name = "cookie" version = "0.18.1" @@ -659,6 +938,40 @@ dependencies = [ "serde", ] +[[package]] +name = "derive_more" +version = "0.99.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6edb4b64a43d977b8e99788fe3a04d483834fba1215a7e02caa415b626497f7f" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.96", +] + +[[package]] +name = "derive_more" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.96", + "unicode-xid", +] + [[package]] name = "devise" version = "0.4.2" @@ -1243,6 +1556,12 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "http-range" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" + [[package]] name = "httparse" version = "1.9.5" @@ -1509,6 +1828,12 @@ dependencies = [ "icu_properties", ] +[[package]] +name = "impl-more" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a5a9a0ff0086c7a148acb942baaabeadf9504d10400b5a05645853729b9cd2" + [[package]] name = "indexmap" version = "2.7.1" @@ -1595,6 +1920,15 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +[[package]] +name = "jobserver" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.77" @@ -1640,6 +1974,12 @@ dependencies = [ "libc", ] +[[package]] +name = "language-tags" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" + [[package]] name = "lazy_static" version = "1.5.0" @@ -1726,6 +2066,23 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" +[[package]] +name = "local-channel" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6cbc85e69b8df4b8bb8b89ec634e7189099cea8927a276b7384ce5488e53ec8" +dependencies = [ + "futures-core", + "futures-sink", + "local-waker", +] + +[[package]] +name = "local-waker" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d873d7c67ce09b42110d801813efbc9364414e356be9935700d368351657487" + [[package]] name = "lock_api" version = "0.4.12" @@ -1788,6 +2145,16 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "miniz_oxide" version = "0.8.3" @@ -1822,6 +2189,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", + "log", "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", ] @@ -2718,17 +3086,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "rc_static_data" -version = "0.2.0" -dependencies = [ - "clap", - "env_logger", - "libfj", - "log", - "rocket", -] - [[package]] name = "rdrand" version = "0.4.0" @@ -2799,6 +3156,12 @@ dependencies = [ "regex-syntax 0.8.5", ] +[[package]] +name = "regex-lite" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" + [[package]] name = "regex-syntax" version = "0.6.29" @@ -2981,7 +3344,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e274915a20ee3065f611c044bd63c40757396b6dbc057d6046aec27f14f882b9" dependencies = [ - "cookie", + "cookie 0.18.1", "either", "futures", "http 0.2.12", @@ -3050,6 +3413,15 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + [[package]] name = "rustix" version = "0.38.44" @@ -3305,6 +3677,12 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" +[[package]] +name = "semver" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" + [[package]] name = "serde" version = "1.0.217" @@ -3954,6 +4332,7 @@ dependencies = [ "bytes", "libc", "mio 1.0.3", + "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", @@ -4177,6 +4556,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "unicase" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" + [[package]] name = "unicode-bidi" version = "0.3.18" @@ -4274,6 +4659,12 @@ dependencies = [ "serde", ] +[[package]] +name = "v_htmlescape" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e8257fbc510f0a46eb602c10215901938b5c2a7d5e70fc11483b1d3c9b5b18c" + [[package]] name = "valuable" version = "0.1.1" @@ -4839,3 +5230,31 @@ dependencies = [ "quote", "syn 2.0.96", ] + +[[package]] +name = "zstd" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.15+zstd.1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb81183ddd97d0c74cedf1d50d85c8d08c1b8b68ee863bdee9e706eedba1a237" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml index 3e57696..2366a92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,10 +13,10 @@ readme = "README.md" [workspace] members = [ - "auth", + "auth", "cdn", "polariton_auth", "rc_services", "rc_services_room", - "rc_static_data", "rc_microtransactions", + "rc_microtransactions", "rc_social", "rc_social_room", "rc_chat", "rc_chat_room", "rc_singleplayer", "rc_singleplayer_room", @@ -25,6 +25,8 @@ members = [ [workspace.dependencies] rocket = { version = "0.5.1", features = [ "json" ] } +actix-web = { version = "4" } +actix-files = "0.6" libfj = { version = "0.7.5", path = "../libfj" } log = "0.4" env_logger = "0.11" diff --git a/assets/robocraft/live_data.json b/assets/robocraft/live_data.json new file mode 100644 index 0000000..31b8df4 --- /dev/null +++ b/assets/robocraft/live_data.json @@ -0,0 +1,47 @@ +{ + "MaintenanceMode": "false", + "MaintenanceRegex": "", + "EacEnabled": "true", + "MinimumVersion": "2855", + "PhotonSocialServer": "rc-backend.servers.robocraftgame.com:4534", + "PhotonServicesServer": "rc-backend.servers.robocraftgame.com:4532", + "PhotonChatServer": "rc-backend.servers.robocraftgame.com:4530", + "PhotonSinglePlayerServer": "rc-backend.servers.robocraftgame.com:4536", + "GameplayServerServiceAddress": "rc-backend.servers.robocraftgame.com:4538", + "PhotonLobbyServer": "rc-backend.servers.robocraftgame.com:4540", + "ErrorLogAddress": "logs.freejamgames.com:4561", + "ServerErrorLogAddress": "logs.freejamgames.com:4562", + "authUrl": "http://127.0.0.1:8001/", + "paymentUrl": "http://127.0.0.1:8011/", + "enterBattleLogGenerationTimeout": "60", + "GameServerConnectionTestTimeout": 10, + "AvatarCdnUrl": "https://rc-cdn-images.robocraftgame.com/customavatar/Live/", + "ClanAvatarCdnUrl": "https://rc-cdn-images.robocraftgame.com/clanavatar/Live/", + "FeatureThrottlerOnPercent": "100", + "EmailCaptureEnabled": "true", + "UnreliableMessages": "true", + "MessageQueueEnabled": "true", + "BrawlDataUrl": "https://rc-cdn-images.robocraftgame.com/brawldata/Live/", + "CampaignDataUrl": "https://rc-cdn-images.robocraftgame.com/campaigndata/Live/", + "LeaderboardsUrl": "https://leaderboards.robocraftgame.com", + "NetworkChannelTypes": "3113", + "MaxSentMessageQueueSize": 64, + "IsAcksLong": 1, + "NetworkDropThreshold": 80, + "PacketSize": 1200, + "MaxPacketSize": 5888, + "MaxCombinedReliableMessageCount": 20, + "MaxCombinedReliableMessageSize": 200, + "MaxDelay": 1, + "OverflowThreshold": 10, + "MinUpdateTimeout": 1, + "DevMessageRefresh": 60, + "MaintenanceRefresh": 30, + "SaveRequestOnPhoton": "false", + "UseS3System": "true", + "authMigrationUrl": "http://88.150.159.132:3000/auth-migration", + "xsollaEnabled": "true", + "MaintenanceMessage": "Robocraft is currently undergoing server maintenance. ", + "DevMessage": "NGnius says hello", + "DevMessageDisplayTime": "10" +} diff --git a/assets/robocraft/servenvmulti.config b/assets/robocraft/servenvmulti.config index e7aabca..ba7a0d9 100644 --- a/assets/robocraft/servenvmulti.config +++ b/assets/robocraft/servenvmulti.config @@ -25,7 +25,7 @@ :4539 https://live-auth.rc.ngram.ca/ https://static.rc.ngram.ca/live/data.json - https://pay.rc.ngram.ca/live/data.json + https://pay.rc.ngram.ca/ diff --git a/rc_static_data/Cargo.toml b/cdn/Cargo.toml similarity index 62% rename from rc_static_data/Cargo.toml rename to cdn/Cargo.toml index ea72e78..81def9b 100644 --- a/rc_static_data/Cargo.toml +++ b/cdn/Cargo.toml @@ -1,15 +1,13 @@ [package] -name = "rc_static_data" +name = "cdn" version.workspace = true edition.workspace = true -readme.workspace = true -license.workspace = true repository.workspace = true +license.workspace = true authors.workspace = true +readme.workspace = true [dependencies] -rocket.workspace = true -libfj.workspace = true -log.workspace = true -env_logger.workspace = true +actix-web.workspace = true +actix-files.workspace = true clap.workspace = true diff --git a/rc_static_data/build_arm64.sh b/cdn/build_arm64.sh similarity index 100% rename from rc_static_data/build_arm64.sh rename to cdn/build_arm64.sh diff --git a/rc_static_data/run_debug.sh b/cdn/run_debug.sh similarity index 74% rename from rc_static_data/run_debug.sh rename to cdn/run_debug.sh index 6351ef2..a6e46e5 100755 --- a/rc_static_data/run_debug.sh +++ b/cdn/run_debug.sh @@ -1,3 +1,3 @@ #!/bin/bash -#cargo build + RUST_LOG=debug cargo run diff --git a/cdn/src/cli.rs b/cdn/src/cli.rs new file mode 100644 index 0000000..2b82125 --- /dev/null +++ b/cdn/src/cli.rs @@ -0,0 +1,27 @@ +use clap::Parser; + +#[derive(Parser, Debug, Clone)] +#[command(version, about, long_about = None)] +pub struct CliArgs { + /// TCP port on which to accept connections + #[arg(short, long, default_value_t = 8010)] + pub port: u16, + + /// IP Address on which to accept connections + #[arg(long, default_value_t = {"127.0.0.1".to_string()})] + pub ip: String, + + /// Assets root + #[arg(long, default_value_t = {"../assets/robocraft".to_string()})] + pub assets_robocraft: String, + + /// User data root + #[arg(long, default_value_t = {"../data/robocraft".to_string()})] + pub data_robocraft: String, +} + +impl CliArgs { + pub fn get() -> Self { + Self::parse() + } +} diff --git a/cdn/src/main.rs b/cdn/src/main.rs new file mode 100644 index 0000000..51605d9 --- /dev/null +++ b/cdn/src/main.rs @@ -0,0 +1,29 @@ +mod cli; +mod robocraft; + +use actix_web::{App, HttpServer, Responder}; + +#[actix_web::get("/")] +async fn index() -> impl Responder { + let name = env!("CARGO_PKG_NAME"); + let version = env!("CARGO_PKG_VERSION"); + let authors = env!("CARGO_PKG_AUTHORS"); + let license = env!("CARGO_PKG_LICENSE"); + let repo = env!("CARGO_PKG_REPOSITORY"); + format!("{} {} by [{}]\n{}\n{}", name, version, authors, license, repo) +} + +#[actix_web::main] +async fn main() -> std::io::Result<()> { + let cli_args = cli::CliArgs::get(); + let cli_args2 = cli_args.clone(); + HttpServer::new(move || { + App::new() + .app_data(actix_web::web::Data::new(cli_args2.clone())) + .service(index) + .service(robocraft::live_data::live_data_json) + }) + .bind((cli_args.ip, cli_args.port))? + .run() + .await +} diff --git a/cdn/src/robocraft/live_data.rs b/cdn/src/robocraft/live_data.rs new file mode 100644 index 0000000..9f448bc --- /dev/null +++ b/cdn/src/robocraft/live_data.rs @@ -0,0 +1,7 @@ +use actix_web::{get, Responder, web::Data}; + +#[get("/live/data.json")] +pub async fn live_data_json(cli: Data) -> impl Responder { + let path = std::path::PathBuf::from(&cli.assets_robocraft).join("live_data.json"); + actix_files::NamedFile::open_async(path).await +} diff --git a/cdn/src/robocraft/mod.rs b/cdn/src/robocraft/mod.rs new file mode 100644 index 0000000..eca8b6f --- /dev/null +++ b/cdn/src/robocraft/mod.rs @@ -0,0 +1 @@ +pub mod live_data; diff --git a/rc_static_data/Rocket.toml b/rc_static_data/Rocket.toml deleted file mode 100644 index 3841eb4..0000000 --- a/rc_static_data/Rocket.toml +++ /dev/null @@ -1,12 +0,0 @@ -## defaults for _all_ profiles -[default] -address = "127.0.0.1" -port = 8010 - -## set only when compiled in debug mode, i.e, `cargo build` -[debug] -port = 8010 - -## set only when compiled in release mode, i.e, `cargo build --release` -[release] -address = "0.0.0.0" diff --git a/rc_static_data/src/cli.rs b/rc_static_data/src/cli.rs deleted file mode 100644 index e8034cb..0000000 --- a/rc_static_data/src/cli.rs +++ /dev/null @@ -1,18 +0,0 @@ -use clap::Parser; - -#[derive(Parser, Debug)] -#[command(version, about, long_about = None)] -pub struct CliArgs { - /// URL of authentication web server - #[arg(long, default_value_t = {"http://127.0.0.1:8001/".to_string()})] - pub auth: String, - /// URL of microtransactions web server - #[arg(long, default_value_t = {"http://127.0.0.1:8011/".to_string()})] - pub pay: String, -} - -impl CliArgs { - pub fn get() -> Self { - Self::parse() - } -} diff --git a/rc_static_data/src/main.rs b/rc_static_data/src/main.rs deleted file mode 100644 index 6d7af13..0000000 --- a/rc_static_data/src/main.rs +++ /dev/null @@ -1,23 +0,0 @@ -#![forbid(unsafe_code)] -mod robocraft; -mod cli; - -#[rocket::get("/")] -fn index() -> String { - let name = env!("CARGO_PKG_NAME"); - let version = env!("CARGO_PKG_VERSION"); - let authors = env!("CARGO_PKG_AUTHORS"); - let license = env!("CARGO_PKG_LICENSE"); - let repo = env!("CARGO_PKG_REPOSITORY"); - format!("{} {} by [{}]\n{}\n{}", name, version, authors, license, repo) -} - -#[rocket::launch] -fn rocket() -> _ { - env_logger::init(); - let args = cli::CliArgs::get(); - rocket::build().mount("/", rocket::routes![index]) - .attach(robocraft::stage()) - .manage(args) -} - diff --git a/rc_static_data/src/robocraft/live_data.rs b/rc_static_data/src/robocraft/live_data.rs deleted file mode 100644 index eccdd9c..0000000 --- a/rc_static_data/src/robocraft/live_data.rs +++ /dev/null @@ -1,58 +0,0 @@ -use rocket::{get, routes, serde::json::Json, State}; - -#[get("/live/data.json")] -pub fn static_live_data(cli: &State) -> Json { - Json(libfj::robocraft::StaticDataRaw { - MaintenanceMode: "false".into(), - MaintenanceRegex: "".into(), - EacEnabled: "true".into(), - MinimumVersion: "2855".into(), - PhotonSocialServer: "rc-backend.servers.robocraftgame.com:4534".into(), - PhotonServicesServer: "rc-backend.servers.robocraftgame.com:4532".into(), - PhotonChatServer: "rc-backend.servers.robocraftgame.com:4530".into(), - PhotonSinglePlayerServer: "rc-backend.servers.robocraftgame.com:4536".into(), - GameplayServerServiceAddress: "rc-backend.servers.robocraftgame.com:4538".into(), - PhotonLobbyServer: "rc-backend.servers.robocraftgame.com:4540".into(), - ErrorLogAddress: "logs.freejamgames.com:4561".into(), - ServerErrorLogAddress: "logs.freejamgames.com:4562".into(), - authUrl: cli.auth.clone(), // originally "https://auth-backend.freejamgames.com/" - paymentUrl: cli.pay.clone(), - enterBattleLogGenerationTimeout: "60".into(), - GameServerConnectionTestTimeout: 10, - AvatarCdnUrl: "https://rc-cdn-images.robocraftgame.com/customavatar/Live/".into(), - ClanAvatarCdnUrl: "https://rc-cdn-images.robocraftgame.com/clanavatar/Live/".into(), - FeatureThrottlerOnPercent: "100".into(), - EmailCaptureEnabled: "true".into(), - UnreliableMessages: "true".into(), - MessageQueueEnabled: "true".into(), - BrawlDataUrl: "https://rc-cdn-images.robocraftgame.com/brawldata/Live/".into(), - CampaignDataUrl: "https://rc-cdn-images.robocraftgame.com/campaigndata/Live/".into(), - LeaderboardsUrl: "https://leaderboards.robocraftgame.com".into(), - NetworkChannelTypes: "3113".into(), - MaxSentMessageQueueSize: 64, - IsAcksLong: 1, - NetworkDropThreshold: 80, - PacketSize: 1200, - MaxPacketSize: 5888, - MaxCombinedReliableMessageCount: 20, - MaxCombinedReliableMessageSize: 200, - MaxDelay: 1, - OverflowThreshold: 10, - MinUpdateTimeout: 1, - DevMessageRefresh: 60, - MaintenanceRefresh: 30, - SaveRequestOnPhoton: "false".into(), - UseS3System: "true".into(), - authMigrationUrl: "http://88.150.159.132:3000/auth-migration".into(), - xsollaEnabled: "true".into(), - MaintenanceMessage: "Robocraft is currently undergoing server maintenance. ".into(), - DevMessage: "NGnius says hello".into(), - DevMessageDisplayTime: "10".into(), - }) -} - -pub fn stage() -> rocket::fairing::AdHoc { - rocket::fairing::AdHoc::on_ignite("Robocraft live data.json", |rocket| async { - rocket.mount("/", routes![static_live_data]) - }) -} diff --git a/rc_static_data/src/robocraft/mod.rs b/rc_static_data/src/robocraft/mod.rs deleted file mode 100644 index 979ba57..0000000 --- a/rc_static_data/src/robocraft/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -mod live_data; - -pub fn stage() -> rocket::fairing::AdHoc { - rocket::fairing::AdHoc::on_ignite("JSON", |rocket| async { - rocket.attach(live_data::stage()) - }) -}