mirror of
https://github.com/EggLinks/DanhengServer-OpenSource.git
synced 2026-01-02 20:26:03 +08:00
feat: gateserver & dispatch server isolation
This commit is contained in:
@@ -14,20 +14,37 @@ namespace EggLink.DanhengServer.WebServer.Controllers;
|
||||
[Route("/")]
|
||||
public class DispatchRoutes
|
||||
{
|
||||
public static ConfigContainer config = ConfigManager.Config;
|
||||
public static ConfigContainer Config = ConfigManager.Config;
|
||||
public static Logger Logger = new("DispatchServer");
|
||||
|
||||
[HttpGet("query_dispatch")]
|
||||
public string QueryDispatch()
|
||||
{
|
||||
if (!Config.ServerOption.ServerConfig.RunDispatch)
|
||||
return "";
|
||||
|
||||
var data = new Dispatch();
|
||||
data.RegionList.Add(new RegionInfo
|
||||
|
||||
if (Config.ServerOption.ServerConfig.RunGateway)
|
||||
data.RegionList.Add(new RegionInfo
|
||||
{
|
||||
Name = Config.GameServer.GameServerId,
|
||||
DispatchUrl = $"{Config.HttpServer.GetDisplayAddress()}/query_gateway",
|
||||
EnvType = "21",
|
||||
DisplayName = Config.GameServer.GameServerName
|
||||
});
|
||||
|
||||
foreach (var region in Config.ServerOption.ServerConfig.Regions)
|
||||
{
|
||||
Name = config.GameServer.GameServerId,
|
||||
DispatchUrl = $"{config.HttpServer.GetDisplayAddress()}/query_gateway",
|
||||
EnvType = "21",
|
||||
DisplayName = config.GameServer.GameServerName
|
||||
});
|
||||
data.RegionList.Add(new RegionInfo
|
||||
{
|
||||
Name = region.GameServerId,
|
||||
DisplayName = region.GameServerName,
|
||||
EnvType = region.EnvType.ToString(),
|
||||
DispatchUrl = region.GateWayAddress,
|
||||
});
|
||||
}
|
||||
|
||||
Logger.Info("Client request: query_dispatch");
|
||||
return Convert.ToBase64String(data.ToByteArray());
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using EggLink.DanhengServer.WebServer.Handler;
|
||||
using EggLink.DanhengServer.Util;
|
||||
using EggLink.DanhengServer.WebServer.Handler;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EggLink.DanhengServer.WebServer.Controllers;
|
||||
@@ -8,9 +9,20 @@ namespace EggLink.DanhengServer.WebServer.Controllers;
|
||||
public class GateServerRoutes
|
||||
{
|
||||
[HttpGet("/query_gateway")]
|
||||
public async ValueTask<string> QueryGateway([FromQuery] string version)
|
||||
public async ValueTask<ContentResult> QueryGateway([FromQuery] string version)
|
||||
{
|
||||
if (!ConfigManager.Config.ServerOption.ServerConfig.RunGateway)
|
||||
return new ContentResult
|
||||
{
|
||||
StatusCode = 404
|
||||
};
|
||||
|
||||
await ValueTask.CompletedTask;
|
||||
return new QueryGatewayHandler(version).Data;
|
||||
return new ContentResult
|
||||
{
|
||||
Content = new QueryGatewayHandler(version).Data,
|
||||
StatusCode = 200,
|
||||
ContentType = "plain/text; charset=utf-8"
|
||||
};
|
||||
}
|
||||
}
|
||||
44
WebServer/Controllers/ServerExchangeRoutes.cs
Normal file
44
WebServer/Controllers/ServerExchangeRoutes.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using EggLink.DanhengServer.Database;
|
||||
using EggLink.DanhengServer.Database.Account;
|
||||
using EggLink.DanhengServer.Util;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EggLink.DanhengServer.WebServer.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("/")]
|
||||
public class ServerExchangeRoutes
|
||||
{
|
||||
[HttpGet("/get_account_info")]
|
||||
public async ValueTask<ContentResult> GetAccountInfo([FromQuery] string accountUid)
|
||||
{
|
||||
if (!ConfigManager.Config.ServerOption.ServerConfig.RunDispatch)
|
||||
return new ContentResult
|
||||
{
|
||||
StatusCode = 404
|
||||
};
|
||||
|
||||
if (string.IsNullOrEmpty(accountUid) || !int.TryParse(accountUid, out var uid))
|
||||
return new ContentResult
|
||||
{
|
||||
StatusCode = 400
|
||||
};
|
||||
|
||||
var account = DatabaseHelper.Instance?.GetInstance<AccountData>(uid);
|
||||
if (account == null)
|
||||
return new ContentResult
|
||||
{
|
||||
StatusCode = 404,
|
||||
Content = "Account not found"
|
||||
};
|
||||
|
||||
await ValueTask.CompletedTask;
|
||||
|
||||
return new ContentResult
|
||||
{
|
||||
Content = account.Uid.ToString(),
|
||||
StatusCode = 200,
|
||||
ContentType = "plain/text; charset=utf-8"
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ internal partial class QueryGatewayHandler
|
||||
RegionName = config.GameServer.GameServerId,
|
||||
Ip = config.GameServer.PublicAddress,
|
||||
Port = config.GameServer.Port,
|
||||
LoginWhiteMsg = I18NManager.Translate("Server.Web.Maintain"),
|
||||
Msg = I18NManager.Translate("Server.Web.Maintain"),
|
||||
EnableVersionUpdate = true,
|
||||
EnableUploadBattleLog = true,
|
||||
EnableDesignDataVersionUpdate = true,
|
||||
|
||||
Reference in New Issue
Block a user