1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Create basic CDN endpoints for #10

This commit is contained in:
NG (Graham)
2025-05-24 16:21:45 -04:00
parent e7de53929d
commit 59612e6aa3
12 changed files with 53 additions and 7 deletions

2
Cargo.lock generated
View File

@@ -664,6 +664,8 @@ dependencies = [
"actix-files", "actix-files",
"actix-web", "actix-web",
"clap", "clap",
"env_logger",
"log",
] ]
[[package]] [[package]]

View File

@@ -15,14 +15,14 @@
"paymentUrl": "http://127.0.0.1:8011/", "paymentUrl": "http://127.0.0.1:8011/",
"enterBattleLogGenerationTimeout": "60", "enterBattleLogGenerationTimeout": "60",
"GameServerConnectionTestTimeout": 10, "GameServerConnectionTestTimeout": 10,
"AvatarCdnUrl": "https://rc-cdn-images.robocraftgame.com/customavatar/Live/", "AvatarCdnUrl": "http://127.0.0.1:8010/customavatar/Live/",
"ClanAvatarCdnUrl": "https://rc-cdn-images.robocraftgame.com/clanavatar/Live/", "ClanAvatarCdnUrl": "http://127.0.0.1:8010/clanavatar/Live/",
"FeatureThrottlerOnPercent": "100", "FeatureThrottlerOnPercent": "100",
"EmailCaptureEnabled": "true", "EmailCaptureEnabled": "true",
"UnreliableMessages": "true", "UnreliableMessages": "true",
"MessageQueueEnabled": "true", "MessageQueueEnabled": "true",
"BrawlDataUrl": "https://rc-cdn-images.robocraftgame.com/brawldata/Live/", "BrawlDataUrl": "http://127.0.0.1:8010/brawldata/Live/",
"CampaignDataUrl": "https://rc-cdn-images.robocraftgame.com/campaigndata/Live/", "CampaignDataUrl": "http://127.0.0.1:8010/campaigndata/Live/",
"LeaderboardsUrl": "https://leaderboards.robocraftgame.com", "LeaderboardsUrl": "https://leaderboards.robocraftgame.com",
"NetworkChannelTypes": "3113", "NetworkChannelTypes": "3113",
"MaxSentMessageQueueSize": 64, "MaxSentMessageQueueSize": 64,

View File

@@ -11,3 +11,5 @@ readme.workspace = true
actix-web.workspace = true actix-web.workspace = true
actix-files.workspace = true actix-files.workspace = true
clap.workspace = true clap.workspace = true
log.workspace = true
env_logger.workspace = true

View File

