HTTP part passed

This commit is contained in:
xeon 2024-01-18 19:18:25 +03:00
parent be16275e23
commit 7f9dbbc53d
24 changed files with 2766 additions and 0 deletions

View file

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<None Remove="Messages.proto" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.25.2" />
<PackageReference Include="Grpc.Tools" Version="2.60.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Protobuf Include="messages.proto" GrpcServices="None" />
</ItemGroup>
</Project>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,23 @@
syntax = "proto3";
option csharp_namespace = "RPG.Network.Proto";
enum RPGServiceType
{
SERVICE_TYPE_NONE = 0;
SERVICE_TYPE_SDK = 1;
SERVICE_TYPE_GATESERVER = 2;
SERVICE_TYPE_GAMESERVER = 3;
}
message ActionMetadata
{
RPGServiceType sender_type = 1;
uint64 session_id = 2;
uint32 player_uid = 3;
}
message ForwardGameMessageNotify
{
uint32 cmd_type = 1;
bytes payload = 2;
}

View file

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RPG.GameCore\RPG.GameCore.csproj" />
<ProjectReference Include="..\RPG.Network.Proto\RPG.Network.Proto.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,15 @@
using Microsoft.Extensions.Hosting;
namespace RPG.Services.Core;
public abstract class RPGServiceBase : IHostedService
{
public virtual Task StartAsync(CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
public virtual Task StopAsync(CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}

View file

@ -0,0 +1,9 @@
namespace RPG.Services.Gameserver;
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}

View file

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,9 @@
namespace RPG.Services.Gateserver;
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}

View file

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,59 @@
using Microsoft.AspNetCore.Http.HttpResults;
using RPG.Services.SDK.Models.Auth;
namespace RPG.Services.SDK.Handlers;
public static class AuthHandler
{
public static JsonHttpResult<MdkLoginRsp> LoginWithPassword(string productName)
{
_ = productName;
return TypedResults.Json(new MdkLoginRsp
{
Retcode = 0,
Message = "OK",
Data = new MdkLoginRsp.LoginData
{
Account = new MdkLoginRsp.MdkAccount
{
Name = "Snowflake Player",
Token = "mostsecuretokenever",
Uid = "1337"
}
}
});
}
public static JsonHttpResult<GranterVerificationRsp> OnGranterVerification(string productName)
{
_ = productName;
return TypedResults.Json(new GranterVerificationRsp
{
Retcode = 0,
Message = "OK",
Data = new GranterVerificationRsp.GranterData
{
ComboId = 1,
OpenId = 1337,
ComboToken = "mostsecuretokenever",
AccountType = 1
}
});
}
public static JsonHttpResult<RiskyApiCheckRsp> OnRiskyApiCheck()
{
return TypedResults.Json(new RiskyApiCheckRsp
{
Retcode = 0,
Message = "OK",
Data = new RiskyApiCheckRsp.Info
{
Id = "06611ed14c3131a676b19c0d34c0644b",
Action = "ACTION_NONE"
}
});
}
}

View file

@ -0,0 +1,52 @@
using Microsoft.AspNetCore.Http.HttpResults;
using RPG.Services.SDK.Models;
using RPG.Services.SDK.Models.Region;
namespace RPG.Services.SDK.Handlers;
public static class DispatchHandler
{
private const string QueryGatewayUrl = "http://127.0.0.1:8888/query_gateway";
public static JsonHttpResult<QueryDispatchHttpRsp> OnQueryDispatch()
{
return TypedResults.Json(new QueryDispatchHttpRsp
{
Retcode = 0,
TopServerRegionName = "Snowflake",
RegionList =
[
new RegionInfo
{
EnvType = "2",
DispatchUrl = QueryGatewayUrl,
Name = "Snowflake",
Title = "Snowflake"
}
]
});
}
public static JsonHttpResult<QueryGatewayHttpRsp> OnQueryGateway()
{
return TypedResults.Json(new QueryGatewayHttpRsp
{
Retcode = 0,
Message = "OK",
AsbRelogin = 1,
RegionName = "Snowflake",
Gateway = new GatewayInfo
{
Ip = "127.0.0.1",
Port = 20301
},
Ext = new ExtAssetInfo
{
UpdateStreamingAsb = "0",
DataUseAssetBundle = "0",
ForbidRecharge = "0",
ResUseAssetBundle = "0"
}
});
}
}

View file

@ -0,0 +1,42 @@
using System.Text.Json.Serialization;
namespace RPG.Services.SDK.Models.Auth;
public record GranterVerificationRsp
{
[JsonPropertyName("retcode")]
public required int Retcode { get; init; }
[JsonPropertyName("message")]
public required string Message { get; init; }
[JsonPropertyName("data")]
public GranterData? Data { get; init; }
public record GranterData
{
[JsonPropertyName("combo_id")]
public required int ComboId { get; init; }
[JsonPropertyName("open_id")]
public required int OpenId { get; init; }
[JsonPropertyName("combo_token")]
public required string ComboToken { get; init; }
[JsonPropertyName("heartbeat")]
public bool Heartbeat { get; init; }
[JsonPropertyName("account_type")]
public required int AccountType { get; init; }
[JsonPropertyName("data")]
public GuestLoginData Data { get; } = new();
}
public record GuestLoginData
{
[JsonPropertyName("guest")]
public bool Guest { get; init; }
}
}

