SDKServer: query_gateway cdn links configuration

This commit is contained in:
xeon 2024-03-29 13:31:19 +03:00
parent bfe0374bfe
commit bccf928bbe
5 changed files with 42 additions and 17 deletions

View file

@ -14,17 +14,13 @@ lazy_static = "1.4.0"
axum = "0.7.4"
axum-server = "0.6.0"
dirs = "5.0.1"
dotenv = "0.15.0"
env_logger = "0.11.3"
rbase64 = "2.0.3"
rand = "0.8.5"
rsa = { version = "0.9.6", features = [
"sha1",
"nightly",
"pkcs5",
"serde",
"sha2",
] }
prost = "0.12.3"
prost-types = "0.12.3"

4
sdkserver/.env Normal file
View file

@ -0,0 +1,4 @@
ASSET_BUNDLE_URL=https://autopatchcn.bhsr.com/asb/BetaLive/output_6744505_89b2f5dc973e
EX_RESOURCE_URL=https://autopatchcn.bhsr.com/design_data/BetaLive/output_6759713_b4e0e740f0da
LUA_URL=https://autopatchcn.bhsr.com/lua/BetaLive/output_6755976_3c46d7c46e2c
LUA_VERSION=6755976

View file

@ -10,6 +10,9 @@ env_logger.workspace = true
axum.workspace = true
axum-server.workspace = true
dirs.workspace = true
dotenv.workspace = true
serde.workspace = true
serde_json.workspace = true

View file

@ -3,16 +3,19 @@ use axum::routing::{get, post};
use axum::Router;
use logging::init_tracing;
use services::{auth, dispatch, errors};
use std::path::Path;
use tracing::Level;
mod logging;
mod services;
const PORT: u16 = 21000;
const DEFAULT_DOTENV: &str = include_str!("../.env");
#[tokio::main]
async fn main() -> Result<()> {
init_tracing();
init_config()?;
let span = tracing::span!(Level::DEBUG, "main");
let _ = span.enter();
@ -49,3 +52,26 @@ async fn main() -> Result<()> {
Ok(())
}
fn init_config() -> Result<()> {
let local_dotenv = Path::new(".env");
if local_dotenv.exists() {
dotenv::dotenv()?;
} else {
let config = dirs::config_dir()
.ok_or_else(|| anyhow::anyhow!("No config directory found"))?
.join("hkrpg-sdkserver");
std::fs::create_dir_all(&config)?;
let env = config.join(".env");
if !env.exists() {
std::fs::write(&env, DEFAULT_DOTENV)?;
}
dotenv::from_path(&env)?;
}
Ok(())
}

View file

@ -1,3 +1,5 @@
use std::env;
use prost::Message;
use proto::{Dispatch, Gateserver, RegionInfo};
@ -30,17 +32,11 @@ pub async fn query_gateway() -> String {
retcode: 0,
ip: String::from("127.0.0.1"),
port: 23301,
asset_bundle_url: String::from(
"https://autopatchcn.bhsr.com/asb/BetaLive/output_6744505_89b2f5dc973e",
),
lua_url: String::from(
"https://autopatchcn.bhsr.com/lua/BetaLive/output_6755976_3c46d7c46e2c",
),
ex_resource_url: String::from(
"https://autopatchcn.bhsr.com/design_data/BetaLive/output_6759713_b4e0e740f0da",
),
asset_bundle_url: env::var("ASSET_BUNDLE_URL").unwrap(),
ex_resource_url: env::var("EX_RESOURCE_URL").unwrap(),
lua_url: env::var("LUA_URL").unwrap(),
lua_version: env::var("LUA_VERSION").unwrap(),
ifix_version: String::from("0"),
lua_version: String::from("6755976"),
jblkncaoiao: true,
hjdjakjkdbi: true,
ldknmcpffim: true,