mirror of
https://git.neonteam.dev/amizing/robinsr.git
synced 2025-03-12 03:28:30 -04:00
add version config
This commit is contained in:
parent
46ae86cacf
commit
8c26e6b0f8
@ -10,6 +10,8 @@ env_logger.workspace = true
|
||||
axum.workspace = true
|
||||
axum-server.workspace = true
|
||||
|
||||
lazy_static.workspace = true
|
||||
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
|
||||
|
||||
3
sdkserver/src/config/mod.rs
Normal file
3
sdkserver/src/config/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
mod version_config;
|
||||
|
||||
pub use version_config::INSTANCE as versions;
|
||||
29
sdkserver/src/config/version_config.rs
Normal file
29
sdkserver/src/config/version_config.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use serde::Deserialize;
|
||||
use serde_json::from_str;
|
||||
|
||||
const DEFAULT_VERSIONS: &str = include_str!("../../versions.json");
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct VersionConfig {
|
||||
pub asset_bundle_url: String,
|
||||
pub ex_resource_url: String,
|
||||
pub lua_url: String,
|
||||
pub lua_version: String,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
pub static ref INSTANCE: HashMap<String, VersionConfig> = {
|
||||
let local_config = std::path::Path::new("versions.json");
|
||||
let data = if local_config.exists() {
|
||||
std::fs::read_to_string("versions.json").unwrap()
|
||||
} else {
|
||||
std::fs::write("versions.json", DEFAULT_VERSIONS).unwrap();
|
||||
DEFAULT_VERSIONS.to_string()
|
||||
};
|
||||
|
||||
from_str(&data).unwrap()
|
||||
};
|
||||
}
|
||||
@ -5,6 +5,7 @@ use logging::init_tracing;
|
||||
use services::{auth, dispatch, errors};
|
||||
use tracing::Level;
|
||||
|
||||
mod config;
|
||||
mod logging;
|
||||
mod services;
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
use crate::config::versions;
|
||||
use axum::extract::Query;
|
||||
use prost::Message;
|
||||
use proto::{Dispatch, Gateserver, RegionInfo};
|
||||
use serde::Deserialize;
|
||||
|
||||
pub const QUERY_DISPATCH_ENDPOINT: &str = "/query_dispatch";
|
||||
pub const QUERY_GATEWAY_ENDPOINT: &str = "/query_gateway";
|
||||
@ -24,38 +27,45 @@ pub async fn query_dispatch() -> String {
|
||||
rbase64::encode(&buff)
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct QueryGatewayParameters {
|
||||
pub version: String,
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
pub async fn query_gateway() -> String {
|
||||
let rsp = Gateserver {
|
||||
retcode: 0,
|
||||
ip: String::from("127.0.0.1"),
|
||||
port: 23301,
|
||||
asset_bundle_url: String::from(
|
||||
"https://autopatchcn.bhsr.com/asb/BetaLive/output_6828321_72f2df86102b",
|
||||
),
|
||||
lua_url: String::from(
|
||||
"https://autopatchcn.bhsr.com/lua/BetaLive/output_6828764_f749b48347fd",
|
||||
),
|
||||
ex_resource_url: String::from(
|
||||
"https://autopatchcn.bhsr.com/design_data/BetaLive/output_6834225_44836493b261",
|
||||
),
|
||||
ifix_version: String::from("0"),
|
||||
lua_version: String::from("6755976"),
|
||||
jblkncaoiao: true,
|
||||
hjdjakjkdbi: true,
|
||||
ldknmcpffim: true,
|
||||
feehapamfci: true,
|
||||
eebfeohfpph: true,
|
||||
dfmjjcfhfea: true,
|
||||
najikcgjgan: true,
|
||||
giddjofkndm: true,
|
||||
fbnbbembcgn: false,
|
||||
dedgfjhbnok: false,
|
||||
use_tcp: true,
|
||||
linlaijbboh: false,
|
||||
ahmbfbkhmgh: false,
|
||||
nmdccehcdcc: false,
|
||||
..Default::default()
|
||||
pub async fn query_gateway(parameters: Query<QueryGatewayParameters>) -> String {
|
||||
let rsp = if let Some(config) = versions.get(¶meters.version) {
|
||||
Gateserver {
|
||||
retcode: 0,
|
||||
ip: String::from("127.0.0.1"),
|
||||
port: 23301,
|
||||
asset_bundle_url: config.asset_bundle_url.clone(),
|
||||
ex_resource_url: config.ex_resource_url.clone(),
|
||||
lua_url: config.lua_url.clone(),
|
||||
lua_version: config.lua_version.clone(),
|
||||
ifix_version: String::from("0"),
|
||||
jblkncaoiao: true,
|
||||
hjdjakjkdbi: true,
|
||||
ldknmcpffim: true,
|
||||
feehapamfci: true,
|
||||
eebfeohfpph: true,
|
||||
dfmjjcfhfea: true,
|
||||
najikcgjgan: true,
|
||||
giddjofkndm: true,
|
||||
fbnbbembcgn: false,
|
||||
dedgfjhbnok: false,
|
||||
use_tcp: true,
|
||||
linlaijbboh: false,
|
||||
ahmbfbkhmgh: false,
|
||||
nmdccehcdcc: false,
|
||||
..Default::default()
|
||||
}
|
||||
} else {
|
||||
Gateserver {
|
||||
retcode: 9,
|
||||
msg: format!("forbidden version: {} or invalid bind", parameters.version),
|
||||
..Default::default()
|
||||
}
|
||||
};
|
||||
|
||||
let mut buff = Vec::new();
|
||||
|
||||
40
sdkserver/versions.json
Normal file
40
sdkserver/versions.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"OSBETAWin2.1.51": {
|
||||
"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"
|
||||
},
|
||||
"CNBETAWin2.1.51": {
|
||||
"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"
|
||||
},
|
||||
|
||||
"OSBETAWin2.1.52": {
|
||||
"asset_bundle_url": "https://autopatchcn.bhsr.com/asb/BetaLive/output_6785106_15237df2ef89",
|
||||
"ex_resource_url": "https://autopatchcn.bhsr.com/design_data/BetaLive/output_6787319_5f3f1dae4769",
|
||||
"lua_url": "https://autopatchcn.bhsr.com/lua/BetaLive/output_6785460_26c4b6c61a8b",
|
||||
"lua_version": "6785460"
|
||||
},
|
||||
"CNBETAWin2.1.52": {
|
||||
"asset_bundle_url": "https://autopatchcn.bhsr.com/asb/BetaLive/output_6785106_15237df2ef89",
|
||||
"ex_resource_url": "https://autopatchcn.bhsr.com/design_data/BetaLive/output_6787319_5f3f1dae4769",
|
||||
"lua_url": "https://autopatchcn.bhsr.com/lua/BetaLive/output_6785460_26c4b6c61a8b",
|
||||
"lua_version": "6785460"
|
||||
},
|
||||
|
||||
"OSBETAWin2.1.53": {
|
||||
"asset_bundle_url": "https://autopatchcn.bhsr.com/asb/BetaLive/output_6828321_72f2df86102b",
|
||||
"ex_resource_url": "https://autopatchcn.bhsr.com/design_data/BetaLive/output_6834225_44836493b261",
|
||||
"lua_url": "https://autopatchcn.bhsr.com/lua/BetaLive/output_6828764_f749b48347fd",
|
||||
"lua_version": "6828764"
|
||||
},
|
||||
"CNBETAWin2.1.53": {
|
||||
"asset_bundle_url": "https://autopatchcn.bhsr.com/asb/BetaLive/output_6828321_72f2df86102b",
|
||||
"ex_resource_url": "https://autopatchcn.bhsr.com/design_data/BetaLive/output_6834225_44836493b261",
|
||||
"lua_url": "https://autopatchcn.bhsr.com/lua/BetaLive/output_6828764_f749b48347fd",
|
||||
"lua_version": "6828764"
|
||||
}
|
||||
}
|
||||
40
versions.json
Normal file
40
versions.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"OSBETAWin2.1.51": {
|
||||
"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"
|
||||
},
|
||||
"CNBETAWin2.1.51": {
|
||||
"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"
|
||||
},
|
||||
|
||||
"OSBETAWin2.1.52": {
|
||||
"asset_bundle_url": "https://autopatchcn.bhsr.com/asb/BetaLive/output_6785106_15237df2ef89",
|
||||
"ex_resource_url": "https://autopatchcn.bhsr.com/design_data/BetaLive/output_6787319_5f3f1dae4769",
|
||||
"lua_url": "https://autopatchcn.bhsr.com/lua/BetaLive/output_6785460_26c4b6c61a8b",
|
||||
"lua_version": "6785460"
|
||||
},
|
||||
"CNBETAWin2.1.52": {
|
||||
"asset_bundle_url": "https://autopatchcn.bhsr.com/asb/BetaLive/output_6785106_15237df2ef89",
|
||||
"ex_resource_url": "https://autopatchcn.bhsr.com/design_data/BetaLive/output_6787319_5f3f1dae4769",
|
||||
"lua_url": "https://autopatchcn.bhsr.com/lua/BetaLive/output_6785460_26c4b6c61a8b",
|
||||
"lua_version": "6785460"
|
||||
},
|
||||
|
||||
"OSBETAWin2.1.53": {
|
||||
"asset_bundle_url": "https://autopatchcn.bhsr.com/asb/BetaLive/output_6828321_72f2df86102b",
|
||||
"ex_resource_url": "https://autopatchcn.bhsr.com/design_data/BetaLive/output_6834225_44836493b261",
|
||||
"lua_url": "https://autopatchcn.bhsr.com/lua/BetaLive/output_6828764_f749b48347fd",
|
||||
"lua_version": "6828764"
|
||||
},
|
||||
"CNBETAWin2.1.53": {
|
||||
"asset_bundle_url": "https://autopatchcn.bhsr.com/asb/BetaLive/output_6828321_72f2df86102b",
|
||||
"ex_resource_url": "https://autopatchcn.bhsr.com/design_data/BetaLive/output_6834225_44836493b261",
|
||||
"lua_url": "https://autopatchcn.bhsr.com/lua/BetaLive/output_6828764_f749b48347fd",
|
||||
"lua_version": "6828764"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user