View file

@ -0,0 +1,33 @@
using System.Text.Json.Serialization;
namespace RPG.Services.SDK.Models.Auth;
public record MdkLoginRsp
{
[JsonPropertyName("retcode")]
public required int Retcode { get; init; }
[JsonPropertyName("message")]
public required string Message { get; init; }
[JsonPropertyName("data")]
public required LoginData Data { get; init; }
public record MdkAccount
{
[JsonPropertyName("name")]
public required string Name { get; init; }
[JsonPropertyName("token")]
public required string Token { get; init; }
[JsonPropertyName("uid")]
public required string Uid { get; init; }
}
public record LoginData
{
[JsonPropertyName("account")]
public MdkAccount? Account { get; init; }
}
}

View file

@ -0,0 +1,24 @@
using System.Text.Json.Serialization;
namespace RPG.Services.SDK.Models.Auth;
public record RiskyApiCheckRsp
{
[JsonPropertyName("retcode")]
public required int Retcode { get; init; }
[JsonPropertyName("message")]
public required string Message { get; init; }
[JsonPropertyName("data")]
public required Info Data { get; init; }
public record Info
{
[JsonPropertyName("id")]
public required string Id { get; init; }
[JsonPropertyName("action")]
public required string Action { get; init; }
}
}

View file

@ -0,0 +1,18 @@
using System.Text.Json.Serialization;
namespace RPG.Services.SDK.Models.Region;
public record ExtAssetInfo
{
[JsonPropertyName("data_use_asset_bundle")]
public required string DataUseAssetBundle { get; set; }
[JsonPropertyName("forbid_recharge")]
public required string ForbidRecharge { get; set; }
[JsonPropertyName("res_use_asset_bundle")]
public required string ResUseAssetBundle { get; set; }
[JsonPropertyName("update_streaming_asb")]
public required string UpdateStreamingAsb { get; set; }
}

View file

@ -0,0 +1,12 @@
using System.Text.Json.Serialization;
namespace RPG.Services.SDK.Models.Region;
public record GatewayInfo
{
[JsonPropertyName("ip")]
public required string Ip { get; set; }
[JsonPropertyName("port")]
public required int Port { get; set; }
}

View file

@ -0,0 +1,15 @@
using System.Text.Json.Serialization;
namespace RPG.Services.SDK.Models.Region;
public record QueryDispatchHttpRsp
{
[JsonPropertyName("retcode")]
public int Retcode { get; set; }
[JsonPropertyName("region_list")]
public List<RegionInfo> RegionList { get; set; } = [];
[JsonPropertyName("top_server_region_name")]
public required string TopServerRegionName { get; set; }
}

View file

@ -0,0 +1,48 @@
using System.Text.Json.Serialization;
namespace RPG.Services.SDK.Models.Region;
public record QueryGatewayHttpRsp
{
[JsonPropertyName("asb_memo")]
public string AsbMemo { get; set; } = string.Empty;
[JsonPropertyName("asb_relogin")]
public int AsbRelogin { get; set; }
[JsonPropertyName("asset_bundle_url")]
public string AssetBundleUrl { get; set; } = string.Empty;
[JsonPropertyName("client_secret_key")]
public string ClientSecretKey { get; set; } = string.Empty;
[JsonPropertyName("design_data_memo")]
public string DesignDataMemo { get; set; } = string.Empty;
[JsonPropertyName("ex_resource_url")]
public string ExResourceUrl { get; set; } = string.Empty;
[JsonPropertyName("ext")]
public required ExtAssetInfo Ext { get; set; }
[JsonPropertyName("gateway")]
public required GatewayInfo Gateway { get; set; }
[JsonPropertyName("lua_url")]
public string LuaUrl { get; set; } = string.Empty;
[JsonPropertyName("region_name")]
public required string RegionName { get; set; }
[JsonPropertyName("retcode")]
public required int Retcode { get; set; }
[JsonPropertyName("message")]
public required string Message { get; set; }
[JsonPropertyName("stopBeginTime")]
public int StopBeginTime { get; set; }
[JsonPropertyName("stopEndTime")]
public int StopEndTime { get; set; }
}

View file

@ -0,0 +1,18 @@
using System.Text.Json.Serialization;
namespace RPG.Services.SDK.Models.Region;
public record RegionInfo
{
[JsonPropertyName("env_type")]
public required string EnvType { get; set; }
[JsonPropertyName("dispatch_url")]
public required string DispatchUrl { get; set; }
[JsonPropertyName("name")]
public required string Name { get; set; }
[JsonPropertyName("title")]
public required string Title { get; set; }
}

View file

