mirror of
https://github.com/raphaeIl/Novaria.git
synced 2025-12-14 15:34:37 +01:00
serverlist handler + basic crypto, rename project
This commit is contained in:
58
Novaria.SDKServer/Controllers/MetaController.cs
Normal file
58
Novaria.SDKServer/Controllers/MetaController.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
23
Novaria.SDKServer/Controllers/SDKController.cs
Normal file
23
Novaria.SDKServer/Controllers/SDKController.cs
Normal 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"": ""夏萝莉是小楠梁""
|
||||
}
|
||||
");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user