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"": ""夏萝莉是小楠梁""
}
");
}
}
}

View File

@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DotNetZip" Version="1.16.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Novaria.Common\Novaria.Common.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,14 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"externalUrlConfiguration": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,45 @@
using System.Reflection;
using System.Security.Cryptography;
using Google.Protobuf;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Pb;
using Serilog;
namespace Novaria.SDKServer
{
public class SDKServer
{
public static void Main(string[] args)
{
Log.Information("Starting SDK Server...");
try
{
var builder = WebApplication.CreateBuilder(args);
builder.Services.Configure<KestrelServerOptions>(op =>
op.AllowSynchronousIO = true
);
builder.Host.UseSerilog();
builder.Services.AddControllers();
builder.Services.AddControllers().AddApplicationPart(Assembly.GetAssembly(typeof(SDKServer)));
var app = builder.Build();
app.UseAuthorization();
app.UseSerilogRequestLogging();
app.MapControllers();
app.Run();
}
catch (Exception ex)
{
Log.Fatal(ex, "An unhandled exception occurred during runtime");
}
finally
{
Log.CloseAndFlush();
}
}
}
}

View File

@@ -0,0 +1,23 @@
{
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "https://0.0.0.0:443"
},
"Https": {
"Url": "https://0.0.0.0:80"
}
}
},
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
},
"AllowedHosts": "*"
}

View File

@@ -0,0 +1 @@
<EFBFBD>\=H<>Y@2=2<>;<3B>cH<63><48>&9<>S<EFBFBD><53><EFBFBD>B<EFBFBD>o<EFBFBD>{g<><67>8<EFBFBD>3<EFBFBD><33>R<<0F><>N<EFBFBD><0F><>/<1E><>_<EFBFBD><5F><EFBFBD>

View File

@@ -0,0 +1,14 @@
{
"version": "37",
"agent": [
{
"name": "启明测试",
"addr": "https://nova.yostar.cn/agent-zone-1/",
"status": 1,
"zone": "1"
}
],
"status": 1,
"message": "测试尚未开始预计开服时间1月9日11:00",
"reportEndpoint": "https://nova.yostar.cn/report/"
}