feat: gateserver & dispatch server isolation

This commit is contained in:
StopWuyu
2025-08-17 15:54:30 +08:00
parent b5dac65fec
commit dad9efe7a9
8 changed files with 205 additions and 64 deletions

View File

@@ -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());
}

View File

@@ -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"
};
}
}

View 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"
};
}
}

View File

@@ -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,