@@ -15,6 +15,7 @@ async fn index() -> impl Responder {
#[actix_web::main] #[actix_web::main]
async fn main() -> std::io::Result<()> { async fn main() -> std::io::Result<()> {
env_logger::init();
let cli_args = cli::CliArgs::get(); let cli_args = cli::CliArgs::get();
let cli_args2 = cli_args.clone(); let cli_args2 = cli_args.clone();
HttpServer::new(move || { HttpServer::new(move || {
@@ -22,6 +23,10 @@ async fn main() -> std::io::Result<()> {
.app_data(actix_web::web::Data::new(cli_args2.clone())) .app_data(actix_web::web::Data::new(cli_args2.clone()))
.service(index) .service(index)
.service(robocraft::live_data::live_data_json) .service(robocraft::live_data::live_data_json)
.service(robocraft::user_avatar::get)
.service(robocraft::clan_avatar::get)
.service(robocraft::brawl_data::get)
.service(robocraft::campaign_data::get)
}) })
.bind((cli_args.ip, cli_args.port))? .bind((cli_args.ip, cli_args.port))?
.run() .run()

View File

@@ -0,0 +1,8 @@
use actix_web::{dev::ResourcePath, get, web::{Data, Path}, Responder};
#[get("/brawldata/Live/{name}")]
pub async fn get(cli: Data<crate::cli::CliArgs>, name: Path<String>) -> impl Responder {
let path = std::path::PathBuf::from(&cli.data_robocraft).join("brawldata").join(format!("{}.jpg", name.path()));
log::debug!("RC asset at {} (exists? {})", path.display(), path.exists());
actix_files::NamedFile::open_async(path).await
}

View File

@@ -0,0 +1,8 @@
use actix_web::{dev::ResourcePath, get, web::{Data, Path}, Responder};
#[get("/campaigndata/Live/{name}")]
pub async fn get(cli: Data<crate::cli::CliArgs>, name: Path<String>) -> impl Responder {
let path = std::path::PathBuf::from(&cli.data_robocraft).join("campaigndata").join(format!("{}.jpg", name.path()));
log::debug!("RC asset at {} (exists? {})", path.display(), path.exists());
actix_files::NamedFile::open_async(path).await
}

View File

@@ -0,0 +1,8 @@
use actix_web::{dev::ResourcePath, get, web::{Data, Path}, Responder};
#[get("/clanavatar/Live/{name}")]
pub async fn get(cli: Data<crate::cli::CliArgs>, name: Path<String>) -> impl Responder {
let path = std::path::PathBuf::from(&cli.data_robocraft).join("clanavatar").join(format!("{}.jpg", name.path()));
log::debug!("RC asset at {} (exists? {})", path.display(), path.exists());
actix_files::NamedFile::open_async(path).await
}

View File

@@ -3,5 +3,6 @@ use actix_web::{get, Responder, web::Data};
#[get("/live/data.json")] #[get("/live/data.json")]
pub async fn live_data_json(cli: Data<crate::cli::CliArgs>) -> impl Responder { pub async fn live_data_json(cli: Data<crate::cli::CliArgs>) -> impl Responder {
let path = std::path::PathBuf::from(&cli.assets_robocraft).join("live_data.json"); let path = std::path::PathBuf::from(&cli.assets_robocraft).join("live_data.json");
log::debug!("RC asset at {} (exists? {})", path.display(), path.exists());
actix_files::NamedFile::open_async(path).await actix_files::NamedFile::open_async(path).await
} }

View File

@@ -1 +1,5 @@
pub mod live_data; pub mod live_data;
pub mod user_avatar;
pub mod clan_avatar;
pub mod brawl_data;
pub mod campaign_data;

View File

@@ -0,0 +1,8 @@
use actix_web::{dev::ResourcePath, get, web::{Data, Path}, Responder};
#[get("/customavatar/Live/{name}")]
pub async fn get(cli: Data<crate::cli::CliArgs>, name: Path<String>) -> impl Responder {
let path = std::path::PathBuf::from(&cli.data_robocraft).join("customavatars").join(format!("{}.jpg", name.path()));
log::debug!("RC asset at {} (exists? {})", path.display(), path.exists());
actix_files::NamedFile::open_async(path).await
}

View File

@@ -14,7 +14,7 @@ pub(super) fn clan_invites_provider<C: Send + Sync>() -> SimpleFunc<39, crate::U
ClanInviteInfo { ClanInviteInfo {
username: "RE_user1".to_owned(), username: "RE_user1".to_owned(),
display_name: "RE_user1".to_owned(), display_name: "RE_user1".to_owned(),
clan_name: "RE_clan1".to_owned(), clan_name: "RE_clan_invite1".to_owned(),
clan_size: 42, clan_size: 42,
use_custom_avatar: false, use_custom_avatar: false,
avatar_id: 0, avatar_id: 0,

View File

@@ -25,8 +25,8 @@ pub(super) fn search_clans_provider<C: Send + Sync>() -> SimpleFunc<32, crate::U
ty: polariton::serdes::TypePrefix::HashMap, // hashmap ty: polariton::serdes::TypePrefix::HashMap, // hashmap
items: vec![ items: vec![
ClanInfo { ClanInfo {
clan_name: "".to_owned(), clan_name: "RE_clan_search_name".to_owned(),
clan_description: "".to_owned(), clan_description: "RE_clan_search_description".to_owned(),
clan_type: ClanType::Closed, clan_type: ClanType::Closed,
clan_size: 1, clan_size: 1,
}.as_transmissible(), }.as_transmissible(),