mirror of
https://github.com/MikuLeaks/KianaBH3.git
synced 2025-12-12 21:04:41 +01:00
Init enter game
This commit is contained in:
41
SdkServer/Handlers/Dispatch/QueryDispatchController.cs
Normal file
41
SdkServer/Handlers/Dispatch/QueryDispatchController.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using KianaBH.Configuration;
|
||||
using KianaBH.Data.Models.Dispatch;
|
||||
using KianaBH.Util;
|
||||
using KianaBH.Util.Crypto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace KianaBH.SdkServer.Handlers.Dispatch;
|
||||
|
||||
[ApiController]
|
||||
public class QueryDispatchController : ControllerBase
|
||||
{
|
||||
[HttpGet("/query_dispatch")]
|
||||
public IActionResult QueryDispatch([FromQuery] DispatchQuery query, Logger logger)
|
||||
{
|
||||
var version = HotfixContainer.ExtractVersionNumber(query.Version);
|
||||
if (!ConfigManager.Hotfix.Hotfixes.ContainsKey(version))
|
||||
{
|
||||
logger.Warn($"Client sent requesting unsupported game version: {version}");
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
var response = new QueryDispatchResponse
|
||||
{
|
||||
Retcode = 0,
|
||||
RegionList =
|
||||
[
|
||||
new QueryDispatchResponse.RegionInfo
|
||||
{
|
||||
Retcode = 0,
|
||||
DispatchUrl =
|
||||
$"{ConfigManager.Config.HttpServer.GetDisplayAddress()}/query_gateway",
|
||||
Ext = null,
|
||||
Name = "KianaBH",
|
||||
Title = "KianaBH",
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
return Ok(DispatchEncryption.EncryptDispatchContent(version, response));
|
||||
}
|
||||
}
|
||||
191
SdkServer/Handlers/Dispatch/QueryGatewayController.cs
Normal file
191
SdkServer/Handlers/Dispatch/QueryGatewayController.cs
Normal file
@@ -0,0 +1,191 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using KianaBH.Configuration;
|
||||
using KianaBH.Data.Models.Dispatch;
|
||||
using KianaBH.Util;
|
||||
using KianaBH.Util.Crypto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace KianaBH.SdkServer.Handlers.Dispatch;
|
||||
|
||||
[ApiController]
|
||||
public class QueryGatewayController : ControllerBase
|
||||
{
|
||||
[HttpGet("/query_gateway")]
|
||||
public IActionResult QueryGateway([FromQuery] DispatchQuery query, Logger logger)
|
||||
{
|
||||
var version = HotfixContainer.ExtractVersionNumber(query.Version);
|
||||
|
||||
if (!ConfigManager.Hotfix.Hotfixes.TryGetValue(version, out var hotfix))
|
||||
{
|
||||
logger.Warn($"Client sent requesting unsupported game version: {version}");
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
var serverInfo = new QueryGatewayResponse.ServerInfo
|
||||
{
|
||||
Ip = ConfigManager.Config.GameServer.PublicAddress,
|
||||
Port = ConfigManager.Config.GameServer.Port,
|
||||
IsKcp = true,
|
||||
};
|
||||
|
||||
var assetBundleUrlList = UrlProvider.GetAssetBundleUrlList(query.Version!);
|
||||
var exResourceUrlList = UrlProvider.GetExResourceUrlList(query.Version!);
|
||||
var exAudioAndVideoUrlList = UrlProvider.GetExAudioAndVideoUrlList(query.Version!);
|
||||
|
||||
var response = new QueryGatewayResponse
|
||||
{
|
||||
AccountUrl = $"{ConfigManager.Config.HttpServer.GetDisplayAddress()}/",
|
||||
Gameserver = serverInfo,
|
||||
Gateway = serverInfo,
|
||||
AssetBundleUrlList = assetBundleUrlList,
|
||||
ExResourceUrlList = exResourceUrlList,
|
||||
ExAudioAndVideoUrlList = exAudioAndVideoUrlList,
|
||||
Manifest = hotfix,
|
||||
Ext = new Dictionary<string, object>
|
||||
{
|
||||
{ "ex_res_use_http", "0" },
|
||||
{ "is_xxxx", "0" },
|
||||
{ "elevator_model_path", "GameEntry/EVA/StartLoading_Model" },
|
||||
{ "block_error_dialog", "1" },
|
||||
{ "ex_res_pre_publish", "0" },
|
||||
{ "ex_resource_url_list", exResourceUrlList },
|
||||
{ "apm_switch_game_log", "1" },
|
||||
{ "ex_audio_and_video_url_list", exAudioAndVideoUrlList },
|
||||
{ "apm_log_dest", "2" },
|
||||
{ "update_streaming_asb", "1" },
|
||||
{ "use_multy_cdn", "1" },
|
||||
{ "show_bulletin_empty_dialog_bg", "0" },
|
||||
{ "ai_use_asset_boundle", "1" },
|
||||
{ "res_use_asset_boundle", "1" },
|
||||
{ "apm_log_level", "0" },
|
||||
{ "apm_switch_crash", "1" },
|
||||
{ "network_feedback_enable", "0" },
|
||||
{ "new_audio_upload", "1" },
|
||||
{ "apm_switch", "1" }
|
||||
}
|
||||
};
|
||||
|
||||
return Ok(DispatchEncryption.EncryptDispatchContent(version, response));
|
||||
}
|
||||
}
|
||||
|
||||
public static partial class UrlProvider
|
||||
{
|
||||
[GeneratedRegex("^(.*?)_(os|gf|global)_(.*?)$")]
|
||||
private static partial Regex VersionRegex();
|
||||
|
||||
public static List<string> GetAssetBundleUrlList(string version)
|
||||
{
|
||||
var match = VersionRegex().Match(version);
|
||||
if (!match.Success) return [];
|
||||
|
||||
var type = match.Groups[2].Value;
|
||||
|
||||
if (ConfigManager.Hotfix.UseLocalCache) return GetLocalUrlList(type, version);
|
||||
|
||||
return type switch
|
||||
{
|
||||
"os" =>
|
||||
[
|
||||
"https://autopatchos.honkaiimpact3.com/asset_bundle/overseas01/1.1",
|
||||
"https://bundle-aliyun-os.honkaiimpact3.com/asset_bundle/overseas01/1.1",
|
||||
],
|
||||
"gf" when version.Contains("beta") =>
|
||||
[
|
||||
"https://autopatchbeta.bh3.com/asset_bundle/beta_release/1.0",
|
||||
"https://autopatchbeta.bh3.com/asset_bundle/beta_release/1.0",
|
||||
],
|
||||
"gf" =>
|
||||
[
|
||||
"https://bundle-qcloud.bh3.com/asset_bundle/android01/1.0",
|
||||
"https://bundle.bh3.com/asset_bundle/android01/1.0",
|
||||
],
|
||||
"global" =>
|
||||
[
|
||||
"http://hk-bundle-west-mihayo.akamaized.net/asset_bundle/usa01/1.1",
|
||||
"http://bundle-aliyun-usa.honkaiimpact3.com/asset_bundle/usa01/1.1",
|
||||
],
|
||||
_ =>
|
||||
[
|
||||
"https://bundle-aliyun-os.honkaiimpact3.com/asset_bundle/overseas01/1.1",
|
||||
"https://hk-bundle-os-mihayo.akamaized.net/asset_bundle/overseas01/1.1",
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
public static List<string> GetExAudioAndVideoUrlList(string version)
|
||||
{
|
||||
var match = VersionRegex().Match(version);
|
||||
if (!match.Success) return [];
|
||||
|
||||
var type = match.Groups[2].Value;
|
||||
|
||||
if (ConfigManager.Hotfix.UseLocalCache) return GetLocalUrlList(type, version);
|
||||
|
||||
return type switch
|
||||
{
|
||||
"os" =>
|
||||
[
|
||||
"autopatchos.honkaiimpact3.com/com.miHoYo.bh3oversea",
|
||||
"bigfile-aliyun-os.honkaiimpact3.com/com.miHoYo.bh3oversea",
|
||||
],
|
||||
"gf" when version.Contains("beta") =>
|
||||
[
|
||||
"autopatchbeta.bh3.com/tmp/CGAudio",
|
||||
"autopatchbeta.bh3.com/tmp/CGAudio",
|
||||
],
|
||||
_ =>
|
||||
[
|
||||
"bh3rd-beta-qcloud.bh3.com/tmp/CGAudio",
|
||||
"bh3rd-beta.bh3.com/tmp/CGAudio",
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
public static List<string> GetExResourceUrlList(string version)
|
||||
{
|
||||
var match = VersionRegex().Match(version);
|
||||
if (!match.Success) return [];
|
||||
|
||||
var type = match.Groups[2].Value;
|
||||
|
||||
if (ConfigManager.Hotfix.UseLocalCache) return GetLocalUrlList(type, version);
|
||||
|
||||
return type switch
|
||||
{
|
||||
"os" =>
|
||||
[
|
||||
"autopatchos.honkaiimpact3.com/com.miHoYo.bh3oversea",
|
||||
"bigfile-aliyun-os.honkaiimpact3.com/com.miHoYo.bh3oversea",
|
||||
],
|
||||
"gf" when version.Contains("beta") =>
|
||||
[
|
||||
"autopatchbeta.bh3.com/tmp/beta",
|
||||
"autopatchbeta.bh3.com/tmp/beta",
|
||||
],
|
||||
"gf" =>
|
||||
[
|
||||
"bundle-qcloud.bh3.com/tmp/Original",
|
||||
"bundle.bh3.com/tmp/Original",
|
||||
],
|
||||
"global" =>
|
||||
[
|
||||
"hk-bundle-west-mihayo.akamaized.net/tmp/com.miHoYo.bh3global",
|
||||
"bigfile-aliyun-usa.honkaiimpact3.com/tmp/com.miHoYo.bh3global",
|
||||
],
|
||||
_ =>
|
||||
[
|
||||
"bigfile-aliyun-os.honkaiimpact3.com/com.miHoYo.bh3oversea",
|
||||
"hk-bigfile-os-mihayo.akamaized.net/com.miHoYo.bh3oversea",
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
private static List<string> GetLocalUrlList(string type, string version)
|
||||
{
|
||||
var formattedVersion = version.Replace(".", "_");
|
||||
var baseUrl =
|
||||
$"{ConfigManager.Config.HttpServer.GetDisplayAddress()}/statics/{type}/{formattedVersion}";
|
||||
return [baseUrl, baseUrl];
|
||||
}
|
||||
}
|
||||
33
SdkServer/Handlers/Sdk/AbTestController.cs
Normal file
33
SdkServer/Handlers/Sdk/AbTestController.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using KianaBH.Data.Models.Sdk;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace KianaBH.SdkServer.Handlers.Sdk;
|
||||
|
||||
[ApiController]
|
||||
public class AbTestController : ControllerBase
|
||||
{
|
||||
[HttpPost("/data_abtest_api/config/experiment/list")]
|
||||
public IActionResult GetExperimentList()
|
||||
{
|
||||
return Ok(new ResponseBase
|
||||
{
|
||||
Data = new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
code = 1000,
|
||||
type = 2,
|
||||
config_id = "169",
|
||||
period_id = "6524_721",
|
||||
version = 2,
|
||||
configs = new
|
||||
{
|
||||
hoyopass_enable = false
|
||||
},
|
||||
sceneWhiteList = false,
|
||||
experimentWhiteList = false,
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
123
SdkServer/Handlers/Sdk/ComboGranterController.cs
Normal file
123
SdkServer/Handlers/Sdk/ComboGranterController.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using KianaBH.Data.Models.Sdk;
|
||||
using KianaBH.Database.Account;
|
||||
using KianaBH.Util;
|
||||
|
||||
namespace KianaBH.SdkServer.Handlers.Sdk;
|
||||
|
||||
[ApiController]
|
||||
public class ComboGranterController : Controller
|
||||
{
|
||||
[HttpPost("/{productName}/combo/granter/login/v2/login")]
|
||||
public async Task<IActionResult> ComboLoginV2(string productName, [FromBody] ComboGranterRequest request)
|
||||
{
|
||||
// TODO: Reuse this logic with MDK Controller Verify Token
|
||||
|
||||
int accountUid;
|
||||
try
|
||||
{
|
||||
accountUid = int.Parse(request.Data?.Uid!);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Ok(new ResponseBase
|
||||
{
|
||||
Retcode = -101,
|
||||
Success = false,
|
||||
Message = "Account token error"
|
||||
});
|
||||
}
|
||||
|
||||
var account = AccountData.GetAccountByUid(accountUid,true);
|
||||
|
||||
if (account == null || account!.ComboToken != request.Data!.Token)
|
||||
{
|
||||
return Ok(new ResponseBase
|
||||
{
|
||||
Retcode = -101,
|
||||
Success = false,
|
||||
Message = "Account token error"
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(new ComboGranterResponse
|
||||
{
|
||||
Data = new ComboGranterResponse.ComboGranterResponseData
|
||||
{
|
||||
AccountType = 1,
|
||||
Data = "{\"guest\": false}",
|
||||
Heartbeat = false,
|
||||
OpenId = account!.Uid.ToString(),
|
||||
ComboToken = account!.ComboToken,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost("/{productName}/combo/granter/api/compareProtocolVersion")]
|
||||
public IActionResult CompareProtocolVersion(string productName)
|
||||
{
|
||||
return Ok(new ResponseBase
|
||||
{
|
||||
Data = new
|
||||
{
|
||||
Modified = false,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet("/{productName}/combo/granter/api/getConfig")]
|
||||
public IActionResult GetConfig()
|
||||
{
|
||||
return Ok(new ResponseBase
|
||||
{
|
||||
Data = new
|
||||
{
|
||||
protocol = true,
|
||||
qr_enabled = false,
|
||||
log_level = "INFO",
|
||||
announce_url =
|
||||
$"{ConfigManager.Config.HttpServer.GetDisplayAddress()}/announcement/index.html",
|
||||
push_alias_type = 2,
|
||||
disable_ysdk_guard = false,
|
||||
enable_announce_popup = false,
|
||||
app_name = "崩坏3-东南亚",
|
||||
qr_enabled_apps = new
|
||||
{
|
||||
bbs = false,
|
||||
cloud = false
|
||||
},
|
||||
qr_app_icons = new
|
||||
{
|
||||
app = "",
|
||||
bbs = "",
|
||||
cloud = "",
|
||||
},
|
||||
qr_cloud_display_name = "",
|
||||
enable_user_center = false,
|
||||
functional_switch_configs = new { }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet("/combo/box/api/config/sdk/combo")]
|
||||
public IActionResult GetComboConfig()
|
||||
{
|
||||
return Ok(new ResponseBase
|
||||
{
|
||||
Data = new
|
||||
{
|
||||
vals = new
|
||||
{
|
||||
network_report_config =
|
||||
"{ \"enable\": 1, \"status_codes\": [206], \"url_paths\": [\"dataUpload\", \"red_dot\"] }",
|
||||
list_price_tierv2_enable = "false",
|
||||
default_os_pay_dialog_type = "old",
|
||||
kibana_pc_config = "{ \"enable\": 1, \"level\": \"Info\",\"modules\": [\"download\"]\n",
|
||||
telemetry_config = "{\n \"dataupload_enable\": 1,\n}",
|
||||
h5log_filter_config =
|
||||
"{\n\t\"function\": {\n\t\t\"event_name\": [\"info_get_cps\", \"notice_close_notice\", \"info_get_uapc\", \"report_set_info\", \"info_get_channel_id\", \"info_get_sub_channel_id\"]\n\t}\n}",
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
57
SdkServer/Handlers/Sdk/DeviceFingerprintController.cs
Normal file
57
SdkServer/Handlers/Sdk/DeviceFingerprintController.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using KianaBH.Data.Models.Sdk;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace KianaBH.SdkServer.Handlers.Sdk;
|
||||
|
||||
[ApiController]
|
||||
public class DeviceFingerprintController : ControllerBase
|
||||
{
|
||||
[HttpPost("/device-fp/api/getFp")]
|
||||
public IActionResult GetDeviceFingerprint([FromBody] GetDeviceFingerprintRequest request)
|
||||
{
|
||||
return Ok(new ResponseBase
|
||||
{
|
||||
Data = new { request.DeviceFp, Code = 0, Msg = "ok" }
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet("/device-fp/api/getExtList")]
|
||||
public IActionResult GetExtList()
|
||||
{
|
||||
var extList = new[]
|
||||
{
|
||||
"cpuName",
|
||||
"deviceModel",
|
||||
"deviceName",
|
||||
"deviceType",
|
||||
"deviceUID",
|
||||
"gpuID",
|
||||
"gpuName",
|
||||
"gpuAPI",
|
||||
"gpuVendor",
|
||||
"gpuVersion",
|
||||
"gpuMemory",
|
||||
"osVersion",
|
||||
"cpuCores",
|
||||
"cpuFrequency",
|
||||
"gpuVendorID",
|
||||
"isGpuMultiTread",
|
||||
"memorySize",
|
||||
"screenSize",
|
||||
"engineName",
|
||||
"addressMAC",
|
||||
"packageVersion"
|
||||
};
|
||||
|
||||
return Ok(new ResponseBase
|
||||
{
|
||||
Data = new
|
||||
{
|
||||
code = 200,
|
||||
msg = "ok",
|
||||
ext_list = extList,
|
||||
pkg_list = Array.Empty<object>()
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
31
SdkServer/Handlers/Sdk/GameWeatherController.cs
Normal file
31
SdkServer/Handlers/Sdk/GameWeatherController.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using KianaBH.Data.Models.Sdk;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace KianaBH.SdkServer.Handlers.Sdk;
|
||||
|
||||
[ApiController]
|
||||
public class GameWeatherController : ControllerBase
|
||||
{
|
||||
[HttpGet("/game_weather/weather/get_weather")]
|
||||
public IActionResult GetWeather()
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var dateString = now.ToString("yyyy-MM-dd");
|
||||
|
||||
return Ok(new GetWeatherResponse
|
||||
{
|
||||
Data = new GetWeatherResponse.GetWeatherResponseData
|
||||
{
|
||||
Timezone = (int)TimeZoneInfo.Local.GetUtcOffset(now).TotalHours,
|
||||
Hourly = Enumerable.Range(1, 24).Select(i =>
|
||||
new GetWeatherResponse.GetWeatherResponseData.HourlyWeatherData
|
||||
{
|
||||
Condition = 3,
|
||||
Date = dateString,
|
||||
Hour = i,
|
||||
Temp = 21
|
||||
}).ToList()
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
36
SdkServer/Handlers/Sdk/LogDataUploadController.cs
Normal file
36
SdkServer/Handlers/Sdk/LogDataUploadController.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace KianaBH.SdkServer.Handlers.Sdk;
|
||||
|
||||
[ApiController]
|
||||
public class LogDataUploadController : ControllerBase
|
||||
{
|
||||
[HttpGet("/report")]
|
||||
public IActionResult Report()
|
||||
{
|
||||
return Ok(new { code = 0, message = "OK" });
|
||||
}
|
||||
|
||||
[HttpPost("/{logType}/dataUpload")]
|
||||
public IActionResult LogDataUpload(string logType)
|
||||
{
|
||||
return Ok(new { code = 0, message = "OK" });
|
||||
}
|
||||
|
||||
[HttpPost("/common/h5log/log/batch")]
|
||||
public IActionResult H5LogBatch()
|
||||
{
|
||||
return Ok(new { code = 0, message = "OK" });
|
||||
}
|
||||
|
||||
[HttpGet("/_ts")]
|
||||
public IActionResult GetTs()
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
code = 0,
|
||||
message = "app running",
|
||||
milliTs = DateTime.Now.Millisecond.ToString()
|
||||
});
|
||||
}
|
||||
}
|
||||
50
SdkServer/Handlers/Sdk/MaPassportController.cs
Normal file
50
SdkServer/Handlers/Sdk/MaPassportController.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
// TODO: Since these stuff requires client patch, we will disable it for now
|
||||
|
||||
// using Microsoft.AspNetCore.Mvc;
|
||||
// using KianaBH.Database.Repositories;
|
||||
// using KianaBH.SdkServer.Models;
|
||||
// using KianaBH.SdkServer.Models.Sdk;
|
||||
//
|
||||
// namespace KianaBH.SdkServer.Handlers.Sdk;
|
||||
//
|
||||
// [ApiController]
|
||||
// public class MaPassportController : ControllerBase
|
||||
// {
|
||||
// [HttpPost("/{productName}/account/ma-passport/api/appLoginByPassword")]
|
||||
// public async Task<IActionResult> AppLoginByPassword(string productName,
|
||||
// [FromBody] AppLoginByPasswordRequest request)
|
||||
// {
|
||||
// var account = AccountRepository.FindAccountByUsername(request.Account);
|
||||
//
|
||||
// // Make new account
|
||||
// if (account == null)
|
||||
// {
|
||||
// var (success, accountUid) = await AccountRepository.CreateAccount(request.Account, request.Password);
|
||||
// if (!success)
|
||||
// {
|
||||
// return Ok(new ResponseBase
|
||||
// {
|
||||
// Retcode = -101,
|
||||
// Message = "Failed to create account"
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// account = AccountRepository.FindAccountByAccountUid(accountUid);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// return Ok(new AppLoginByPasswordResponse
|
||||
// {
|
||||
// Data = new AppLoginByPasswordResponse.AppLoginByPasswordResponseData
|
||||
// {
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// [HttpPost("/{productName}/account/ma-passport/api/logout")]
|
||||
// public IActionResult Logout(string productName, [FromBody] LogoutRequest request)
|
||||
// {
|
||||
// return Ok(new ResponseBase());
|
||||
// }
|
||||
// }
|
||||
|
||||
153
SdkServer/Handlers/Sdk/MdkController.cs
Normal file
153
SdkServer/Handlers/Sdk/MdkController.cs
Normal file
@@ -0,0 +1,153 @@
|
||||
using KianaBH.Data.Models.Sdk;
|
||||
using KianaBH.Database.Account;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace KianaBH.SdkServer.Models.Sdk;
|
||||
|
||||
[ApiController]
|
||||
public class MdkController : Controller
|
||||
{
|
||||
[HttpPost("/{productName}/mdk/shield/api/login")]
|
||||
public async Task<IActionResult> MdkShieldLogin(string productName, [FromBody] MdkShieldLoginRequest request)
|
||||
{
|
||||
var account = AccountData.GetAccountByUserName(request.Account!);
|
||||
|
||||
// Make new account
|
||||
if (account == null)
|
||||
{
|
||||
AccountData.CreateAccount(request.Account!, 0, request.Password!);
|
||||
|
||||
account = AccountData.GetAccountByUserName(request.Account!)!;
|
||||
}
|
||||
|
||||
return Ok(new MdkShieldResponse
|
||||
{
|
||||
Data = new MdkShieldResponse.MdkShieldResponseData
|
||||
{
|
||||
Account = new MdkShieldAccountData
|
||||
{
|
||||
Uid = account.Uid.ToString(),
|
||||
Token = account.GenerateComboToken(),
|
||||
Name = account.Username,
|
||||
Realname = account.Username,
|
||||
IsEmailVerify = "0",
|
||||
Email = $"{account!.Username}@neonteam.dev",
|
||||
AreaCode = "**",
|
||||
Country = "US",
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost("/{productName}/mdk/shield/api/verify")]
|
||||
public async Task<IActionResult> MdkShieldVerify(string productName, [FromBody] MdkShieldVerifyRequest request)
|
||||
{
|
||||
int accountUid;
|
||||
try
|
||||
{
|
||||
accountUid = int.Parse(request.Uid!);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Ok(new ResponseBase
|
||||
{
|
||||
Retcode = -101,
|
||||
Success = false,
|
||||
Message = "Account cache error"
|
||||
});
|
||||
}
|
||||
|
||||
var account = AccountData.GetAccountByUid(accountUid,true);
|
||||
|
||||
if (account == null)
|
||||
{
|
||||
return Ok(new ResponseBase
|
||||
{
|
||||
Retcode = -101,
|
||||
Success = false,
|
||||
Message = "Account cache error"
|
||||
});
|
||||
}
|
||||
|
||||
if (account.ComboToken != request.Token)
|
||||
{
|
||||
return Ok(new ResponseBase
|
||||
{
|
||||
Retcode = -101,
|
||||
Success = false,
|
||||
Message = "For account safety, please log in again"
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(new MdkShieldResponse
|
||||
{
|
||||
Data = new MdkShieldResponse.MdkShieldResponseData
|
||||
{
|
||||
Account = new MdkShieldAccountData
|
||||
{
|
||||
Uid = account.Uid.ToString(),
|
||||
Token = account.ComboToken!,
|
||||
Name = account.Username,
|
||||
Realname = account.Username,
|
||||
IsEmailVerify = "0",
|
||||
Email = $"{account!.Username}@neonteam.dev",
|
||||
AreaCode = "**",
|
||||
Country = "US",
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet("/{productName}/mdk/agreement/api/getAgreementInfos")]
|
||||
public IActionResult MdkGetAgreementInfos(string productName)
|
||||
{
|
||||
return Ok(new ResponseBase
|
||||
{
|
||||
Data = new { marketing_agreements = Array.Empty<object>() }
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet("/{productName}/mdk/shield/api/loadConfig")]
|
||||
public IActionResult MdkLoadConfig(string productName)
|
||||
{
|
||||
return Ok(new ResponseBase
|
||||
{
|
||||
Data = new
|
||||
{
|
||||
id = 16,
|
||||
game_key = productName,
|
||||
client = "PC",
|
||||
identity = "I_IDENTITY",
|
||||
guest = false,
|
||||
ignore_versions = "",
|
||||
scene = "S_NORMAL",
|
||||
name = "崩坏3rd-东南亚",
|
||||
disable_regist = false,
|
||||
enable_email_captcha = false,
|
||||
thirdparty = Array.Empty<string>(),
|
||||
disable_mmt = false,
|
||||
server_guest = false,
|
||||
thirdparty_ignore = new { },
|
||||
enable_ps_bind_account = false,
|
||||
thirdparty_login_configs = new { },
|
||||
initialize_firebase = false,
|
||||
bbs_auth_login = false,
|
||||
bbs_auth_login_ignore = Array.Empty<string>(),
|
||||
fetch_instance_id = false,
|
||||
enable_flash_login = false,
|
||||
enable_logo_18 = false,
|
||||
logo_height = "0",
|
||||
logo_width = "0",
|
||||
enable_cx_bind_account = false,
|
||||
firebase_blacklist_devices_switch = false,
|
||||
firebase_blacklist_devices_version = 0,
|
||||
hoyolab_auth_login = false,
|
||||
hoyolab_auth_login_ignore = Array.Empty<string>(),
|
||||
hoyoplay_auth_login = true,
|
||||
enable_douyin_flash_login = false,
|
||||
enable_age_gate = false,
|
||||
enable_age_gate_ignore = Array.Empty<string>()
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
14
SdkServer/Handlers/Sdk/RiskyController.cs
Normal file
14
SdkServer/Handlers/Sdk/RiskyController.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using KianaBH.Data.Models.Sdk;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace KianaBH.SdkServer.Models.Sdk;
|
||||
|
||||
[ApiController]
|
||||
public class RiskyController : ControllerBase
|
||||
{
|
||||
[HttpPost("/account/risky/api/check")]
|
||||
public IActionResult ComboGranter()
|
||||
{
|
||||
return Ok(new ResponseBase { Data = new { } });
|
||||
}
|
||||
}
|
||||
53
SdkServer/SdkServer.cs
Normal file
53
SdkServer/SdkServer.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using KianaBH.SdkServer.Utils;
|
||||
using KianaBH.Util;
|
||||
using Microsoft.AspNetCore;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace KianaBH.SdkServer;
|
||||
|
||||
public class SdkServer
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
BuildWebHost(args).Start();
|
||||
}
|
||||
|
||||
private static IWebHost BuildWebHost(string[] args)
|
||||
{
|
||||
var builder = WebHost.CreateDefaultBuilder(args)
|
||||
.UseStartup<Startup>()
|
||||
.ConfigureLogging((_, logging) => { logging.ClearProviders(); })
|
||||
.UseUrls(ConfigManager.Config.HttpServer.GetBindDisplayAddress());
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
}
|
||||
|
||||
public class Startup
|
||||
{
|
||||
public static void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment()) app.UseDeveloperExceptionPage();
|
||||
|
||||
app.UseRouting();
|
||||
app.UseCors("AllowAll");
|
||||
app.UseAuthorization();
|
||||
app.UseMiddleware<RequestLoggingMiddleware>();
|
||||
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
|
||||
}
|
||||
|
||||
public static void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("AllowAll",
|
||||
builder => { builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader(); });
|
||||
});
|
||||
services.AddControllers()
|
||||
.AddJsonOptions(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower;
|
||||
});
|
||||
services.AddSingleton<Logger>(_ => new Logger("HttpServer"));
|
||||
}
|
||||
}
|
||||
32
SdkServer/SdkServer.csproj
Normal file
32
SdkServer/SdkServer.csproj
Normal file
@@ -0,0 +1,32 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<CETCompat>false</CETCompat>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>KianaBH.SdkServer</RootNamespace>
|
||||
<OutputType>Library</OutputType>
|
||||
<AssemblyName>KianaSdkServer</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.29.2" />
|
||||
<PackageReference Include="Google.Protobuf.Tools" Version="3.29.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
|
||||
<PackageReference Include="Spectre.Console" Version="0.49.1" />
|
||||
<PackageReference Include="SQLitePCLRaw.core" Version="2.1.10" />
|
||||
<PackageReference Include="SQLitePCLRaw.provider.e_sqlite3" Version="2.1.10" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.172" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
|
||||
<PackageReference Include="System.Management" Version="9.0.0" />
|
||||
<ProjectReference Include="..\Common\Common.csproj" />
|
||||
<ProjectReference Include="..\GameServer\GameServer.csproj" />
|
||||
<ProjectReference Include="..\Proto\Proto.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Handlers\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user