serverlist handler + basic crypto, rename project

This commit is contained in:
raphaeIl
2025-01-08 23:19:50 -05:00
parent f855950370
commit 55c3fc1fec
563 changed files with 278 additions and 206 deletions

View File

@@ -0,0 +1,58 @@
using Google.Protobuf;
using Microsoft.AspNetCore.Mvc;
using Novaria.Common.Crypto;
using Novaria.Common.Utils;
using Pb;
using Serilog;
namespace Novaria.SDKServer.CoNovariaollers
{
[ApiController]
[Route("/meta")]
public class MetaController : ControllerBase
{
[Route("serverlist.html")]
public IActionResult GetServerlist()
{
ServerListMeta serverListMeta = new ServerListMeta()
{
Version = 37,
Status = 0,
Message = "测试尚未开始预计开服时间1月9日11:00",
ReportEndpoint = "https://nova.yostar.cn/report/",
};
serverListMeta.Agent.Add(new ServerAgent()
{
Name = "启明测试",
Addr = "https://nova.yostar.cn/agent-zone-1/",
Status = 0,
Zone = 1,
});
// seems like IV is sent as the first 16 bytes, and key is hardcoded in client
// response = [IV, protobuf_serialized_data]
byte[] encrypted_content = AeadTool.EncryptAesCBCInfo(AeadTool.DEFAULT_SERVERLIST_KEY, AeadTool.DEFAULT_SERVERLIST_IV, serverListMeta.ToByteArray());
byte[] response = Utils.CombineByteArrays(AeadTool.DEFAULT_SERVERLIST_IV, encrypted_content);
Log.Information("Response bytes:");
return File(response, "text/html");
}
[HttpGet("{*catchAll}")]
public IResult CatchAllGet(string catchAll)
{
Log.Information($"HttpGet: {catchAll}");
return Results.Empty;
}
[HttpPost("{*catchAll}")]
public IResult CatchAllPost(string catchAll)
{
Log.Information($"HttpGet: {catchAll}");
return Results.Empty;
}
}
}

View File

@@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Mvc;
using Serilog;
namespace Novaria.SDKServer.CoNovariaollers
{
[ApiController]
[Route("/user")]
public class SDKController : ControllerBase
{
[Route("login")]
public IResult PostLogin()
{
Log.Information("post login received!");
return Results.Text(@"
{
""Code"": 200,
""Data"": {},
""Msg"": ""夏萝莉是小楠梁""
}
");
}
}
}