Skip to content

Commit

Permalink
Refactor: Create SakuarLibrary for IPC protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
fengberd committed Aug 17, 2020
1 parent 3f7fb36 commit 929e146
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,6 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# protobuf generated stuffs
**/Proto/Out/*.cs
6 changes: 6 additions & 0 deletions SakuraLauncher.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LegacyLauncher", "LegacyLau
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SakuraUpdater", "SakuraUpdater\SakuraUpdater.csproj", "{5FF971A9-1F53-4A85-9440-E61A8F659D75}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SakuraLibrary", "SakuraLibrary\SakuraLibrary.csproj", "{EC113DEE-C0B2-4E52-A318-FD44DAD67EA3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -27,6 +29,10 @@ Global
{5FF971A9-1F53-4A85-9440-E61A8F659D75}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5FF971A9-1F53-4A85-9440-E61A8F659D75}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FF971A9-1F53-4A85-9440-E61A8F659D75}.Release|Any CPU.Build.0 = Release|Any CPU
{EC113DEE-C0B2-4E52-A318-FD44DAD67EA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC113DEE-C0B2-4E52-A318-FD44DAD67EA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC113DEE-C0B2-4E52-A318-FD44DAD67EA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC113DEE-C0B2-4E52-A318-FD44DAD67EA3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
36 changes: 36 additions & 0 deletions SakuraLibrary/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("SakuraFrp Launcher Library")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SakuraLibrary")]
[assembly: AssemblyCopyright("Copyright © FENGberd 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]

// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("ec113dee-c0b2-4e52-a318-fd44dad67ea3")]

// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Empty file.
33 changes: 33 additions & 0 deletions SakuraLibrary/Proto/base.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
syntax = "proto3";
option csharp_namespace = "SakuraLibrary.Proto";

import "user.proto";
import "tunnel.proto";

enum MessageID {
USER_LOGIN = 0;
USER_LOGOUT = 1;
USER_INFO = 2;
TUNNEL_LIST = 3;
TUNNEL_RELOAD = 4;
TUNNEL_UPDATE = 5;
}

message BasicResponse {
bool success = 1;
string message = 2;
}

message BasicRequest {
int32 version = 1;
MessageID type = 2;

oneof data {
UserLogin USER_LOGIN = 3;
UserLogout USER_LOGOUT = 4;
UserInfoRequest USER_INFO = 5;
GetTunnelList TUNNEL_LIST = 6;
ReloadTunnelList TUNNEL_RELOAD = 7;
UpdateTunnelStatus TUNNEL_UPDATE = 8;
}
}
29 changes: 29 additions & 0 deletions SakuraLibrary/Proto/tunnel.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
syntax = "proto3";
option csharp_namespace = "SakuraLibrary.Proto";

message Tunnel {
int32 id = 1;
string name = 2;

enum Status {
DISABLED = 0;
RUNNING = 1;
PENDING = 2;
}
Status status = 3;
}

message GetTunnelList {}

message GetTunnelListResponse {
bool success = 1;
string message = 2;
repeated Tunnel tunnels = 3;
}

message ReloadTunnelList {}

message UpdateTunnelStatus {
int32 id = 1;
int32 status = 2;
}
20 changes: 20 additions & 0 deletions SakuraLibrary/Proto/user.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";
option csharp_namespace = "SakuraLibrary.Proto";

message User {
int32 id = 1;
string name = 2;

enum Status {
NO_LOGIN = 0;
LOGGING_IN = 1;
LOGGED_IN = 2;
}
Status status = 3;
}

message UserLogin { string token = 1; }

message UserLogout {}

message UserInfoRequest {}
73 changes: 73 additions & 0 deletions SakuraLibrary/SakuraLibrary.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{EC113DEE-C0B2-4E52-A318-FD44DAD67EA3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SakuraLibrary</RootNamespace>
<AssemblyName>SakuraLibrary</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Google.Protobuf, Version=3.13.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.13.0\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard1.1\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.2\lib\netstandard1.1\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<None Include="Proto\**" />
<Compile Include="Proto\Out\**" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>protoc -I"$(SolutionDir)$(ProjectName)\Proto" $(SolutionDir)$(ProjectName)\Proto\*.proto --csharp_out=$(SolutionDir)$(ProjectName)\Proto\Out</PreBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
7 changes: 7 additions & 0 deletions SakuraLibrary/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Google.Protobuf" version="3.13.0" targetFramework="net45" />
<package id="System.Buffers" version="4.4.0" targetFramework="net45" />
<package id="System.Memory" version="4.5.2" targetFramework="net45" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net45" />
</packages>

0 comments on commit 929e146

Please sign in to comment.