@ -0,0 +1,25 @@
using RPG.Services.SDK.Handlers;
namespace RPG.Services.SDK;
internal static class Program
{
private static async Task Main(string[] args)
{
Console.Title = "Snowflake | SDK";
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseUrls("http://*:8888");
WebApplication app = builder.Build();
app.MapGet("/query_dispatch", DispatchHandler.OnQueryDispatch);
app.MapGet("/query_gateway", DispatchHandler.OnQueryGateway);
app.MapPost("/account/risky/api/check", AuthHandler.OnRiskyApiCheck);
app.MapPost("/{productName}/mdk/shield/api/login", AuthHandler.LoginWithPassword);
app.MapPost("/{productName}/combo/granter/login/v2/login", AuthHandler.OnGranterVerification);
await app.RunAsync();
}
}

View file

@ -0,0 +1,12 @@
{
"profiles": {
"RPG.Services.SDK": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:52654;http://localhost:52655"
}
}
}

View file

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

67
Snowflake.sln Normal file
View file

@ -0,0 +1,67 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RPG.Network.Proto", "RPG.Network.Proto\RPG.Network.Proto.csproj", "{7DA70126-3F73-407B-A024-5856F354FA97}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RPG.GameCore", "RPG.GameCore\RPG.GameCore.csproj", "{74042D70-7EA0-4348-9BDB-D1E5D0FC868A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Framework", "Framework", "{0FF9D567-C413-43F0-9EDF-09D4D36154B7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{F199706E-4A92-4A2F-BDDD-25DA4691D43E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RPG.Services.SDK", "RPG.Services.SDK\RPG.Services.SDK.csproj", "{855DA130-974F-4CE8-8DB5-2BD59DC2C3AA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RPG.Services.Gateserver", "RPG.Services.Gateserver\RPG.Services.Gateserver.csproj", "{EB7A2038-E2AF-4565-944C-D850D6AEAEED}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RPG.Services.Gameserver", "RPG.Services.Gameserver\RPG.Services.Gameserver.csproj", "{565F9857-3E97-4363-9A5D-05CED8718116}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RPG.Services.Core", "RPG.Services.Core\RPG.Services.Core.csproj", "{1B434662-DEC9-40C9-A709-CE87026191D9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7DA70126-3F73-407B-A024-5856F354FA97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7DA70126-3F73-407B-A024-5856F354FA97}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7DA70126-3F73-407B-A024-5856F354FA97}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7DA70126-3F73-407B-A024-5856F354FA97}.Release|Any CPU.Build.0 = Release|Any CPU
{74042D70-7EA0-4348-9BDB-D1E5D0FC868A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74042D70-7EA0-4348-9BDB-D1E5D0FC868A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74042D70-7EA0-4348-9BDB-D1E5D0FC868A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74042D70-7EA0-4348-9BDB-D1E5D0FC868A}.Release|Any CPU.Build.0 = Release|Any CPU
{855DA130-974F-4CE8-8DB5-2BD59DC2C3AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{855DA130-974F-4CE8-8DB5-2BD59DC2C3AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{855DA130-974F-4CE8-8DB5-2BD59DC2C3AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{855DA130-974F-4CE8-8DB5-2BD59DC2C3AA}.Release|Any CPU.Build.0 = Release|Any CPU
{EB7A2038-E2AF-4565-944C-D850D6AEAEED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EB7A2038-E2AF-4565-944C-D850D6AEAEED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB7A2038-E2AF-4565-944C-D850D6AEAEED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB7A2038-E2AF-4565-944C-D850D6AEAEED}.Release|Any CPU.Build.0 = Release|Any CPU
{565F9857-3E97-4363-9A5D-05CED8718116}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{565F9857-3E97-4363-9A5D-05CED8718116}.Debug|Any CPU.Build.0 = Debug|Any CPU
{565F9857-3E97-4363-9A5D-05CED8718116}.Release|Any CPU.ActiveCfg = Release|Any CPU
{565F9857-3E97-4363-9A5D-05CED8718116}.Release|Any CPU.Build.0 = Release|Any CPU
{1B434662-DEC9-40C9-A709-CE87026191D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B434662-DEC9-40C9-A709-CE87026191D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B434662-DEC9-40C9-A709-CE87026191D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B434662-DEC9-40C9-A709-CE87026191D9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{7DA70126-3F73-407B-A024-5856F354FA97} = {0FF9D567-C413-43F0-9EDF-09D4D36154B7}
{74042D70-7EA0-4348-9BDB-D1E5D0FC868A} = {0FF9D567-C413-43F0-9EDF-09D4D36154B7}
{855DA130-974F-4CE8-8DB5-2BD59DC2C3AA} = {F199706E-4A92-4A2F-BDDD-25DA4691D43E}
{EB7A2038-E2AF-4565-944C-D850D6AEAEED} = {F199706E-4A92-4A2F-BDDD-25DA4691D43E}
{565F9857-3E97-4363-9A5D-05CED8718116} = {F199706E-4A92-4A2F-BDDD-25DA4691D43E}
{1B434662-DEC9-40C9-A709-CE87026191D9} = {0FF9D567-C413-43F0-9EDF-09D4D36154B7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9B5CE103-882A-419D-8FA3-89C8642687F6}
EndGlobalSection
EndGlobal