forked from LagrangeDev/Lagrange.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Kritor] Intrudoce Kritor (LagrangeDev#270)
* [Kritor] Introduce Lagrange.Kritor * [Kritor] Setup structure
- Loading branch information
Linwenxuan
authored
Apr 1, 2024
1 parent
44477b9
commit 4257484
Showing
38 changed files
with
1,817 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Protobuf Include="Protos\auth\*" GrpcServices="Server"/> | ||
<Protobuf Include="Protos\common\*" GrpcServices="Server"/> | ||
<Protobuf Include="Protos\core\*" GrpcServices="Server"/> | ||
<Protobuf Include="Protos\customization\*" GrpcServices="Server"/> | ||
<Protobuf Include="Protos\developer\*" GrpcServices="Server"/> | ||
<Protobuf Include="Protos\event\*" GrpcServices="Server"/> | ||
<Protobuf Include="Protos\file\*" GrpcServices="Server"/> | ||
<Protobuf Include="Protos\friend\*" GrpcServices="Server"/> | ||
<Protobuf Include="Protos\group\*" GrpcServices="Server"/> | ||
<Protobuf Include="Protos\guild\*" GrpcServices="Server"/> | ||
<Protobuf Include="Protos\message\*" GrpcServices="Server"/> | ||
<Protobuf Include="Protos\reverse\*" GrpcServices="Server"/> | ||
<Protobuf Include="Protos\web\*" GrpcServices="Server"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Grpc.AspNetCore" Version="2.57.0"/> | ||
<PackageReference Include="LiteDB" Version="5.0.17" /> | ||
<PackageReference Include="Net.Codecrete.QrCodeGenerator" Version="1.6.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Core\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
namespace Lagrange.Kritor; | ||
|
||
public class LagrangeApp : IHost | ||
{ | ||
private readonly IHost _hostApp; | ||
|
||
public IServiceProvider Services => _hostApp.Services; | ||
|
||
public ILogger<LagrangeApp> Logger { get; } | ||
|
||
internal LagrangeApp(IHost host) | ||
{ | ||
_hostApp = host; | ||
Logger = Services.GetRequiredService<ILogger<LagrangeApp>>(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public async Task StartAsync(CancellationToken cancellationToken = new CancellationToken()) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public async Task StopAsync(CancellationToken cancellationToken = new CancellationToken()) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Lagrange.Kritor; | ||
|
||
public sealed class LagrangeAppBuilder | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace Lagrange.Kritor; | ||
|
||
internal static class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
builder.Services.AddGrpc(); | ||
|
||
var app = builder.Build(); | ||
|
||
app.MapGet("/", () => "Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909"); | ||
|
||
app.Run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": false, | ||
"applicationUrl": "http://localhost:5211", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": false, | ||
"applicationUrl": "https://localhost:7233;http://localhost:5211", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
syntax = "proto3"; | ||
|
||
package kritor.authentication; | ||
|
||
option csharp_namespace = "Kritor.Authentication"; | ||
option java_multiple_files = true; | ||
option java_package = "io.kritor.authentication"; | ||
option go_package = "grpc/kritor/authentication"; | ||
|
||
service AuthenticationService { | ||
rpc Authenticate(AuthenticateRequest) returns (AuthenticateResponse); | ||
rpc GetAuthenticationState(GetAuthenticationStateRequest) returns (GetAuthenticationStateResponse); | ||
|
||
rpc GetTicket(GetTicketRequest) returns (GetTicketResponse); | ||
rpc AddTicket(AddTicketRequest) returns (AddTicketResponse); | ||
rpc DeleteTicket(DeleteTicketRequest) returns (DeleteTicketResponse); | ||
} | ||
|
||
/* | ||
在某个账号授权成功之后,接下来所有的请求都必须围绕该账号,且禁止再次发送授权包。 | ||
*/ | ||
message AuthenticateRequest { | ||
string account = 1; // 客户端连接认证账号 | ||
string ticket = 2; // 客户端连接认证ticket | ||
} | ||
|
||
message AuthenticateResponse { | ||
enum AuthenticateResponseCode { | ||
OK = 0; | ||
NO_ACCOUNT = 1; | ||
NO_TICKET = 2; | ||
LOGIC_ERROR = 3; | ||
} | ||
|
||
AuthenticateResponseCode code = 1; // 认证结果 | ||
string msg = 2; // 错误信息 | ||
} | ||
|
||
message GetAuthenticationStateRequest { | ||
string account = 1; // 客户端连接认证账号 | ||
} | ||
|
||
message GetAuthenticationStateResponse { | ||
bool is_required = 1; // 是否需要认证 | ||
} | ||
|
||
|
||
/* 所有对认证ticket增删查都需要使用super ticket */ | ||
|
||
enum TicketOperationResponseCode { | ||
OK = 0; | ||
ERROR = 1; | ||
} | ||
|
||
message GetTicketRequest { | ||
string account = 1; // 客户端连接认证账号 | ||
string super_ticket = 2; // 客户端连接认证super ticket | ||
} | ||
|
||
message GetTicketResponse { | ||
TicketOperationResponseCode code = 1; | ||
string msg = 2; | ||
repeated string tickets = 3; // 返回的客户端ticket,非super ticket | ||
} | ||
|
||
message AddTicketRequest { | ||
string account = 1; // 客户端连接认证账号 | ||
string super_ticket = 2; // 客户端连接认证super ticket | ||
string ticket = 3; | ||
} | ||
|
||
message AddTicketResponse { | ||
TicketOperationResponseCode code = 1; | ||
string msg = 2; | ||
} | ||
|
||
message DeleteTicketRequest { | ||
string account = 1; // 客户端连接认证账号 | ||
string super_ticket = 2; // 客户端连接认证super ticket | ||
string ticket = 3; | ||
} | ||
|
||
message DeleteTicketResponse { | ||
TicketOperationResponseCode code = 1; | ||
string msg = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
syntax = "proto3"; | ||
|
||
package kritor.common; | ||
|
||
option csharp_namespace = "Kritor.Common"; | ||
option java_multiple_files = true; | ||
option java_package = "io.kritor.common"; | ||
option go_package = "grpc/kritor/common"; | ||
|
||
enum Scene { | ||
GROUP = 0; // 群聊 | ||
FRIEND = 1; // 私聊 | ||
GUILD = 2; // 频道 | ||
STRANGER_FROM_GROUP = 10; // 群临时会话 | ||
|
||
// 以下类型为可选实现 | ||
NEARBY = 5; // 附近的人 | ||
STRANGER = 9; // 陌生人 | ||
} | ||
|
||
message Contact { | ||
Scene scene = 1; | ||
string peer = 2; // 群聊则为群号 私聊则为uid 频道消息则为频道号 | ||
optional string sub_peer = 3; // 群临时聊天则为群号 频道消息则为子频道号 其它情况可不提供 | ||
} | ||
|
||
message Sender { | ||
string uid = 1; | ||
optional uint64 uin = 2; | ||
optional string nick = 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
syntax = "proto3"; | ||
|
||
package kritor.common; | ||
|
||
option csharp_namespace = "Kritor.Common"; | ||
option java_multiple_files = true; | ||
option java_package = "io.kritor.common"; | ||
option go_package = "grpc/kritor/common"; | ||
|
||
import "Protos/common/contact.proto"; | ||
import "Protos/common/message_element.proto"; | ||
|
||
message PushMessageBody { | ||
uint32 time = 1; | ||
string message_id = 2; | ||
uint64 message_seq = 3; | ||
Contact contact = 4; // 从什么地方收到的信息 | ||
Sender sender = 5; // 发送者详细信息 | ||
repeated Element elements = 6; // 发的什么东西 | ||
} | ||
|
||
message ForwardMessageBody { | ||
oneof forward_message { | ||
string message_id = 1; | ||
PushMessageBody message = 2; | ||
} | ||
} | ||
|
||
message EssenceMessageBody { | ||
uint32 group_id = 1; | ||
string sender_uid = 2; | ||
uint64 sender_uin = 3; | ||
string sender_nick = 4; | ||
uint64 operator_uid = 5; | ||
uint64 operator_uin = 6; | ||
string operator_nick = 7; | ||
uint32 operation_time = 8; | ||
uint32 message_time = 9; | ||
string message_id = 10; | ||
uint64 message_seq = 11; | ||
string json_elements = 12; | ||
} |
Oops, something went wrong.