Compare commits
56 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35788158bc | ||
|
|
4fd494ded4 | ||
|
|
23eeb8ff55 | ||
|
|
456ffb200a | ||
|
|
18e0bb194e | ||
|
|
392f6111dd | ||
|
|
ce6572af3d | ||
|
|
cf59137481 | ||
|
|
519e588124 | ||
|
|
666c874998 | ||
|
|
5f9f677467 | ||
|
|
b06b5779dd | ||
|
|
e3a3b9c201 | ||
|
|
321ec30f39 | ||
|
|
5adae2dd2a | ||
|
|
be5e15dfb6 | ||
|
|
15d3418c79 | ||
|
|
0efb0228c6 | ||
|
|
75b399b48b | ||
|
|
24ccfb8077 | ||
|
|
204451db6c | ||
|
|
f553bbc41e | ||
|
|
8cb4f2f961 | ||
|
|
4d3db56065 | ||
|
|
d92540121f | ||
|
|
17d586ea26 | ||
|
|
9a096d31fc | ||
|
|
bf83dbdfea | ||
|
|
e31cd0e199 | ||
|
|
1e11477e27 | ||
|
|
e0750df96c | ||
|
|
e3580b05f7 | ||
|
|
6ad0762731 | ||
|
|
70b05d7812 | ||
|
|
5403fc9e21 | ||
|
|
5bffca9584 | ||
|
|
2060539c34 | ||
|
|
de3cdb4f7e | ||
|
|
2a4ba2a751 | ||
|
|
48747aabe0 | ||
|
|
7182be921d | ||
|
|
9d7dcd2c4f | ||
|
|
c3e56e84f1 | ||
|
|
f1ef5a1f51 | ||
|
|
d1e6898290 | ||
|
|
8597332b21 | ||
|
|
7cc42ae249 | ||
|
|
e054d4487d | ||
|
|
6ef36f521d | ||
|
|
a02a122dd1 | ||
|
|
701138617c | ||
|
|
d0e2cc9442 | ||
|
|
d561f10edc | ||
|
|
2df412476a | ||
|
|
e6011cfede | ||
|
|
bcf43e2928 |
4
.github/workflows/build-linux.yml
vendored
4
.github/workflows/build-linux.yml
vendored
@@ -32,7 +32,7 @@ jobs:
|
|||||||
fetch-depth: '0'
|
fetch-depth: '0'
|
||||||
|
|
||||||
- name: Setup
|
- name: Setup
|
||||||
uses: actions/setup-dotnet@v4.3.0
|
uses: actions/setup-dotnet@v4.3.1
|
||||||
with:
|
with:
|
||||||
dotnet-version: '8.0.x'
|
dotnet-version: '8.0.x'
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ jobs:
|
|||||||
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r linux-arm64 --self-contained=true -p:PublishTrimmed=true -o $OutputPathArm64
|
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r linux-arm64 --self-contained=true -p:PublishTrimmed=true -o $OutputPathArm64
|
||||||
|
|
||||||
- name: Upload build artifacts
|
- name: Upload build artifacts
|
||||||
uses: actions/upload-artifact@v4.6.1
|
uses: actions/upload-artifact@v4.6.2
|
||||||
with:
|
with:
|
||||||
name: v2rayN-linux
|
name: v2rayN-linux
|
||||||
path: |
|
path: |
|
||||||
|
|||||||
4
.github/workflows/build-osx.yml
vendored
4
.github/workflows/build-osx.yml
vendored
@@ -32,7 +32,7 @@ jobs:
|
|||||||
fetch-depth: '0'
|
fetch-depth: '0'
|
||||||
|
|
||||||
- name: Setup
|
- name: Setup
|
||||||
uses: actions/setup-dotnet@v4.3.0
|
uses: actions/setup-dotnet@v4.3.1
|
||||||
with:
|
with:
|
||||||
dotnet-version: '8.0.x'
|
dotnet-version: '8.0.x'
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ jobs:
|
|||||||
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r osx-arm64 --self-contained=true -p:PublishTrimmed=true -o $OutputPathArm64
|
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r osx-arm64 --self-contained=true -p:PublishTrimmed=true -o $OutputPathArm64
|
||||||
|
|
||||||
- name: Upload build artifacts
|
- name: Upload build artifacts
|
||||||
uses: actions/upload-artifact@v4.6.1
|
uses: actions/upload-artifact@v4.6.2
|
||||||
with:
|
with:
|
||||||
name: v2rayN-macos
|
name: v2rayN-macos
|
||||||
path: |
|
path: |
|
||||||
|
|||||||
4
.github/workflows/build-windows-desktop.yml
vendored
4
.github/workflows/build-windows-desktop.yml
vendored
@@ -32,7 +32,7 @@ jobs:
|
|||||||
fetch-depth: '0'
|
fetch-depth: '0'
|
||||||
|
|
||||||
- name: Setup
|
- name: Setup
|
||||||
uses: actions/setup-dotnet@v4.3.0
|
uses: actions/setup-dotnet@v4.3.1
|
||||||
with:
|
with:
|
||||||
dotnet-version: '8.0.x'
|
dotnet-version: '8.0.x'
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ jobs:
|
|||||||
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r win-arm64 --self-contained=true -p:EnableWindowsTargeting=true -p:PublishTrimmed=true -o $OutputPathArm64
|
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r win-arm64 --self-contained=true -p:EnableWindowsTargeting=true -p:PublishTrimmed=true -o $OutputPathArm64
|
||||||
|
|
||||||
- name: Upload build artifacts
|
- name: Upload build artifacts
|
||||||
uses: actions/upload-artifact@v4.6.1
|
uses: actions/upload-artifact@v4.6.2
|
||||||
with:
|
with:
|
||||||
name: v2rayN-windows-desktop
|
name: v2rayN-windows-desktop
|
||||||
path: |
|
path: |
|
||||||
|
|||||||
4
.github/workflows/build-windows.yml
vendored
4
.github/workflows/build-windows.yml
vendored
@@ -30,7 +30,7 @@ jobs:
|
|||||||
uses: actions/checkout@v4.2.2
|
uses: actions/checkout@v4.2.2
|
||||||
|
|
||||||
- name: Setup
|
- name: Setup
|
||||||
uses: actions/setup-dotnet@v4.3.0
|
uses: actions/setup-dotnet@v4.3.1
|
||||||
with:
|
with:
|
||||||
dotnet-version: '8.0.x'
|
dotnet-version: '8.0.x'
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ jobs:
|
|||||||
|
|
||||||
|
|
||||||
- name: Upload build artifacts
|
- name: Upload build artifacts
|
||||||
uses: actions/upload-artifact@v4.6.1
|
uses: actions/upload-artifact@v4.6.2
|
||||||
with:
|
with:
|
||||||
name: v2rayN-windows
|
name: v2rayN-windows
|
||||||
path: |
|
path: |
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace AmazTool
|
namespace AmazTool;
|
||||||
|
|
||||||
|
internal static class Program
|
||||||
{
|
{
|
||||||
internal static class Program
|
|
||||||
{
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
@@ -22,5 +22,4 @@ namespace AmazTool
|
|||||||
|
|
||||||
UpgradeApp.Upgrade(argData);
|
UpgradeApp.Upgrade(argData);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
2
v2rayN/AmazTool/Resx/Resource.Designer.cs
generated
2
v2rayN/AmazTool/Resx/Resource.Designer.cs
generated
@@ -61,7 +61,7 @@ namespace AmazTool.Resx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 Failed to terminate the v2rayN.Close it manually,or the upgrade may fail. 的本地化字符串。
|
/// 查找类似 Failed to terminate the v2rayN. Close it manually, or the upgrade may fail. 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string FailedTerminateProcess {
|
internal static string FailedTerminateProcess {
|
||||||
get {
|
get {
|
||||||
|
|||||||
@@ -133,7 +133,7 @@
|
|||||||
<value>Try to terminate the v2rayN process...</value>
|
<value>Try to terminate the v2rayN process...</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="FailedTerminateProcess" xml:space="preserve">
|
<data name="FailedTerminateProcess" xml:space="preserve">
|
||||||
<value>Failed to terminate the v2rayN.Close it manually,or the upgrade may fail.</value>
|
<value>Failed to terminate the v2rayN. Close it manually, or the upgrade may fail.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="StartUnzipping" xml:space="preserve">
|
<data name="StartUnzipping" xml:space="preserve">
|
||||||
<value>Start extracting the update package...</value>
|
<value>Start extracting the update package...</value>
|
||||||
|
|||||||
@@ -133,7 +133,7 @@
|
|||||||
<value>尝试结束 v2rayN 进程...</value>
|
<value>尝试结束 v2rayN 进程...</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="FailedTerminateProcess" xml:space="preserve">
|
<data name="FailedTerminateProcess" xml:space="preserve">
|
||||||
<value>请手动关闭正在运行的v2rayN,否则可能升级失败。</value>
|
<value>请手动关闭正在运行的 v2rayN,否则可能升级失败。</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="StartUnzipping" xml:space="preserve">
|
<data name="StartUnzipping" xml:space="preserve">
|
||||||
<value>开始解压缩更新包...</value>
|
<value>开始解压缩更新包...</value>
|
||||||
|
|||||||
156
v2rayN/AmazTool/Resx/Resource.zh-Hant.resx
Normal file
156
v2rayN/AmazTool/Resx/Resource.zh-Hant.resx
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<data name="Restartv2rayN" xml:space="preserve">
|
||||||
|
<value>正在重啟,請等待...</value>
|
||||||
|
</data>
|
||||||
|
<data name="Guidelines" xml:space="preserve">
|
||||||
|
<value>請從主應用程式運行。</value>
|
||||||
|
</data>
|
||||||
|
<data name="UpgradeFileNotFound" xml:space="preserve">
|
||||||
|
<value>升級失敗,檔案不存在。</value>
|
||||||
|
</data>
|
||||||
|
<data name="InProgress" xml:space="preserve">
|
||||||
|
<value>正在進行中,請等待...</value>
|
||||||
|
</data>
|
||||||
|
<data name="TryTerminateProcess" xml:space="preserve">
|
||||||
|
<value>嘗試結束 v2rayN 進程...</value>
|
||||||
|
</data>
|
||||||
|
<data name="FailedTerminateProcess" xml:space="preserve">
|
||||||
|
<value>請手動關閉正在執行的 v2rayN,否則可能會升級失敗。</value>
|
||||||
|
</data>
|
||||||
|
<data name="StartUnzipping" xml:space="preserve">
|
||||||
|
<value>開始解壓縮更新包...</value>
|
||||||
|
</data>
|
||||||
|
<data name="SuccessUnzipping" xml:space="preserve">
|
||||||
|
<value>解壓縮更新包成功。</value>
|
||||||
|
</data>
|
||||||
|
<data name="FailedUnzipping" xml:space="preserve">
|
||||||
|
<value>解壓縮更新包失敗。</value>
|
||||||
|
</data>
|
||||||
|
<data name="FailedUpgrade" xml:space="preserve">
|
||||||
|
<value>升級失敗。</value>
|
||||||
|
</data>
|
||||||
|
<data name="SuccessUpgrade" xml:space="preserve">
|
||||||
|
<value>升級成功。</value>
|
||||||
|
</data>
|
||||||
|
<data name="Information" xml:space="preserve">
|
||||||
|
<value>提示</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
||||||
@@ -2,10 +2,10 @@ using System.Diagnostics;
|
|||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace AmazTool
|
namespace AmazTool;
|
||||||
|
|
||||||
|
internal class UpgradeApp
|
||||||
{
|
{
|
||||||
internal class UpgradeApp
|
|
||||||
{
|
|
||||||
public static void Upgrade(string fileName)
|
public static void Upgrade(string fileName)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{Resx.Resource.StartUnzipping}\n{fileName}");
|
Console.WriteLine($"{Resx.Resource.StartUnzipping}\n{fileName}");
|
||||||
@@ -113,5 +113,4 @@ namespace AmazTool
|
|||||||
|
|
||||||
Utils.StartV2RayN();
|
Utils.StartV2RayN();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace AmazTool
|
namespace AmazTool;
|
||||||
|
|
||||||
|
internal class Utils
|
||||||
{
|
{
|
||||||
internal class Utils
|
|
||||||
{
|
|
||||||
public static string GetExePath()
|
public static string GetExePath()
|
||||||
{
|
{
|
||||||
return Environment.ProcessPath ?? Process.GetCurrentProcess().MainModule?.FileName ?? string.Empty;
|
return Environment.ProcessPath ?? Process.GetCurrentProcess().MainModule?.FileName ?? string.Empty;
|
||||||
@@ -48,5 +48,4 @@ namespace AmazTool
|
|||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
<Project>
|
<Project>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>7.10.4</Version>
|
<Version>7.11.3</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||||
<NoWarn>CA1031;CS1591;NU1507;CA1416</NoWarn>
|
<NoWarn>CA1031;CS1591;NU1507;CA1416;IDE0058</NoWarn>
|
||||||
<Nullable>annotations</Nullable>
|
<Nullable>annotations</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Authors>2dust</Authors>
|
<Authors>2dust</Authors>
|
||||||
|
|||||||
@@ -5,25 +5,25 @@
|
|||||||
<CentralPackageVersionOverrideEnabled>false</CentralPackageVersionOverrideEnabled>
|
<CentralPackageVersionOverrideEnabled>false</CentralPackageVersionOverrideEnabled>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.2.5" />
|
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.2.8" />
|
||||||
<PackageVersion Include="Avalonia.Desktop" Version="11.2.5" />
|
<PackageVersion Include="Avalonia.Desktop" Version="11.2.8" />
|
||||||
<PackageVersion Include="Avalonia.Diagnostics" Version="11.2.5" />
|
<PackageVersion Include="Avalonia.Diagnostics" Version="11.2.8" />
|
||||||
<PackageVersion Include="Avalonia.ReactiveUI" Version="11.2.5" />
|
<PackageVersion Include="Avalonia.ReactiveUI" Version="11.2.8" />
|
||||||
<PackageVersion Include="CliWrap" Version="3.8.1" />
|
<PackageVersion Include="CliWrap" Version="3.8.2" />
|
||||||
<PackageVersion Include="Downloader" Version="3.3.3" />
|
<PackageVersion Include="Downloader" Version="3.3.4" />
|
||||||
<PackageVersion Include="H.NotifyIcon.Wpf" Version="2.3.0" />
|
<PackageVersion Include="H.NotifyIcon.Wpf" Version="2.3.0" />
|
||||||
<PackageVersion Include="MaterialDesignThemes" Version="5.2.1" />
|
<PackageVersion Include="MaterialDesignThemes" Version="5.2.1" />
|
||||||
<PackageVersion Include="MessageBox.Avalonia" Version="3.2.0" />
|
<PackageVersion Include="MessageBox.Avalonia" Version="3.2.0" />
|
||||||
<PackageVersion Include="QRCoder" Version="1.6.0" />
|
<PackageVersion Include="QRCoder" Version="1.6.0" />
|
||||||
<PackageVersion Include="ReactiveUI" Version="20.1.63" />
|
<PackageVersion Include="ReactiveUI" Version="20.2.45" />
|
||||||
<PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" />
|
<PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" />
|
||||||
<PackageVersion Include="ReactiveUI.WPF" Version="20.1.63" />
|
<PackageVersion Include="ReactiveUI.WPF" Version="20.2.45" />
|
||||||
<PackageVersion Include="Semi.Avalonia" Version="11.2.1.5" />
|
<PackageVersion Include="Semi.Avalonia" Version="11.2.1.6" />
|
||||||
<PackageVersion Include="Semi.Avalonia.DataGrid" Version="11.2.1.5" />
|
<PackageVersion Include="Semi.Avalonia.DataGrid" Version="11.2.1.6" />
|
||||||
<PackageVersion Include="Splat.NLog" Version="15.3.1" />
|
<PackageVersion Include="Splat.NLog" Version="15.3.1" />
|
||||||
<PackageVersion Include="sqlite-net-pcl" Version="1.9.172" />
|
<PackageVersion Include="sqlite-net-pcl" Version="1.9.172" />
|
||||||
<PackageVersion Include="TaskScheduler" Version="2.12.0" />
|
<PackageVersion Include="TaskScheduler" Version="2.12.1" />
|
||||||
<PackageVersion Include="WebDav.Client" Version="2.8.0" />
|
<PackageVersion Include="WebDav.Client" Version="2.9.0" />
|
||||||
<PackageVersion Include="YamlDotNet" Version="16.3.0" />
|
<PackageVersion Include="YamlDotNet" Version="16.3.0" />
|
||||||
<PackageVersion Include="ZXing.Net.Bindings.SkiaSharp" Version="0.16.14" />
|
<PackageVersion Include="ZXing.Net.Bindings.SkiaSharp" Version="0.16.14" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace ServiceLib.Base
|
namespace ServiceLib.Base;
|
||||||
|
|
||||||
|
public class MyReactiveObject : ReactiveObject
|
||||||
{
|
{
|
||||||
public class MyReactiveObject : ReactiveObject
|
|
||||||
{
|
|
||||||
protected static Config? _config;
|
protected static Config? _config;
|
||||||
protected Func<EViewAction, object?, Task<bool>>? _updateView;
|
protected Func<EViewAction, object?, Task<bool>>? _updateView;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace ServiceLib.Common
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
|
public class AesUtils
|
||||||
{
|
{
|
||||||
public class AesUtils
|
|
||||||
{
|
|
||||||
private const int KeySize = 256; // AES-256
|
private const int KeySize = 256; // AES-256
|
||||||
private const int IvSize = 16; // AES block size
|
private const int IvSize = 16; // AES block size
|
||||||
private const int Iterations = 10000;
|
private const int Iterations = 10000;
|
||||||
private static readonly byte[] Salt = Encoding.ASCII.GetBytes("saltysalt".PadRight(16, ' ')); // google浏览器默认盐值
|
private static readonly byte[] Salt = Encoding.ASCII.GetBytes("saltysalt".PadRight(16, ' '));
|
||||||
private static readonly string DefaultPassword = Utils.GetMd5(Utils.GetHomePath() + "AesUtils");
|
private static readonly string DefaultPassword = Utils.GetMd5(Utils.GetHomePath() + "AesUtils");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -97,5 +97,4 @@ namespace ServiceLib.Common
|
|||||||
rng.GetBytes(randomNumber);
|
rng.GetBytes(randomNumber);
|
||||||
return randomNumber;
|
return randomNumber;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace ServiceLib.Common
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
|
public class DesUtils
|
||||||
{
|
{
|
||||||
public class DesUtils
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Encrypt
|
/// Encrypt
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -71,5 +71,4 @@ namespace ServiceLib.Common
|
|||||||
{
|
{
|
||||||
return Utils.GetMd5(Utils.GetHomePath() + "DesUtils");
|
return Utils.GetMd5(Utils.GetHomePath() + "DesUtils");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using Downloader;
|
using Downloader;
|
||||||
|
|
||||||
namespace ServiceLib.Common
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
|
public class DownloaderHelper
|
||||||
{
|
{
|
||||||
public class DownloaderHelper
|
|
||||||
{
|
|
||||||
private static readonly Lazy<DownloaderHelper> _instance = new(() => new());
|
private static readonly Lazy<DownloaderHelper> _instance = new(() => new());
|
||||||
public static DownloaderHelper Instance => _instance.Value;
|
public static DownloaderHelper Instance => _instance.Value;
|
||||||
|
|
||||||
@@ -177,5 +177,4 @@ namespace ServiceLib.Common
|
|||||||
|
|
||||||
downloadOpt = null;
|
downloadOpt = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ using System.Formats.Tar;
|
|||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace ServiceLib.Common
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
|
public static class FileManager
|
||||||
{
|
{
|
||||||
public static class FileManager
|
|
||||||
{
|
|
||||||
private static readonly string _tag = "FileManager";
|
private static readonly string _tag = "FileManager";
|
||||||
|
|
||||||
public static bool ByteArrayToFile(string fileName, byte[] content)
|
public static bool ByteArrayToFile(string fileName, byte[] content)
|
||||||
@@ -223,5 +223,4 @@ namespace ServiceLib.Common
|
|||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ using System.Net.Http.Headers;
|
|||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace ServiceLib.Common
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public class HttpClientHelper
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// </summary>
|
|
||||||
public class HttpClientHelper
|
|
||||||
{
|
|
||||||
private static readonly Lazy<HttpClientHelper> _instance = new(() =>
|
private static readonly Lazy<HttpClientHelper> _instance = new(() =>
|
||||||
{
|
{
|
||||||
SocketsHttpHandler handler = new() { UseCookies = false };
|
SocketsHttpHandler handler = new() { UseCookies = false };
|
||||||
@@ -202,5 +202,4 @@ namespace ServiceLib.Common
|
|||||||
}
|
}
|
||||||
} while (isMoreToRead);
|
} while (isMoreToRead);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace ServiceLib.Common
|
namespace ServiceLib.Common;
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* See:
|
* See:
|
||||||
* http://stackoverflow.com/questions/6266820/working-example-of-createjobobject-setinformationjobobject-pinvoke-in-net
|
* http://stackoverflow.com/questions/6266820/working-example-of-createjobobject-setinformationjobobject-pinvoke-in-net
|
||||||
@@ -178,4 +177,4 @@ namespace ServiceLib.Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion Helper classes
|
#endregion Helper classes
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Encodings.Web;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace ServiceLib.Common
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
|
public class JsonUtils
|
||||||
{
|
{
|
||||||
public class JsonUtils
|
|
||||||
{
|
|
||||||
private static readonly string _tag = "JsonUtils";
|
private static readonly string _tag = "JsonUtils";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -86,7 +87,8 @@ namespace ServiceLib.Common
|
|||||||
var options = new JsonSerializerOptions
|
var options = new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
WriteIndented = indented,
|
WriteIndented = indented,
|
||||||
DefaultIgnoreCondition = nullValue ? JsonIgnoreCondition.Never : JsonIgnoreCondition.WhenWritingNull
|
DefaultIgnoreCondition = nullValue ? JsonIgnoreCondition.Never : JsonIgnoreCondition.WhenWritingNull,
|
||||||
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||||
};
|
};
|
||||||
result = JsonSerializer.Serialize(obj, options);
|
result = JsonSerializer.Serialize(obj, options);
|
||||||
}
|
}
|
||||||
@@ -127,5 +129,4 @@ namespace ServiceLib.Common
|
|||||||
/// <param name="obj"></param>
|
/// <param name="obj"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static JsonNode? SerializeToNode(object? obj) => JsonSerializer.SerializeToNode(obj);
|
public static JsonNode? SerializeToNode(object? obj) => JsonSerializer.SerializeToNode(obj);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,13 @@ using NLog;
|
|||||||
using NLog.Config;
|
using NLog.Config;
|
||||||
using NLog.Targets;
|
using NLog.Targets;
|
||||||
|
|
||||||
namespace ServiceLib.Common
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
|
public class Logging
|
||||||
{
|
{
|
||||||
public class Logging
|
private static readonly Logger _logger1 = LogManager.GetLogger("Log1");
|
||||||
{
|
private static readonly Logger _logger2 = LogManager.GetLogger("Log2");
|
||||||
|
|
||||||
public static void Setup()
|
public static void Setup()
|
||||||
{
|
{
|
||||||
LoggingConfiguration config = new();
|
LoggingConfiguration config = new();
|
||||||
@@ -32,7 +35,7 @@ namespace ServiceLib.Common
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogManager.GetLogger("Log1").Info(strContent);
|
_logger1.Info(strContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SaveLog(string strTitle, Exception ex)
|
public static void SaveLog(string strTitle, Exception ex)
|
||||||
@@ -42,13 +45,11 @@ namespace ServiceLib.Common
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var logger = LogManager.GetLogger("Log2");
|
_logger2.Debug($"{strTitle},{ex.Message}");
|
||||||
logger.Debug($"{strTitle},{ex.Message}");
|
_logger2.Debug(ex.StackTrace);
|
||||||
logger.Debug(ex.StackTrace);
|
|
||||||
if (ex?.InnerException != null)
|
if (ex?.InnerException != null)
|
||||||
{
|
{
|
||||||
logger.Error(ex.InnerException);
|
_logger2.Error(ex.InnerException);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
using QRCoder;
|
using QRCoder;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
using ZXing.SkiaSharp;
|
using ZXing.SkiaSharp;
|
||||||
|
|
||||||
namespace ServiceLib.Common
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
|
public class QRCodeHelper
|
||||||
{
|
{
|
||||||
public class QRCodeHelper
|
|
||||||
{
|
|
||||||
public static byte[]? GenQRCode(string? url)
|
public static byte[]? GenQRCode(string? url)
|
||||||
{
|
{
|
||||||
using QRCodeGenerator qrGenerator = new();
|
using QRCodeGenerator qrGenerator = new();
|
||||||
@@ -86,5 +86,4 @@ namespace ServiceLib.Common
|
|||||||
canvas.DrawBitmap(bmp, 0, 0);
|
canvas.DrawBitmap(bmp, 0, 0);
|
||||||
return flipped;
|
return flipped;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Common
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
|
public class SemanticVersion
|
||||||
{
|
{
|
||||||
public class SemanticVersion
|
|
||||||
{
|
|
||||||
private readonly int major;
|
private readonly int major;
|
||||||
private readonly int minor;
|
private readonly int minor;
|
||||||
private readonly int patch;
|
private readonly int patch;
|
||||||
@@ -183,5 +183,4 @@ namespace ServiceLib.Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion Private
|
#endregion Private
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using SQLite;
|
using SQLite;
|
||||||
|
|
||||||
namespace ServiceLib.Common
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
|
public sealed class SQLiteHelper
|
||||||
{
|
{
|
||||||
public sealed class SQLiteHelper
|
|
||||||
{
|
|
||||||
private static readonly Lazy<SQLiteHelper> _instance = new(() => new());
|
private static readonly Lazy<SQLiteHelper> _instance = new(() => new());
|
||||||
public static SQLiteHelper Instance => _instance.Value;
|
public static SQLiteHelper Instance => _instance.Value;
|
||||||
private readonly string _connstr;
|
private readonly string _connstr;
|
||||||
@@ -87,5 +87,4 @@ namespace ServiceLib.Common
|
|||||||
_dbAsync = null;
|
_dbAsync = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace ServiceLib.Common
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
|
public static class StringEx
|
||||||
{
|
{
|
||||||
public static class StringEx
|
|
||||||
{
|
|
||||||
public static bool IsNullOrEmpty([NotNullWhen(false)] this string? value)
|
public static bool IsNullOrEmpty([NotNullWhen(false)] this string? value)
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(value) || string.IsNullOrWhiteSpace(value);
|
return string.IsNullOrEmpty(value) || string.IsNullOrWhiteSpace(value);
|
||||||
@@ -79,5 +79,4 @@ namespace ServiceLib.Common
|
|||||||
{
|
{
|
||||||
return int.TryParse(value, out var result) ? result : defaultValue;
|
return int.TryParse(value, out var result) ? result : defaultValue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ using System.Text;
|
|||||||
using CliWrap;
|
using CliWrap;
|
||||||
using CliWrap.Buffered;
|
using CliWrap.Buffered;
|
||||||
|
|
||||||
namespace ServiceLib.Common
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
|
public class Utils
|
||||||
{
|
{
|
||||||
public class Utils
|
|
||||||
{
|
|
||||||
private static readonly string _tag = "Utils";
|
private static readonly string _tag = "Utils";
|
||||||
|
|
||||||
#region 转换函数
|
#region 转换函数
|
||||||
@@ -224,6 +224,13 @@ namespace ServiceLib.Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static string GetMd5(string str)
|
public static string GetMd5(string str)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(str))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var byteOld = Encoding.UTF8.GetBytes(str);
|
var byteOld = Encoding.UTF8.GetBytes(str);
|
||||||
var byteNew = MD5.HashData(byteOld);
|
var byteNew = MD5.HashData(byteOld);
|
||||||
@@ -235,6 +242,38 @@ namespace ServiceLib.Common
|
|||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logging.SaveLog(_tag, ex);
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetFileHash(string filePath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(filePath))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!File.Exists(filePath))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var md5 = MD5.Create();
|
||||||
|
using var stream = File.OpenRead(filePath);
|
||||||
|
var hash = md5.ComputeHash(stream);
|
||||||
|
return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logging.SaveLog(_tag, ex);
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// idn to idc
|
/// idn to idc
|
||||||
@@ -564,13 +603,20 @@ namespace ServiceLib.Common
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var basePath = GetBaseDirectory();
|
||||||
//When this file exists, it is equivalent to having no permission to read and write
|
//When this file exists, it is equivalent to having no permission to read and write
|
||||||
if (File.Exists(Path.Combine(GetBaseDirectory(), "NotStoreConfigHere.txt")))
|
if (File.Exists(Path.Combine(basePath, "NotStoreConfigHere.txt")))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var tempPath = Path.Combine(GetBaseDirectory(), "guiTemps");
|
//Check if it is installed by Windows WinGet
|
||||||
|
if (IsWindows() && basePath.Contains("Users") && basePath.Contains("WinGet"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var tempPath = Path.Combine(basePath, "guiTemps");
|
||||||
if (!Directory.Exists(tempPath))
|
if (!Directory.Exists(tempPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(tempPath);
|
Directory.CreateDirectory(tempPath);
|
||||||
@@ -816,5 +862,4 @@ namespace ServiceLib.Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion Platform
|
#endregion Platform
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ using System.Security.Cryptography;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
|
||||||
namespace ServiceLib.Common
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
|
internal static class WindowsUtils
|
||||||
{
|
{
|
||||||
internal static class WindowsUtils
|
|
||||||
{
|
|
||||||
private static readonly string _tag = "WindowsUtils";
|
private static readonly string _tag = "WindowsUtils";
|
||||||
|
|
||||||
public static string? RegReadValue(string path, string name, string def)
|
public static string? RegReadValue(string path, string name, string def)
|
||||||
@@ -70,5 +70,4 @@ namespace ServiceLib.Common
|
|||||||
Logging.SaveLog(_tag, ex);
|
Logging.SaveLog(_tag, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,16 @@ using YamlDotNet.Core;
|
|||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
using YamlDotNet.Serialization.NamingConventions;
|
using YamlDotNet.Serialization.NamingConventions;
|
||||||
|
|
||||||
namespace ServiceLib.Common
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
|
public class YamlUtils
|
||||||
{
|
{
|
||||||
public class YamlUtils
|
|
||||||
{
|
|
||||||
private static readonly string _tag = "YamlUtils";
|
private static readonly string _tag = "YamlUtils";
|
||||||
|
|
||||||
#region YAML
|
#region YAML
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 反序列化成对象
|
/// Deserialize
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <param name="str"></param>
|
/// <param name="str"></param>
|
||||||
@@ -34,7 +34,7 @@ namespace ServiceLib.Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 序列化
|
/// Serialize
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj"></param>
|
/// <param name="obj"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@@ -76,5 +76,4 @@ namespace ServiceLib.Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion YAML
|
#endregion YAML
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Enums
|
namespace ServiceLib.Enums;
|
||||||
|
|
||||||
|
public enum EConfigType
|
||||||
{
|
{
|
||||||
public enum EConfigType
|
|
||||||
{
|
|
||||||
VMess = 1,
|
VMess = 1,
|
||||||
Custom = 2,
|
Custom = 2,
|
||||||
Shadowsocks = 3,
|
Shadowsocks = 3,
|
||||||
@@ -12,5 +12,4 @@
|
|||||||
TUIC = 8,
|
TUIC = 8,
|
||||||
WireGuard = 9,
|
WireGuard = 9,
|
||||||
HTTP = 10
|
HTTP = 10
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Enums
|
namespace ServiceLib.Enums;
|
||||||
|
|
||||||
|
public enum ECoreType
|
||||||
{
|
{
|
||||||
public enum ECoreType
|
|
||||||
{
|
|
||||||
v2fly = 1,
|
v2fly = 1,
|
||||||
Xray = 2,
|
Xray = 2,
|
||||||
v2fly_v5 = 4,
|
v2fly_v5 = 4,
|
||||||
@@ -15,5 +15,4 @@ namespace ServiceLib.Enums
|
|||||||
brook = 27,
|
brook = 27,
|
||||||
overtls = 28,
|
overtls = 28,
|
||||||
v2rayN = 99
|
v2rayN = 99
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
namespace ServiceLib.Enums
|
namespace ServiceLib.Enums;
|
||||||
|
|
||||||
|
public enum EGirdOrientation
|
||||||
{
|
{
|
||||||
public enum EGirdOrientation
|
|
||||||
{
|
|
||||||
Horizontal,
|
Horizontal,
|
||||||
Vertical,
|
Vertical,
|
||||||
Tab,
|
Tab,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
namespace ServiceLib.Enums
|
namespace ServiceLib.Enums;
|
||||||
|
|
||||||
|
public enum EGlobalHotkey
|
||||||
{
|
{
|
||||||
public enum EGlobalHotkey
|
|
||||||
{
|
|
||||||
ShowForm = 0,
|
ShowForm = 0,
|
||||||
SystemProxyClear = 1,
|
SystemProxyClear = 1,
|
||||||
SystemProxySet = 2,
|
SystemProxySet = 2,
|
||||||
SystemProxyUnchanged = 3,
|
SystemProxyUnchanged = 3,
|
||||||
SystemProxyPac = 4,
|
SystemProxyPac = 4,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Enums
|
namespace ServiceLib.Enums;
|
||||||
|
|
||||||
|
public enum EInboundProtocol
|
||||||
{
|
{
|
||||||
public enum EInboundProtocol
|
|
||||||
{
|
|
||||||
socks = 0,
|
socks = 0,
|
||||||
socks2,
|
socks2,
|
||||||
socks3,
|
socks3,
|
||||||
@@ -10,5 +10,4 @@
|
|||||||
api2,
|
api2,
|
||||||
mixed,
|
mixed,
|
||||||
speedtest = 21
|
speedtest = 21
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
namespace ServiceLib.Enums
|
namespace ServiceLib.Enums;
|
||||||
|
|
||||||
|
public enum EMove
|
||||||
{
|
{
|
||||||
public enum EMove
|
|
||||||
{
|
|
||||||
Top = 1,
|
Top = 1,
|
||||||
Up = 2,
|
Up = 2,
|
||||||
Down = 3,
|
Down = 3,
|
||||||
Bottom = 4,
|
Bottom = 4,
|
||||||
Position = 5
|
Position = 5
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
namespace ServiceLib.Enums
|
namespace ServiceLib.Enums;
|
||||||
|
|
||||||
|
public enum EMsgCommand
|
||||||
{
|
{
|
||||||
public enum EMsgCommand
|
|
||||||
{
|
|
||||||
ClearMsg,
|
ClearMsg,
|
||||||
SendMsgView,
|
SendMsgView,
|
||||||
SendSnackMsg,
|
SendSnackMsg,
|
||||||
RefreshProfiles,
|
RefreshProfiles,
|
||||||
AppExit
|
AppExit
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
9
v2rayN/ServiceLib/Enums/EMultipleLoad.cs
Normal file
9
v2rayN/ServiceLib/Enums/EMultipleLoad.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace ServiceLib.Enums;
|
||||||
|
|
||||||
|
public enum EMultipleLoad
|
||||||
|
{
|
||||||
|
Random,
|
||||||
|
RoundRobin,
|
||||||
|
LeastPing,
|
||||||
|
LeastLoad
|
||||||
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
namespace ServiceLib.Enums
|
namespace ServiceLib.Enums;
|
||||||
|
|
||||||
|
public enum EPresetType
|
||||||
{
|
{
|
||||||
public enum EPresetType
|
|
||||||
{
|
|
||||||
Default = 0,
|
Default = 0,
|
||||||
Russia = 1,
|
Russia = 1,
|
||||||
Iran = 2,
|
Iran = 2,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
namespace ServiceLib.Enums
|
namespace ServiceLib.Enums;
|
||||||
|
|
||||||
|
public enum ERuleMode
|
||||||
{
|
{
|
||||||
public enum ERuleMode
|
|
||||||
{
|
|
||||||
Rule = 0,
|
Rule = 0,
|
||||||
Global = 1,
|
Global = 1,
|
||||||
Direct = 2,
|
Direct = 2,
|
||||||
Unchanged = 3
|
Unchanged = 3
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Enums
|
namespace ServiceLib.Enums;
|
||||||
|
|
||||||
|
public enum EServerColName
|
||||||
{
|
{
|
||||||
public enum EServerColName
|
|
||||||
{
|
|
||||||
Def = 0,
|
Def = 0,
|
||||||
ConfigType,
|
ConfigType,
|
||||||
Remarks,
|
Remarks,
|
||||||
@@ -17,5 +17,4 @@
|
|||||||
TodayUp,
|
TodayUp,
|
||||||
TotalDown,
|
TotalDown,
|
||||||
TotalUp
|
TotalUp
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
namespace ServiceLib.Enums
|
namespace ServiceLib.Enums;
|
||||||
|
|
||||||
|
public enum ESpeedActionType
|
||||||
{
|
{
|
||||||
public enum ESpeedActionType
|
|
||||||
{
|
|
||||||
Tcping,
|
Tcping,
|
||||||
Realping,
|
Realping,
|
||||||
Speedtest,
|
Speedtest,
|
||||||
Mixedtest
|
Mixedtest
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
namespace ServiceLib.Enums
|
namespace ServiceLib.Enums;
|
||||||
|
|
||||||
|
public enum ESysProxyType
|
||||||
{
|
{
|
||||||
public enum ESysProxyType
|
|
||||||
{
|
|
||||||
ForcedClear = 0,
|
ForcedClear = 0,
|
||||||
ForcedChange = 1,
|
ForcedChange = 1,
|
||||||
Unchanged = 2,
|
Unchanged = 2,
|
||||||
Pac = 3
|
Pac = 3
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Enums
|
namespace ServiceLib.Enums;
|
||||||
|
|
||||||
|
public enum ETheme
|
||||||
{
|
{
|
||||||
public enum ETheme
|
|
||||||
{
|
|
||||||
FollowSystem,
|
FollowSystem,
|
||||||
Dark,
|
Dark,
|
||||||
Light,
|
Light,
|
||||||
@@ -9,5 +9,4 @@
|
|||||||
Desert,
|
Desert,
|
||||||
Dusk,
|
Dusk,
|
||||||
NightSky
|
NightSky
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Enums
|
namespace ServiceLib.Enums;
|
||||||
|
|
||||||
|
public enum ETransport
|
||||||
{
|
{
|
||||||
public enum ETransport
|
|
||||||
{
|
|
||||||
tcp,
|
tcp,
|
||||||
kcp,
|
kcp,
|
||||||
ws,
|
ws,
|
||||||
@@ -11,5 +11,4 @@
|
|||||||
http,
|
http,
|
||||||
quic,
|
quic,
|
||||||
grpc
|
grpc
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Enums
|
namespace ServiceLib.Enums;
|
||||||
|
|
||||||
|
public enum EViewAction
|
||||||
{
|
{
|
||||||
public enum EViewAction
|
|
||||||
{
|
|
||||||
CloseWindow,
|
CloseWindow,
|
||||||
ShowYesNo,
|
ShowYesNo,
|
||||||
SaveFileDialog,
|
SaveFileDialog,
|
||||||
@@ -42,5 +42,4 @@
|
|||||||
DispatcherCheckUpdate,
|
DispatcherCheckUpdate,
|
||||||
DispatcherCheckUpdateFinished,
|
DispatcherCheckUpdateFinished,
|
||||||
DispatcherShowMsg,
|
DispatcherShowMsg,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib
|
namespace ServiceLib;
|
||||||
|
|
||||||
|
public class Global
|
||||||
{
|
{
|
||||||
public class Global
|
|
||||||
{
|
|
||||||
#region const
|
#region const
|
||||||
|
|
||||||
public const string AppName = "v2rayN";
|
public const string AppName = "v2rayN";
|
||||||
@@ -72,6 +72,7 @@ namespace ServiceLib
|
|||||||
public const string LocalAppData = "V2RAYN_LOCAL_APPLICATION_DATA_V2";
|
public const string LocalAppData = "V2RAYN_LOCAL_APPLICATION_DATA_V2";
|
||||||
public const string V2RayLocalAsset = "V2RAY_LOCATION_ASSET";
|
public const string V2RayLocalAsset = "V2RAY_LOCATION_ASSET";
|
||||||
public const string XrayLocalAsset = "XRAY_LOCATION_ASSET";
|
public const string XrayLocalAsset = "XRAY_LOCATION_ASSET";
|
||||||
|
public const string XrayLocalCert = "XRAY_LOCATION_CERT";
|
||||||
public const int SpeedTestPageSize = 1000;
|
public const int SpeedTestPageSize = 1000;
|
||||||
public const string LinuxBash = "/bin/bash";
|
public const string LinuxBash = "/bin/bash";
|
||||||
|
|
||||||
@@ -124,7 +125,7 @@ namespace ServiceLib
|
|||||||
[
|
[
|
||||||
"",
|
"",
|
||||||
@"https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/{0}.dat",
|
@"https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/{0}.dat",
|
||||||
@"https://cdn.jsdelivr.net/gh/chocolate4u/Iran-v2ray-rules@release/{0}.dat"
|
@"https://github.com/Chocolate4U/Iran-v2ray-rules/releases/latest/download/{0}.dat"
|
||||||
];
|
];
|
||||||
|
|
||||||
public static readonly List<string> SingboxRulesetSources =
|
public static readonly List<string> SingboxRulesetSources =
|
||||||
@@ -519,5 +520,4 @@ namespace ServiceLib
|
|||||||
];
|
];
|
||||||
|
|
||||||
#endregion const
|
#endregion const
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler
|
namespace ServiceLib.Handler;
|
||||||
|
|
||||||
|
public sealed class AppHandler
|
||||||
{
|
{
|
||||||
public sealed class AppHandler
|
|
||||||
{
|
|
||||||
#region Property
|
#region Property
|
||||||
|
|
||||||
private static readonly Lazy<AppHandler> _instance = new(() => new());
|
private static readonly Lazy<AppHandler> _instance = new(() => new());
|
||||||
@@ -80,6 +80,10 @@ namespace ServiceLib.Handler
|
|||||||
Logging.SaveLog($"v2rayN start up | {Utils.GetRuntimeInfo()}");
|
Logging.SaveLog($"v2rayN start up | {Utils.GetRuntimeInfo()}");
|
||||||
Logging.LoggingEnabled(_config.GuiItem.EnableLog);
|
Logging.LoggingEnabled(_config.GuiItem.EnableLog);
|
||||||
|
|
||||||
|
//First determine the port value
|
||||||
|
_ = StatePort;
|
||||||
|
_ = StatePort2;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,5 +244,4 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion Core Type
|
#endregion Core Type
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace ServiceLib.Handler
|
namespace ServiceLib.Handler;
|
||||||
|
|
||||||
|
public static class AutoStartupHandler
|
||||||
{
|
{
|
||||||
public static class AutoStartupHandler
|
|
||||||
{
|
|
||||||
private static readonly string _tag = "AutoStartupHandler";
|
private static readonly string _tag = "AutoStartupHandler";
|
||||||
|
|
||||||
public static async Task<bool> UpdateTask(Config config)
|
public static async Task<bool> UpdateTask(Config config)
|
||||||
@@ -238,5 +238,4 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion macOS
|
#endregion macOS
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using static ServiceLib.Models.ClashProxies;
|
using static ServiceLib.Models.ClashProxies;
|
||||||
|
|
||||||
namespace ServiceLib.Handler
|
namespace ServiceLib.Handler;
|
||||||
|
|
||||||
|
public sealed class ClashApiHandler
|
||||||
{
|
{
|
||||||
public sealed class ClashApiHandler
|
|
||||||
{
|
|
||||||
private static readonly Lazy<ClashApiHandler> instance = new(() => new());
|
private static readonly Lazy<ClashApiHandler> instance = new(() => new());
|
||||||
public static ClashApiHandler Instance => instance.Value;
|
public static ClashApiHandler Instance => instance.Value;
|
||||||
|
|
||||||
@@ -11,9 +11,9 @@ namespace ServiceLib.Handler
|
|||||||
private Dictionary<string, ProxiesItem>? _proxies;
|
private Dictionary<string, ProxiesItem>? _proxies;
|
||||||
public Dictionary<string, object> ProfileContent { get; set; }
|
public Dictionary<string, object> ProfileContent { get; set; }
|
||||||
|
|
||||||
public async Task<Tuple<ClashProxies, ClashProviders>?> GetClashProxiesAsync(Config config)
|
public async Task<Tuple<ClashProxies, ClashProviders>?> GetClashProxiesAsync()
|
||||||
{
|
{
|
||||||
for (var i = 0; i < 5; i++)
|
for (var i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
var url = $"{GetApiUrl()}/proxies";
|
var url = $"{GetApiUrl()}/proxies";
|
||||||
var result = await HttpClientHelper.Instance.TryGetAsync(url);
|
var result = await HttpClientHelper.Instance.TryGetAsync(url);
|
||||||
@@ -41,34 +41,26 @@ namespace ServiceLib.Handler
|
|||||||
{
|
{
|
||||||
if (blAll)
|
if (blAll)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < 5; i++)
|
|
||||||
{
|
|
||||||
if (_proxies != null)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
await Task.Delay(5000);
|
|
||||||
}
|
|
||||||
if (_proxies == null)
|
if (_proxies == null)
|
||||||
{
|
{
|
||||||
return;
|
await GetClashProxiesAsync();
|
||||||
}
|
}
|
||||||
lstProxy = new List<ClashProxyModel>();
|
lstProxy = new List<ClashProxyModel>();
|
||||||
foreach (var kv in _proxies)
|
foreach (var kv in _proxies ?? [])
|
||||||
{
|
{
|
||||||
if (Global.notAllowTestType.Contains(kv.Value.type.ToLower()))
|
if (Global.notAllowTestType.Contains(kv.Value.type?.ToLower()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
lstProxy.Add(new ClashProxyModel()
|
lstProxy.Add(new ClashProxyModel()
|
||||||
{
|
{
|
||||||
Name = kv.Value.name,
|
Name = kv.Value.name,
|
||||||
Type = kv.Value.type.ToLower(),
|
Type = kv.Value.type?.ToLower(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lstProxy == null)
|
if (lstProxy is not { Count: > 0 })
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -157,7 +149,7 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ClashConnections?> GetClashConnectionsAsync(Config config)
|
public async Task<ClashConnections?> GetClashConnectionsAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -192,5 +184,4 @@ namespace ServiceLib.Handler
|
|||||||
{
|
{
|
||||||
return $"{Global.HttpProtocol}{Global.Loopback}:{AppHandler.Instance.StatePort2}";
|
return $"{Global.HttpProtocol}{Global.Loopback}:{AppHandler.Instance.StatePort2}";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,22 @@
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace ServiceLib.Handler
|
namespace ServiceLib.Handler;
|
||||||
|
|
||||||
|
public class ConfigHandler
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 本软件配置文件处理类
|
|
||||||
/// </summary>
|
|
||||||
public class ConfigHandler
|
|
||||||
{
|
|
||||||
private static readonly string _configRes = Global.ConfigFileName;
|
private static readonly string _configRes = Global.ConfigFileName;
|
||||||
private static readonly string _tag = "ConfigHandler";
|
private static readonly string _tag = "ConfigHandler";
|
||||||
|
|
||||||
#region ConfigHandler
|
#region ConfigHandler
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 载入配置文件
|
/// Load the application configuration file
|
||||||
|
/// If the file exists, deserialize it from JSON
|
||||||
|
/// If not found, create a new Config object with default settings
|
||||||
|
/// Initialize default values for missing configuration sections
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <returns>Config object containing application settings or null if there's an error</returns>
|
||||||
/// <returns></returns>
|
|
||||||
public static Config? LoadConfig()
|
public static Config? LoadConfig()
|
||||||
{
|
{
|
||||||
Config? config = null;
|
Config? config = null;
|
||||||
@@ -169,10 +168,11 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保参数
|
/// Save the configuration to a file
|
||||||
|
/// First writes to a temporary file, then replaces the original file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Configuration object to be saved</param>
|
||||||
/// <returns></returns>
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> SaveConfig(Config config)
|
public static async Task<int> SaveConfig(Config config)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -204,6 +204,13 @@ namespace ServiceLib.Handler
|
|||||||
|
|
||||||
#region Server
|
#region Server
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add a server profile to the configuration
|
||||||
|
/// Dispatches the request to the appropriate method based on the config type
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="profileItem">Server profile to add</param>
|
||||||
|
/// <returns>Result of the operation (0 if successful, -1 if failed)</returns>
|
||||||
public static async Task<int> AddServer(Config config, ProfileItem profileItem)
|
public static async Task<int> AddServer(Config config, ProfileItem profileItem)
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetProfileItem(profileItem.IndexId);
|
var item = await AppHandler.Instance.GetProfileItem(profileItem.IndexId);
|
||||||
@@ -258,11 +265,13 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add or edit server
|
/// Add or edit a VMess server
|
||||||
|
/// Validates and processes VMess-specific settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="profileItem"></param>
|
/// <param name="profileItem">VMess profile to add</param>
|
||||||
/// <returns></returns>
|
/// <param name="toFile">Whether to save to file</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> AddVMessServer(Config config, ProfileItem profileItem, bool toFile = true)
|
public static async Task<int> AddVMessServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||||
{
|
{
|
||||||
profileItem.ConfigType = EConfigType.VMess;
|
profileItem.ConfigType = EConfigType.VMess;
|
||||||
@@ -291,11 +300,11 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 移除服务器
|
/// Remove multiple servers from the configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="indexes"></param>
|
/// <param name="indexes">List of server profiles to remove</param>
|
||||||
/// <returns></returns>
|
/// <returns>0 if successful</returns>
|
||||||
public static async Task<int> RemoveServers(Config config, List<ProfileItem> indexes)
|
public static async Task<int> RemoveServers(Config config, List<ProfileItem> indexes)
|
||||||
{
|
{
|
||||||
var subid = "TempRemoveSubId";
|
var subid = "TempRemoveSubId";
|
||||||
@@ -311,11 +320,12 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 克隆服务器
|
/// Clone server profiles
|
||||||
|
/// Creates copies of the specified server profiles with "-clone" appended to the remarks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="index"></param>
|
/// <param name="indexes">List of server profiles to clone</param>
|
||||||
/// <returns></returns>
|
/// <returns>0 if successful</returns>
|
||||||
public static async Task<int> CopyServer(Config config, List<ProfileItem> indexes)
|
public static async Task<int> CopyServer(Config config, List<ProfileItem> indexes)
|
||||||
{
|
{
|
||||||
foreach (var it in indexes)
|
foreach (var it in indexes)
|
||||||
@@ -347,11 +357,12 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置活动服务器
|
/// Set the default server by its index ID
|
||||||
|
/// Updates the configuration to use the specified server as default
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="item"></param>
|
/// <param name="indexId">Index ID of the server to set as default</param>
|
||||||
/// <returns></returns>
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> SetDefaultServerIndex(Config config, string? indexId)
|
public static async Task<int> SetDefaultServerIndex(Config config, string? indexId)
|
||||||
{
|
{
|
||||||
if (indexId.IsNullOrEmpty())
|
if (indexId.IsNullOrEmpty())
|
||||||
@@ -366,6 +377,13 @@ namespace ServiceLib.Handler
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set a default server from the provided list of profiles
|
||||||
|
/// Ensures there's always a valid default server selected
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="lstProfile">List of profile models to choose from</param>
|
||||||
|
/// <returns>Result of SetDefaultServerIndex operation</returns>
|
||||||
public static async Task<int> SetDefaultServer(Config config, List<ProfileItemModel> lstProfile)
|
public static async Task<int> SetDefaultServer(Config config, List<ProfileItemModel> lstProfile)
|
||||||
{
|
{
|
||||||
if (lstProfile.Exists(t => t.IndexId == config.IndexId))
|
if (lstProfile.Exists(t => t.IndexId == config.IndexId))
|
||||||
@@ -386,6 +404,12 @@ namespace ServiceLib.Handler
|
|||||||
return await SetDefaultServerIndex(config, item?.IndexId);
|
return await SetDefaultServerIndex(config, item?.IndexId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the current default server profile
|
||||||
|
/// If the current default is invalid, selects a new default
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <returns>The default profile item or null if none exists</returns>
|
||||||
public static async Task<ProfileItem?> GetDefaultServer(Config config)
|
public static async Task<ProfileItem?> GetDefaultServer(Config config)
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetProfileItem(config.IndexId);
|
var item = await AppHandler.Instance.GetProfileItem(config.IndexId);
|
||||||
@@ -400,13 +424,15 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 移动服务器
|
/// Move a server in the list to a different position
|
||||||
|
/// Supports moving to top, up, down, bottom or specific position
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="lstProfile"></param>
|
/// <param name="lstProfile">List of server profiles</param>
|
||||||
/// <param name="index"></param>
|
/// <param name="index">Index of the server to move</param>
|
||||||
/// <param name="eMove"></param>
|
/// <param name="eMove">Direction to move the server</param>
|
||||||
/// <returns></returns>
|
/// <param name="pos">Target position when using EMove.Position</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> MoveServer(Config config, List<ProfileItem> lstProfile, int index, EMove eMove, int pos = -1)
|
public static async Task<int> MoveServer(Config config, List<ProfileItem> lstProfile, int index, EMove eMove, int pos = -1)
|
||||||
{
|
{
|
||||||
int count = lstProfile.Count;
|
int count = lstProfile.Count;
|
||||||
@@ -474,11 +500,13 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加自定义服务器
|
/// Add a custom server configuration from a file
|
||||||
|
/// Copies the configuration file to the app's config directory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="profileItem"></param>
|
/// <param name="profileItem">Profile item with the file path in Address</param>
|
||||||
/// <returns></returns>
|
/// <param name="blDelete">Whether to delete the source file after copying</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> AddCustomServer(Config config, ProfileItem profileItem, bool blDelete)
|
public static async Task<int> AddCustomServer(Config config, ProfileItem profileItem, bool blDelete)
|
||||||
{
|
{
|
||||||
var fileName = profileItem.Address;
|
var fileName = profileItem.Address;
|
||||||
@@ -517,11 +545,12 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add or edit server
|
/// Edit an existing custom server configuration
|
||||||
|
/// Updates the server's properties without changing the file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="profileItem"></param>
|
/// <param name="profileItem">Profile item with updated properties</param>
|
||||||
/// <returns></returns>
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> EditCustomServer(Config config, ProfileItem profileItem)
|
public static async Task<int> EditCustomServer(Config config, ProfileItem profileItem)
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetProfileItem(profileItem.IndexId);
|
var item = await AppHandler.Instance.GetProfileItem(profileItem.IndexId);
|
||||||
@@ -551,11 +580,13 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add or edit server
|
/// Add or edit a Shadowsocks server
|
||||||
|
/// Validates and processes Shadowsocks-specific settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="profileItem"></param>
|
/// <param name="profileItem">Shadowsocks profile to add</param>
|
||||||
/// <returns></returns>
|
/// <param name="toFile">Whether to save to file</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> AddShadowsocksServer(Config config, ProfileItem profileItem, bool toFile = true)
|
public static async Task<int> AddShadowsocksServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||||
{
|
{
|
||||||
profileItem.ConfigType = EConfigType.Shadowsocks;
|
profileItem.ConfigType = EConfigType.Shadowsocks;
|
||||||
@@ -579,11 +610,13 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add or edit server
|
/// Add or edit a SOCKS server
|
||||||
|
/// Processes SOCKS-specific settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="profileItem"></param>
|
/// <param name="profileItem">SOCKS profile to add</param>
|
||||||
/// <returns></returns>
|
/// <param name="toFile">Whether to save to file</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> AddSocksServer(Config config, ProfileItem profileItem, bool toFile = true)
|
public static async Task<int> AddSocksServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||||
{
|
{
|
||||||
profileItem.ConfigType = EConfigType.SOCKS;
|
profileItem.ConfigType = EConfigType.SOCKS;
|
||||||
@@ -596,11 +629,13 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add or edit server
|
/// Add or edit an HTTP server
|
||||||
|
/// Processes HTTP-specific settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="profileItem"></param>
|
/// <param name="profileItem">HTTP profile to add</param>
|
||||||
/// <returns></returns>
|
/// <param name="toFile">Whether to save to file</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> AddHttpServer(Config config, ProfileItem profileItem, bool toFile = true)
|
public static async Task<int> AddHttpServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||||
{
|
{
|
||||||
profileItem.ConfigType = EConfigType.HTTP;
|
profileItem.ConfigType = EConfigType.HTTP;
|
||||||
@@ -613,11 +648,13 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add or edit server
|
/// Add or edit a Trojan server
|
||||||
|
/// Validates and processes Trojan-specific settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="profileItem"></param>
|
/// <param name="profileItem">Trojan profile to add</param>
|
||||||
/// <returns></returns>
|
/// <param name="toFile">Whether to save to file</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> AddTrojanServer(Config config, ProfileItem profileItem, bool toFile = true)
|
public static async Task<int> AddTrojanServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||||
{
|
{
|
||||||
profileItem.ConfigType = EConfigType.Trojan;
|
profileItem.ConfigType = EConfigType.Trojan;
|
||||||
@@ -639,11 +676,14 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add or edit server
|
/// Add or edit a Hysteria2 server
|
||||||
|
/// Validates and processes Hysteria2-specific settings
|
||||||
|
/// Sets the core type to sing_box as required by Hysteria2
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="profileItem"></param>
|
/// <param name="profileItem">Hysteria2 profile to add</param>
|
||||||
/// <returns></returns>
|
/// <param name="toFile">Whether to save to file</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> AddHysteria2Server(Config config, ProfileItem profileItem, bool toFile = true)
|
public static async Task<int> AddHysteria2Server(Config config, ProfileItem profileItem, bool toFile = true)
|
||||||
{
|
{
|
||||||
profileItem.ConfigType = EConfigType.Hysteria2;
|
profileItem.ConfigType = EConfigType.Hysteria2;
|
||||||
@@ -669,11 +709,14 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add or edit server
|
/// Add or edit a TUIC server
|
||||||
|
/// Validates and processes TUIC-specific settings
|
||||||
|
/// Sets the core type to sing_box as required by TUIC
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="profileItem"></param>
|
/// <param name="profileItem">TUIC profile to add</param>
|
||||||
/// <returns></returns>
|
/// <param name="toFile">Whether to save to file</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> AddTuicServer(Config config, ProfileItem profileItem, bool toFile = true)
|
public static async Task<int> AddTuicServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||||
{
|
{
|
||||||
profileItem.ConfigType = EConfigType.TUIC;
|
profileItem.ConfigType = EConfigType.TUIC;
|
||||||
@@ -708,15 +751,16 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add or edit server
|
/// Add or edit a WireGuard server
|
||||||
|
/// Validates and processes WireGuard-specific settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="profileItem"></param>
|
/// <param name="profileItem">WireGuard profile to add</param>
|
||||||
/// <returns></returns>
|
/// <param name="toFile">Whether to save to file</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> AddWireguardServer(Config config, ProfileItem profileItem, bool toFile = true)
|
public static async Task<int> AddWireguardServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||||
{
|
{
|
||||||
profileItem.ConfigType = EConfigType.WireGuard;
|
profileItem.ConfigType = EConfigType.WireGuard;
|
||||||
profileItem.CoreType = ECoreType.sing_box;
|
|
||||||
|
|
||||||
profileItem.Address = profileItem.Address.TrimEx();
|
profileItem.Address = profileItem.Address.TrimEx();
|
||||||
profileItem.Id = profileItem.Id.TrimEx();
|
profileItem.Id = profileItem.Id.TrimEx();
|
||||||
@@ -739,6 +783,15 @@ namespace ServiceLib.Handler
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sort the server list by the specified column
|
||||||
|
/// Updates the sort order in the profile extension data
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="subId">Subscription ID to filter servers</param>
|
||||||
|
/// <param name="colName">Column name to sort by</param>
|
||||||
|
/// <param name="asc">Sort in ascending order if true, descending if false</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> SortServers(Config config, string subId, string colName, bool asc)
|
public static async Task<int> SortServers(Config config, string subId, string colName, bool asc)
|
||||||
{
|
{
|
||||||
var lstModel = await AppHandler.Instance.ProfileItems(subId, "");
|
var lstModel = await AppHandler.Instance.ProfileItems(subId, "");
|
||||||
@@ -832,11 +885,13 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add or edit server
|
/// Add or edit a VLESS server
|
||||||
|
/// Validates and processes VLESS-specific settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="profileItem"></param>
|
/// <param name="profileItem">VLESS profile to add</param>
|
||||||
/// <returns></returns>
|
/// <param name="toFile">Whether to save to file</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> AddVlessServer(Config config, ProfileItem profileItem, bool toFile = true)
|
public static async Task<int> AddVlessServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||||
{
|
{
|
||||||
profileItem.ConfigType = EConfigType.VLESS;
|
profileItem.ConfigType = EConfigType.VLESS;
|
||||||
@@ -868,16 +923,29 @@ namespace ServiceLib.Handler
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove duplicate servers from a subscription
|
||||||
|
/// Compares servers based on their properties rather than just names
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="subId">Subscription ID to deduplicate</param>
|
||||||
|
/// <returns>Tuple with total count and remaining count after deduplication</returns>
|
||||||
public static async Task<Tuple<int, int>> DedupServerList(Config config, string subId)
|
public static async Task<Tuple<int, int>> DedupServerList(Config config, string subId)
|
||||||
{
|
{
|
||||||
var lstProfile = await AppHandler.Instance.ProfileItems(subId);
|
var lstProfile = await AppHandler.Instance.ProfileItems(subId);
|
||||||
|
if (lstProfile == null)
|
||||||
|
{
|
||||||
|
return new Tuple<int, int>(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
List<ProfileItem> lstKeep = new();
|
List<ProfileItem> lstKeep = new();
|
||||||
List<ProfileItem> lstRemove = new();
|
List<ProfileItem> lstRemove = new();
|
||||||
if (!config.GuiItem.KeepOlderDedupl)
|
if (!config.GuiItem.KeepOlderDedupl)
|
||||||
|
{
|
||||||
lstProfile.Reverse();
|
lstProfile.Reverse();
|
||||||
|
}
|
||||||
|
|
||||||
foreach (ProfileItem item in lstProfile)
|
foreach (var item in lstProfile)
|
||||||
{
|
{
|
||||||
if (!lstKeep.Exists(i => CompareProfileItem(i, item, false)))
|
if (!lstKeep.Exists(i => CompareProfileItem(i, item, false)))
|
||||||
{
|
{
|
||||||
@@ -893,6 +961,14 @@ namespace ServiceLib.Handler
|
|||||||
return new Tuple<int, int>(lstProfile.Count, lstKeep.Count);
|
return new Tuple<int, int>(lstProfile.Count, lstKeep.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Common server addition logic used by all server types
|
||||||
|
/// Sets common properties and handles sorting and persistence
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="profileItem">Profile item to add</param>
|
||||||
|
/// <param name="toFile">Whether to save to database</param>
|
||||||
|
/// <returns>0 if successful</returns>
|
||||||
public static async Task<int> AddServerCommon(Config config, ProfileItem profileItem, bool toFile = true)
|
public static async Task<int> AddServerCommon(Config config, ProfileItem profileItem, bool toFile = true)
|
||||||
{
|
{
|
||||||
profileItem.ConfigVersion = 2;
|
profileItem.ConfigVersion = 2;
|
||||||
@@ -944,7 +1020,15 @@ namespace ServiceLib.Handler
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool CompareProfileItem(ProfileItem o, ProfileItem n, bool remarks)
|
/// <summary>
|
||||||
|
/// Compare two profile items to determine if they represent the same server
|
||||||
|
/// Used for deduplication and server matching
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="o">First profile item</param>
|
||||||
|
/// <param name="n">Second profile item</param>
|
||||||
|
/// <param name="remarks">Whether to compare remarks</param>
|
||||||
|
/// <returns>True if the profiles match, false otherwise</returns>
|
||||||
|
private static bool CompareProfileItem(ProfileItem? o, ProfileItem? n, bool remarks)
|
||||||
{
|
{
|
||||||
if (o == null || n == null)
|
if (o == null || n == null)
|
||||||
{
|
{
|
||||||
@@ -952,24 +1036,36 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
return o.ConfigType == n.ConfigType
|
return o.ConfigType == n.ConfigType
|
||||||
&& o.Address == n.Address
|
&& AreEqual(o.Address, n.Address)
|
||||||
&& o.Port == n.Port
|
&& o.Port == n.Port
|
||||||
&& o.Id == n.Id
|
&& AreEqual(o.Id, n.Id)
|
||||||
&& o.Security == n.Security
|
&& AreEqual(o.Security, n.Security)
|
||||||
&& o.Network == n.Network
|
&& AreEqual(o.Network, n.Network)
|
||||||
&& o.HeaderType == n.HeaderType
|
&& AreEqual(o.HeaderType, n.HeaderType)
|
||||||
&& o.RequestHost == n.RequestHost
|
&& AreEqual(o.RequestHost, n.RequestHost)
|
||||||
&& o.Path == n.Path
|
&& AreEqual(o.Path, n.Path)
|
||||||
&& (o.ConfigType == EConfigType.Trojan || o.StreamSecurity == n.StreamSecurity)
|
&& (o.ConfigType == EConfigType.Trojan || o.StreamSecurity == n.StreamSecurity)
|
||||||
&& o.Flow == n.Flow
|
&& AreEqual(o.Flow, n.Flow)
|
||||||
&& o.Sni == n.Sni
|
&& AreEqual(o.Sni, n.Sni)
|
||||||
&& o.Alpn == n.Alpn
|
&& AreEqual(o.Alpn, n.Alpn)
|
||||||
&& o.Fingerprint == n.Fingerprint
|
&& AreEqual(o.Fingerprint, n.Fingerprint)
|
||||||
&& o.PublicKey == n.PublicKey
|
&& AreEqual(o.PublicKey, n.PublicKey)
|
||||||
&& o.ShortId == n.ShortId
|
&& AreEqual(o.ShortId, n.ShortId)
|
||||||
&& (!remarks || o.Remarks == n.Remarks);
|
&& (!remarks || o.Remarks == n.Remarks);
|
||||||
|
|
||||||
|
static bool AreEqual(string? a, string? b)
|
||||||
|
{
|
||||||
|
return string.Equals(a, b) || (string.IsNullOrEmpty(a) && string.IsNullOrEmpty(b));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove a single server profile by its index ID
|
||||||
|
/// Deletes the configuration file if it's a custom config
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="indexId">Index ID of the profile to remove</param>
|
||||||
|
/// <returns>0 if successful</returns>
|
||||||
private static async Task<int> RemoveProfileItem(Config config, string indexId)
|
private static async Task<int> RemoveProfileItem(Config config, string indexId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -994,26 +1090,48 @@ namespace ServiceLib.Handler
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<RetResult> AddCustomServer4Multiple(Config config, List<ProfileItem> selecteds, ECoreType coreType)
|
/// <summary>
|
||||||
|
/// Create a custom server that combines multiple servers for load balancing
|
||||||
|
/// Generates a configuration file that references multiple servers
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="selecteds">Selected servers to combine</param>
|
||||||
|
/// <param name="coreType">Core type to use (Xray or sing_box)</param>
|
||||||
|
/// <param name="multipleLoad">Load balancing algorithm</param>
|
||||||
|
/// <returns>Result object with success state and data</returns>
|
||||||
|
public static async Task<RetResult> AddCustomServer4Multiple(Config config, List<ProfileItem> selecteds, ECoreType coreType, EMultipleLoad multipleLoad)
|
||||||
{
|
{
|
||||||
var indexId = Utils.GetMd5(Global.CoreMultipleLoadConfigFileName);
|
var indexId = Utils.GetMd5(Global.CoreMultipleLoadConfigFileName);
|
||||||
var configPath = Utils.GetConfigPath(Global.CoreMultipleLoadConfigFileName);
|
var configPath = Utils.GetConfigPath(Global.CoreMultipleLoadConfigFileName);
|
||||||
|
|
||||||
var result = await CoreConfigHandler.GenerateClientMultipleLoadConfig(config, configPath, selecteds, coreType);
|
var result = await CoreConfigHandler.GenerateClientMultipleLoadConfig(config, configPath, selecteds, coreType, multipleLoad);
|
||||||
if (result.Success != true)
|
if (result.Success != true)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileName = configPath;
|
if (!File.Exists(configPath))
|
||||||
if (!File.Exists(fileName))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
var profileItem = await AppHandler.Instance.GetProfileItem(indexId) ?? new();
|
var profileItem = await AppHandler.Instance.GetProfileItem(indexId) ?? new();
|
||||||
profileItem.IndexId = indexId;
|
profileItem.IndexId = indexId;
|
||||||
profileItem.Remarks = coreType == ECoreType.sing_box ? ResUI.menuSetDefaultMultipleServer : ResUI.menuSetDefaultLoadBalanceServer;
|
if (coreType == ECoreType.Xray)
|
||||||
|
{
|
||||||
|
profileItem.Remarks = multipleLoad switch
|
||||||
|
{
|
||||||
|
EMultipleLoad.Random => ResUI.menuSetDefaultMultipleServerXrayRandom,
|
||||||
|
EMultipleLoad.RoundRobin => ResUI.menuSetDefaultMultipleServerXrayRoundRobin,
|
||||||
|
EMultipleLoad.LeastPing => ResUI.menuSetDefaultMultipleServerXrayLeastPing,
|
||||||
|
EMultipleLoad.LeastLoad => ResUI.menuSetDefaultMultipleServerXrayLeastLoad,
|
||||||
|
_ => ResUI.menuSetDefaultMultipleServerXrayRoundRobin,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else if (coreType == ECoreType.sing_box)
|
||||||
|
{
|
||||||
|
profileItem.Remarks = ResUI.menuSetDefaultMultipleServerSingBoxLeastPing;
|
||||||
|
}
|
||||||
profileItem.Address = Global.CoreMultipleLoadConfigFileName;
|
profileItem.Address = Global.CoreMultipleLoadConfigFileName;
|
||||||
profileItem.ConfigType = EConfigType.Custom;
|
profileItem.ConfigType = EConfigType.Custom;
|
||||||
profileItem.CoreType = coreType;
|
profileItem.CoreType = coreType;
|
||||||
@@ -1024,6 +1142,14 @@ namespace ServiceLib.Handler
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a SOCKS server profile for pre-SOCKS functionality
|
||||||
|
/// Used when TUN mode is enabled or when a custom config has a pre-SOCKS port
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="node">Server node that might need pre-SOCKS</param>
|
||||||
|
/// <param name="coreType">Core type being used</param>
|
||||||
|
/// <returns>A SOCKS profile item or null if not needed</returns>
|
||||||
public static async Task<ProfileItem?> GetPreSocksItem(Config config, ProfileItem node, ECoreType coreType)
|
public static async Task<ProfileItem?> GetPreSocksItem(Config config, ProfileItem node, ECoreType coreType)
|
||||||
{
|
{
|
||||||
ProfileItem? itemSocks = null;
|
ProfileItem? itemSocks = null;
|
||||||
@@ -1053,6 +1179,13 @@ namespace ServiceLib.Handler
|
|||||||
return itemSocks;
|
return itemSocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove servers with invalid test results (timeout)
|
||||||
|
/// Useful for cleaning up subscription lists
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="subid">Subscription ID to filter servers</param>
|
||||||
|
/// <returns>Number of removed servers or -1 if failed</returns>
|
||||||
public static async Task<int> RemoveInvalidServerResult(Config config, string subid)
|
public static async Task<int> RemoveInvalidServerResult(Config config, string subid)
|
||||||
{
|
{
|
||||||
var lstModel = await AppHandler.Instance.ProfileItems(subid, "");
|
var lstModel = await AppHandler.Instance.ProfileItems(subid, "");
|
||||||
@@ -1076,12 +1209,14 @@ namespace ServiceLib.Handler
|
|||||||
#region Batch add servers
|
#region Batch add servers
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 批量添加服务器
|
/// Add multiple servers from string data (common protocols)
|
||||||
|
/// Parses the string data into server profiles
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="strData"></param>
|
/// <param name="strData">String data containing server information</param>
|
||||||
/// <param name="subid"></param>
|
/// <param name="subid">Subscription ID to associate with the servers</param>
|
||||||
/// <returns>成功导入的数量</returns>
|
/// <param name="isSub">Whether this is from a subscription</param>
|
||||||
|
/// <returns>Number of successfully imported servers or -1 if failed</returns>
|
||||||
private static async Task<int> AddBatchServersCommon(Config config, string strData, string subid, bool isSub)
|
private static async Task<int> AddBatchServersCommon(Config config, string strData, string subid, bool isSub)
|
||||||
{
|
{
|
||||||
if (strData.IsNullOrEmpty())
|
if (strData.IsNullOrEmpty())
|
||||||
@@ -1161,6 +1296,15 @@ namespace ServiceLib.Handler
|
|||||||
return countServers;
|
return countServers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add servers from custom configuration formats (sing-box, v2ray, etc.)
|
||||||
|
/// Handles various configuration formats and imports them as custom configs
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="strData">String data containing server information</param>
|
||||||
|
/// <param name="subid">Subscription ID to associate with the servers</param>
|
||||||
|
/// <param name="isSub">Whether this is from a subscription</param>
|
||||||
|
/// <returns>Number of successfully imported servers or -1 if failed</returns>
|
||||||
private static async Task<int> AddBatchServers4Custom(Config config, string strData, string subid, bool isSub)
|
private static async Task<int> AddBatchServers4Custom(Config config, string strData, string subid, bool isSub)
|
||||||
{
|
{
|
||||||
if (strData.IsNullOrEmpty())
|
if (strData.IsNullOrEmpty())
|
||||||
@@ -1259,6 +1403,15 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add Shadowsocks servers from SIP008 format
|
||||||
|
/// SIP008 is a JSON-based format for Shadowsocks servers
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="strData">String data in SIP008 format</param>
|
||||||
|
/// <param name="subid">Subscription ID to associate with the servers</param>
|
||||||
|
/// <param name="isSub">Whether this is from a subscription</param>
|
||||||
|
/// <returns>Number of successfully imported servers or -1 if failed</returns>
|
||||||
private static async Task<int> AddBatchServers4SsSIP008(Config config, string strData, string subid, bool isSub)
|
private static async Task<int> AddBatchServers4SsSIP008(Config config, string strData, string subid, bool isSub)
|
||||||
{
|
{
|
||||||
if (strData.IsNullOrEmpty())
|
if (strData.IsNullOrEmpty())
|
||||||
@@ -1291,6 +1444,15 @@ namespace ServiceLib.Handler
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Main entry point for adding batch servers from various formats
|
||||||
|
/// Tries different parsing methods to import as many servers as possible
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="strData">String data containing server information</param>
|
||||||
|
/// <param name="subid">Subscription ID to associate with the servers</param>
|
||||||
|
/// <param name="isSub">Whether this is from a subscription</param>
|
||||||
|
/// <returns>Number of successfully imported servers or -1 if failed</returns>
|
||||||
public static async Task<int> AddBatchServers(Config config, string strData, string subid, bool isSub)
|
public static async Task<int> AddBatchServers(Config config, string strData, string subid, bool isSub)
|
||||||
{
|
{
|
||||||
if (strData.IsNullOrEmpty())
|
if (strData.IsNullOrEmpty())
|
||||||
@@ -1363,11 +1525,12 @@ namespace ServiceLib.Handler
|
|||||||
#region Sub & Group
|
#region Sub & Group
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// add sub
|
/// Add a subscription item from URL
|
||||||
|
/// Creates a new subscription with default settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="url"></param>
|
/// <param name="url">Subscription URL</param>
|
||||||
/// <returns></returns>
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> AddSubItem(Config config, string url)
|
public static async Task<int> AddSubItem(Config config, string url)
|
||||||
{
|
{
|
||||||
//already exists
|
//already exists
|
||||||
@@ -1399,6 +1562,12 @@ namespace ServiceLib.Handler
|
|||||||
return await AddSubItem(config, subItem);
|
return await AddSubItem(config, subItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add or update a subscription item
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="subItem">Subscription item to add or update</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> AddSubItem(Config config, SubItem subItem)
|
public static async Task<int> AddSubItem(Config config, SubItem subItem)
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetSubItem(subItem.Id);
|
var item = await AppHandler.Instance.GetSubItem(subItem.Id);
|
||||||
@@ -1450,11 +1619,12 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 移除服务器
|
/// Remove servers associated with a subscription ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config">Current configuration</param>
|
||||||
/// <param name="subid"></param>
|
/// <param name="subid">Subscription ID</param>
|
||||||
/// <returns></returns>
|
/// <param name="isSub">Whether to only remove servers marked as subscription items</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> RemoveServersViaSubid(Config config, string subid, bool isSub)
|
public static async Task<int> RemoveServersViaSubid(Config config, string subid, bool isSub)
|
||||||
{
|
{
|
||||||
if (subid.IsNullOrEmpty())
|
if (subid.IsNullOrEmpty())
|
||||||
@@ -1478,6 +1648,12 @@ namespace ServiceLib.Handler
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete a subscription item and all its associated servers
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="id">Subscription ID to delete</param>
|
||||||
|
/// <returns>0 if successful</returns>
|
||||||
public static async Task<int> DeleteSubItem(Config config, string id)
|
public static async Task<int> DeleteSubItem(Config config, string id)
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetSubItem(id);
|
var item = await AppHandler.Instance.GetSubItem(id);
|
||||||
@@ -1491,6 +1667,13 @@ namespace ServiceLib.Handler
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Move servers to a different group (subscription)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="lstProfile">List of profiles to move</param>
|
||||||
|
/// <param name="subid">Target subscription ID</param>
|
||||||
|
/// <returns>0 if successful</returns>
|
||||||
public static async Task<int> MoveToGroup(Config config, List<ProfileItem> lstProfile, string subid)
|
public static async Task<int> MoveToGroup(Config config, List<ProfileItem> lstProfile, string subid)
|
||||||
{
|
{
|
||||||
foreach (var item in lstProfile)
|
foreach (var item in lstProfile)
|
||||||
@@ -1506,6 +1689,12 @@ namespace ServiceLib.Handler
|
|||||||
|
|
||||||
#region Routing
|
#region Routing
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Save a routing item to the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="item">Routing item to save</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> SaveRoutingItem(Config config, RoutingItem item)
|
public static async Task<int> SaveRoutingItem(Config config, RoutingItem item)
|
||||||
{
|
{
|
||||||
if (item.Id.IsNullOrEmpty())
|
if (item.Id.IsNullOrEmpty())
|
||||||
@@ -1524,11 +1713,11 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// AddBatchRoutingRules
|
/// Add multiple routing rules to a routing item
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="routingItem">Routing item to add rules to</param>
|
||||||
/// <param name="strData"></param>
|
/// <param name="strData">JSON string containing rules data</param>
|
||||||
/// <returns></returns>
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> AddBatchRoutingRules(RoutingItem routingItem, string strData)
|
public static async Task<int> AddBatchRoutingRules(RoutingItem routingItem, string strData)
|
||||||
{
|
{
|
||||||
if (strData.IsNullOrEmpty())
|
if (strData.IsNullOrEmpty())
|
||||||
@@ -1565,12 +1754,14 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// MoveRoutingRule
|
/// Move a routing rule within a rules list
|
||||||
|
/// Supports moving to top, up, down, bottom or specific position
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="routingItem"></param>
|
/// <param name="rules">List of routing rules</param>
|
||||||
/// <param name="index"></param>
|
/// <param name="index">Index of the rule to move</param>
|
||||||
/// <param name="eMove"></param>
|
/// <param name="eMove">Direction to move the rule</param>
|
||||||
/// <returns></returns>
|
/// <param name="pos">Target position when using EMove.Position</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> MoveRoutingRule(List<RulesItem> rules, int index, EMove eMove, int pos = -1)
|
public static async Task<int> MoveRoutingRule(List<RulesItem> rules, int index, EMove eMove, int pos = -1)
|
||||||
{
|
{
|
||||||
int count = rules.Count;
|
int count = rules.Count;
|
||||||
@@ -1641,6 +1832,12 @@ namespace ServiceLib.Handler
|
|||||||
return await Task.FromResult(0);
|
return await Task.FromResult(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set the default routing configuration
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="routingItem">Routing item to set as default</param>
|
||||||
|
/// <returns>0 if successful</returns>
|
||||||
public static async Task<int> SetDefaultRouting(Config config, RoutingItem routingItem)
|
public static async Task<int> SetDefaultRouting(Config config, RoutingItem routingItem)
|
||||||
{
|
{
|
||||||
if (await SQLiteHelper.Instance.TableAsync<RoutingItem>().Where(t => t.Id == routingItem.Id).CountAsync() > 0)
|
if (await SQLiteHelper.Instance.TableAsync<RoutingItem>().Where(t => t.Id == routingItem.Id).CountAsync() > 0)
|
||||||
@@ -1653,6 +1850,12 @@ namespace ServiceLib.Handler
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the current default routing configuration
|
||||||
|
/// If no default is set, selects the first available routing item
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <returns>The default routing item</returns>
|
||||||
public static async Task<RoutingItem> GetDefaultRouting(Config config)
|
public static async Task<RoutingItem> GetDefaultRouting(Config config)
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetRoutingItem(config.RoutingBasicItem.RoutingIndexId);
|
var item = await AppHandler.Instance.GetRoutingItem(config.RoutingBasicItem.RoutingIndexId);
|
||||||
@@ -1666,6 +1869,12 @@ namespace ServiceLib.Handler
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize routing rules from built-in or external templates
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="blImportAdvancedRules">Whether to import advanced rules</param>
|
||||||
|
/// <returns>0 if successful</returns>
|
||||||
public static async Task<int> InitRouting(Config config, bool blImportAdvancedRules = false)
|
public static async Task<int> InitRouting(Config config, bool blImportAdvancedRules = false)
|
||||||
{
|
{
|
||||||
if (config.ConstItem.RouteRulesTemplateSourceUrl.IsNullOrEmpty())
|
if (config.ConstItem.RouteRulesTemplateSourceUrl.IsNullOrEmpty())
|
||||||
@@ -1680,6 +1889,13 @@ namespace ServiceLib.Handler
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize routing rules from external templates
|
||||||
|
/// Downloads and processes routing templates from a URL
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="blImportAdvancedRules">Whether to import advanced rules</param>
|
||||||
|
/// <returns>0 if successful</returns>
|
||||||
public static async Task<int> InitExternalRouting(Config config, bool blImportAdvancedRules = false)
|
public static async Task<int> InitExternalRouting(Config config, bool blImportAdvancedRules = false)
|
||||||
{
|
{
|
||||||
var downloadHandle = new DownloadService();
|
var downloadHandle = new DownloadService();
|
||||||
@@ -1728,6 +1944,13 @@ namespace ServiceLib.Handler
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize built-in routing rules
|
||||||
|
/// Creates default routing configurations (whitelist, blacklist, global)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="blImportAdvancedRules">Whether to import advanced rules</param>
|
||||||
|
/// <returns>0 if successful</returns>
|
||||||
public static async Task<int> InitBuiltinRouting(Config config, bool blImportAdvancedRules = false)
|
public static async Task<int> InitBuiltinRouting(Config config, bool blImportAdvancedRules = false)
|
||||||
{
|
{
|
||||||
var ver = "V3-";
|
var ver = "V3-";
|
||||||
@@ -1781,6 +2004,10 @@ namespace ServiceLib.Handler
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove a routing item from the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="routingItem">Routing item to remove</param>
|
||||||
public static async Task RemoveRoutingItem(RoutingItem routingItem)
|
public static async Task RemoveRoutingItem(RoutingItem routingItem)
|
||||||
{
|
{
|
||||||
await SQLiteHelper.Instance.DeleteAsync(routingItem);
|
await SQLiteHelper.Instance.DeleteAsync(routingItem);
|
||||||
@@ -1790,6 +2017,12 @@ namespace ServiceLib.Handler
|
|||||||
|
|
||||||
#region DNS
|
#region DNS
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize built-in DNS configurations
|
||||||
|
/// Creates default DNS items for V2Ray and sing-box
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <returns>0 if successful</returns>
|
||||||
public static async Task<int> InitBuiltinDNS(Config config)
|
public static async Task<int> InitBuiltinDNS(Config config)
|
||||||
{
|
{
|
||||||
var items = await AppHandler.Instance.DNSItems();
|
var items = await AppHandler.Instance.DNSItems();
|
||||||
@@ -1813,6 +2046,12 @@ namespace ServiceLib.Handler
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Save a DNS item to the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="item">DNS item to save</param>
|
||||||
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> SaveDNSItems(Config config, DNSItem item)
|
public static async Task<int> SaveDNSItems(Config config, DNSItem item)
|
||||||
{
|
{
|
||||||
if (item == null)
|
if (item == null)
|
||||||
@@ -1835,6 +2074,13 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get an external DNS configuration from URL
|
||||||
|
/// Downloads and processes DNS templates
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="type">Core type (Xray or sing-box)</param>
|
||||||
|
/// <param name="url">URL of the DNS template</param>
|
||||||
|
/// <returns>DNS item with configuration from the URL</returns>
|
||||||
public static async Task<DNSItem> GetExternalDNSItem(ECoreType type, string url)
|
public static async Task<DNSItem> GetExternalDNSItem(ECoreType type, string url)
|
||||||
{
|
{
|
||||||
var currentItem = await AppHandler.Instance.GetDNSItem(type);
|
var currentItem = await AppHandler.Instance.GetDNSItem(type);
|
||||||
@@ -1866,6 +2112,13 @@ namespace ServiceLib.Handler
|
|||||||
|
|
||||||
#region Regional Presets
|
#region Regional Presets
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Apply regional presets for geo-specific configurations
|
||||||
|
/// Sets up geo files, routing rules, and DNS for specific regions
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Current configuration</param>
|
||||||
|
/// <param name="type">Type of preset (Default, Russia, Iran)</param>
|
||||||
|
/// <returns>True if successful</returns>
|
||||||
public static async Task<bool> ApplyRegionalPreset(Config config, EPresetType type)
|
public static async Task<bool> ApplyRegionalPreset(Config config, EPresetType type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
@@ -1905,5 +2158,4 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion Regional Presets
|
#endregion Regional Presets
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
namespace ServiceLib.Handler
|
namespace ServiceLib.Handler;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Core configuration file processing class
|
||||||
|
/// </summary>
|
||||||
|
public class CoreConfigHandler
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Core configuration file processing class
|
|
||||||
/// </summary>
|
|
||||||
public class CoreConfigHandler
|
|
||||||
{
|
|
||||||
private static readonly string _tag = "CoreConfigHandler";
|
private static readonly string _tag = "CoreConfigHandler";
|
||||||
|
|
||||||
public static async Task<RetResult> GenerateClientConfig(ProfileItem node, string? fileName)
|
public static async Task<RetResult> GenerateClientConfig(ProfileItem node, string? fileName)
|
||||||
@@ -133,16 +133,16 @@ namespace ServiceLib.Handler
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<RetResult> GenerateClientMultipleLoadConfig(Config config, string fileName, List<ProfileItem> selecteds, ECoreType coreType)
|
public static async Task<RetResult> GenerateClientMultipleLoadConfig(Config config, string fileName, List<ProfileItem> selecteds, ECoreType coreType, EMultipleLoad multipleLoad)
|
||||||
{
|
{
|
||||||
var result = new RetResult();
|
var result = new RetResult();
|
||||||
if (coreType == ECoreType.sing_box)
|
if (coreType == ECoreType.sing_box)
|
||||||
{
|
{
|
||||||
result = await new CoreConfigSingboxService(config).GenerateClientMultipleLoadConfig(selecteds);
|
result = await new CoreConfigSingboxService(config).GenerateClientMultipleLoadConfig(selecteds);
|
||||||
}
|
}
|
||||||
else if (coreType == ECoreType.Xray)
|
else
|
||||||
{
|
{
|
||||||
result = await new CoreConfigV2rayService(config).GenerateClientMultipleLoadConfig(selecteds);
|
result = await new CoreConfigV2rayService(config).GenerateClientMultipleLoadConfig(selecteds, multipleLoad);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.Success != true)
|
if (result.Success != true)
|
||||||
@@ -152,5 +152,4 @@ namespace ServiceLib.Handler
|
|||||||
await File.WriteAllTextAsync(fileName, result.Data.ToString());
|
await File.WriteAllTextAsync(fileName, result.Data.ToString());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace ServiceLib.Handler
|
namespace ServiceLib.Handler;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Core process processing class
|
||||||
|
/// </summary>
|
||||||
|
public class CoreHandler
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Core process processing class
|
|
||||||
/// </summary>
|
|
||||||
public class CoreHandler
|
|
||||||
{
|
|
||||||
private static readonly Lazy<CoreHandler> _instance = new(() => new());
|
private static readonly Lazy<CoreHandler> _instance = new(() => new());
|
||||||
public static CoreHandler Instance => _instance.Value;
|
public static CoreHandler Instance => _instance.Value;
|
||||||
private Config _config;
|
private Config _config;
|
||||||
@@ -24,6 +24,7 @@ namespace ServiceLib.Handler
|
|||||||
|
|
||||||
Environment.SetEnvironmentVariable(Global.V2RayLocalAsset, Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
|
Environment.SetEnvironmentVariable(Global.V2RayLocalAsset, Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
|
||||||
Environment.SetEnvironmentVariable(Global.XrayLocalAsset, Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
|
Environment.SetEnvironmentVariable(Global.XrayLocalAsset, Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
|
||||||
|
Environment.SetEnvironmentVariable(Global.XrayLocalCert, Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
|
||||||
|
|
||||||
//Copy the bin folder to the storage location (for init)
|
//Copy the bin folder to the storage location (for init)
|
||||||
if (Environment.GetEnvironmentVariable(Global.LocalAppData) == "1")
|
if (Environment.GetEnvironmentVariable(Global.LocalAppData) == "1")
|
||||||
@@ -100,7 +101,7 @@ namespace ServiceLib.Handler
|
|||||||
|
|
||||||
public async Task<int> LoadCoreConfigSpeedtest(List<ServerTestItem> selecteds)
|
public async Task<int> LoadCoreConfigSpeedtest(List<ServerTestItem> selecteds)
|
||||||
{
|
{
|
||||||
var coreType = selecteds.Exists(t => t.ConfigType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.WireGuard) ? ECoreType.sing_box : ECoreType.Xray;
|
var coreType = selecteds.Exists(t => t.ConfigType is EConfigType.Hysteria2 or EConfigType.TUIC) ? ECoreType.sing_box : ECoreType.Xray;
|
||||||
var fileName = string.Format(Global.CoreSpeedtestConfigFileName, Utils.GetGuid(false));
|
var fileName = string.Format(Global.CoreSpeedtestConfigFileName, Utils.GetGuid(false));
|
||||||
var configPath = Utils.GetBinConfigPath(fileName);
|
var configPath = Utils.GetBinConfigPath(fileName);
|
||||||
var result = await CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType);
|
var result = await CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType);
|
||||||
@@ -405,5 +406,4 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion Linux
|
#endregion Linux
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler
|
namespace ServiceLib.Handler;
|
||||||
|
|
||||||
|
public sealed class CoreInfoHandler
|
||||||
{
|
{
|
||||||
public sealed class CoreInfoHandler
|
|
||||||
{
|
|
||||||
private static readonly Lazy<CoreInfoHandler> _instance = new(() => new());
|
private static readonly Lazy<CoreInfoHandler> _instance = new(() => new());
|
||||||
private List<CoreInfo>? _coreInfo;
|
private List<CoreInfo>? _coreInfo;
|
||||||
public static CoreInfoHandler Instance => _instance.Value;
|
public static CoreInfoHandler Instance => _instance.Value;
|
||||||
@@ -214,5 +214,4 @@ namespace ServiceLib.Handler
|
|||||||
{
|
{
|
||||||
return $"{Global.GithubUrl}/{Global.CoreUrls[eCoreType]}/releases";
|
return $"{Global.GithubUrl}/{Global.CoreUrls[eCoreType]}/releases";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
|
|
||||||
namespace ServiceLib.Handler.Fmt
|
namespace ServiceLib.Handler.Fmt;
|
||||||
|
|
||||||
|
public class BaseFmt
|
||||||
{
|
{
|
||||||
public class BaseFmt
|
|
||||||
{
|
|
||||||
protected static string GetIpv6(string address)
|
protected static string GetIpv6(string address)
|
||||||
{
|
{
|
||||||
if (Utils.IsIpv6(address))
|
if (Utils.IsIpv6(address))
|
||||||
{
|
{
|
||||||
// 检查地址是否已经被方括号包围,如果没有,则添加方括号
|
// Check if the address is already surrounded by square brackets, if not, add square brackets
|
||||||
return address.StartsWith('[') && address.EndsWith(']') ? address : $"[{address}]";
|
return address.StartsWith('[') && address.EndsWith(']') ? address : $"[{address}]";
|
||||||
}
|
}
|
||||||
return address; // 如果不是IPv6地址,直接返回原地址
|
else
|
||||||
|
{
|
||||||
|
return address;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static int GetStdTransport(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery)
|
protected static int GetStdTransport(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery)
|
||||||
@@ -238,5 +241,4 @@ namespace ServiceLib.Handler.Fmt
|
|||||||
var url = $"{Utils.UrlEncode(userInfo)}@{GetIpv6(address)}:{port}";
|
var url = $"{Utils.UrlEncode(userInfo)}@{GetIpv6(address)}:{port}";
|
||||||
return $"{Global.ProtocolShares[eConfigType]}{url}{query}{remark}";
|
return $"{Global.ProtocolShares[eConfigType]}{url}{query}{remark}";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler.Fmt
|
namespace ServiceLib.Handler.Fmt;
|
||||||
|
|
||||||
|
public class ClashFmt : BaseFmt
|
||||||
{
|
{
|
||||||
public class ClashFmt : BaseFmt
|
|
||||||
{
|
|
||||||
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
|
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
|
||||||
{
|
{
|
||||||
if (Contains(strData, "port", "socks-port", "proxies"))
|
if (Contains(strData, "port", "socks-port", "proxies"))
|
||||||
@@ -19,5 +19,4 @@
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler.Fmt
|
namespace ServiceLib.Handler.Fmt;
|
||||||
|
|
||||||
|
public class FmtHandler
|
||||||
{
|
{
|
||||||
public class FmtHandler
|
|
||||||
{
|
|
||||||
private static readonly string _tag = "FmtHandler";
|
private static readonly string _tag = "FmtHandler";
|
||||||
|
|
||||||
public static string? GetShareUri(ProfileItem item)
|
public static string? GetShareUri(ProfileItem item)
|
||||||
@@ -88,5 +88,4 @@
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler.Fmt
|
namespace ServiceLib.Handler.Fmt;
|
||||||
|
|
||||||
|
public class Hysteria2Fmt : BaseFmt
|
||||||
{
|
{
|
||||||
public class Hysteria2Fmt : BaseFmt
|
|
||||||
{
|
|
||||||
public static ProfileItem? Resolve(string str, out string msg)
|
public static ProfileItem? Resolve(string str, out string msg)
|
||||||
{
|
{
|
||||||
msg = ResUI.ConfigurationFormatIncorrect;
|
msg = ResUI.ConfigurationFormatIncorrect;
|
||||||
@@ -98,5 +98,4 @@ namespace ServiceLib.Handler.Fmt
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler.Fmt
|
namespace ServiceLib.Handler.Fmt;
|
||||||
|
|
||||||
|
public class NaiveproxyFmt : BaseFmt
|
||||||
{
|
{
|
||||||
public class NaiveproxyFmt : BaseFmt
|
|
||||||
{
|
|
||||||
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
|
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
|
||||||
{
|
{
|
||||||
if (Contains(strData, "listen", "proxy", "<html>", "<body>"))
|
if (Contains(strData, "listen", "proxy", "<html>", "<body>"))
|
||||||
@@ -19,5 +19,4 @@
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace ServiceLib.Handler.Fmt
|
namespace ServiceLib.Handler.Fmt;
|
||||||
|
|
||||||
|
public class ShadowsocksFmt : BaseFmt
|
||||||
{
|
{
|
||||||
public class ShadowsocksFmt : BaseFmt
|
|
||||||
{
|
|
||||||
public static ProfileItem? Resolve(string str, out string msg)
|
public static ProfileItem? Resolve(string str, out string msg)
|
||||||
{
|
{
|
||||||
msg = ResUI.ConfigurationFormatIncorrect;
|
msg = ResUI.ConfigurationFormatIncorrect;
|
||||||
@@ -176,5 +176,4 @@ namespace ServiceLib.Handler.Fmt
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +1,39 @@
|
|||||||
namespace ServiceLib.Handler.Fmt
|
namespace ServiceLib.Handler.Fmt;
|
||||||
|
|
||||||
|
public class SingboxFmt : BaseFmt
|
||||||
{
|
{
|
||||||
public class SingboxFmt : BaseFmt
|
|
||||||
{
|
|
||||||
public static List<ProfileItem>? ResolveFullArray(string strData, string? subRemarks)
|
public static List<ProfileItem>? ResolveFullArray(string strData, string? subRemarks)
|
||||||
{
|
{
|
||||||
var configObjects = JsonUtils.Deserialize<object[]>(strData);
|
var configObjects = JsonUtils.Deserialize<object[]>(strData);
|
||||||
if (configObjects != null && configObjects.Length > 0)
|
if (configObjects is not { Length: > 0 })
|
||||||
{
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
List<ProfileItem> lstResult = [];
|
List<ProfileItem> lstResult = [];
|
||||||
foreach (var configObject in configObjects)
|
foreach (var configObject in configObjects)
|
||||||
{
|
{
|
||||||
var objectString = JsonUtils.Serialize(configObject);
|
var objectString = JsonUtils.Serialize(configObject);
|
||||||
var singboxCon = JsonUtils.Deserialize<SingboxConfig>(objectString);
|
var profileIt = ResolveFull(objectString, subRemarks);
|
||||||
if (singboxCon?.inbounds?.Count > 0
|
if (profileIt != null)
|
||||||
&& singboxCon.outbounds?.Count > 0
|
|
||||||
&& singboxCon.route != null)
|
|
||||||
{
|
{
|
||||||
var fileName = WriteAllText(objectString);
|
|
||||||
|
|
||||||
var profileIt = new ProfileItem
|
|
||||||
{
|
|
||||||
CoreType = ECoreType.sing_box,
|
|
||||||
Address = fileName,
|
|
||||||
Remarks = subRemarks ?? "singbox_custom",
|
|
||||||
};
|
|
||||||
lstResult.Add(profileIt);
|
lstResult.Add(profileIt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lstResult;
|
return lstResult;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
|
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
|
||||||
{
|
{
|
||||||
var singboxConfig = JsonUtils.Deserialize<SingboxConfig>(strData);
|
var config = JsonUtils.ParseJson(strData);
|
||||||
if (singboxConfig?.inbounds?.Count > 0
|
if (config?["inbounds"] == null
|
||||||
&& singboxConfig.outbounds?.Count > 0
|
|| config["outbounds"] == null
|
||||||
&& singboxConfig.route != null)
|
|| config["route"] == null
|
||||||
|
|| config["dns"] == null)
|
||||||
{
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var fileName = WriteAllText(strData);
|
var fileName = WriteAllText(strData);
|
||||||
var profileItem = new ProfileItem
|
var profileItem = new ProfileItem
|
||||||
{
|
{
|
||||||
@@ -49,7 +44,4 @@ namespace ServiceLib.Handler.Fmt
|
|||||||
|
|
||||||
return profileItem;
|
return profileItem;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler.Fmt
|
namespace ServiceLib.Handler.Fmt;
|
||||||
|
|
||||||
|
public class SocksFmt : BaseFmt
|
||||||
{
|
{
|
||||||
public class SocksFmt : BaseFmt
|
|
||||||
{
|
|
||||||
public static ProfileItem? Resolve(string str, out string msg)
|
public static ProfileItem? Resolve(string str, out string msg)
|
||||||
{
|
{
|
||||||
msg = ResUI.ConfigurationFormatIncorrect;
|
msg = ResUI.ConfigurationFormatIncorrect;
|
||||||
@@ -111,5 +111,4 @@ namespace ServiceLib.Handler.Fmt
|
|||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler.Fmt
|
namespace ServiceLib.Handler.Fmt;
|
||||||
|
|
||||||
|
public class TrojanFmt : BaseFmt
|
||||||
{
|
{
|
||||||
public class TrojanFmt : BaseFmt
|
|
||||||
{
|
|
||||||
public static ProfileItem? Resolve(string str, out string msg)
|
public static ProfileItem? Resolve(string str, out string msg)
|
||||||
{
|
{
|
||||||
msg = ResUI.ConfigurationFormatIncorrect;
|
msg = ResUI.ConfigurationFormatIncorrect;
|
||||||
@@ -44,5 +44,4 @@ namespace ServiceLib.Handler.Fmt
|
|||||||
|
|
||||||
return ToUri(EConfigType.Trojan, item.Address, item.Port, item.Id, dicQuery, remark);
|
return ToUri(EConfigType.Trojan, item.Address, item.Port, item.Id, dicQuery, remark);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler.Fmt
|
namespace ServiceLib.Handler.Fmt;
|
||||||
|
|
||||||
|
public class TuicFmt : BaseFmt
|
||||||
{
|
{
|
||||||
public class TuicFmt : BaseFmt
|
|
||||||
{
|
|
||||||
public static ProfileItem? Resolve(string str, out string msg)
|
public static ProfileItem? Resolve(string str, out string msg)
|
||||||
{
|
{
|
||||||
msg = ResUI.ConfigurationFormatIncorrect;
|
msg = ResUI.ConfigurationFormatIncorrect;
|
||||||
@@ -60,5 +60,4 @@ namespace ServiceLib.Handler.Fmt
|
|||||||
|
|
||||||
return ToUri(EConfigType.TUIC, item.Address, item.Port, $"{item.Id}:{item.Security}", dicQuery, remark);
|
return ToUri(EConfigType.TUIC, item.Address, item.Port, $"{item.Id}:{item.Security}", dicQuery, remark);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +1,48 @@
|
|||||||
namespace ServiceLib.Handler.Fmt
|
namespace ServiceLib.Handler.Fmt;
|
||||||
|
|
||||||
|
public class V2rayFmt : BaseFmt
|
||||||
{
|
{
|
||||||
public class V2rayFmt : BaseFmt
|
|
||||||
{
|
|
||||||
public static List<ProfileItem>? ResolveFullArray(string strData, string? subRemarks)
|
public static List<ProfileItem>? ResolveFullArray(string strData, string? subRemarks)
|
||||||
{
|
{
|
||||||
var configObjects = JsonUtils.Deserialize<object[]>(strData);
|
var configObjects = JsonUtils.Deserialize<object[]>(strData);
|
||||||
if (configObjects != null && configObjects.Length > 0)
|
if (configObjects is not { Length: > 0 })
|
||||||
{
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
List<ProfileItem> lstResult = [];
|
List<ProfileItem> lstResult = [];
|
||||||
foreach (var configObject in configObjects)
|
foreach (var configObject in configObjects)
|
||||||
{
|
{
|
||||||
var objectString = JsonUtils.Serialize(configObject);
|
var objectString = JsonUtils.Serialize(configObject);
|
||||||
var v2rayCon = JsonUtils.Deserialize<V2rayConfig>(objectString);
|
var profileIt = ResolveFull(objectString, subRemarks);
|
||||||
if (v2rayCon?.inbounds?.Count > 0
|
if (profileIt != null)
|
||||||
&& v2rayCon.outbounds?.Count > 0
|
|
||||||
&& v2rayCon.routing != null)
|
|
||||||
{
|
{
|
||||||
var fileName = WriteAllText(objectString);
|
|
||||||
|
|
||||||
var profileIt = new ProfileItem
|
|
||||||
{
|
|
||||||
CoreType = ECoreType.Xray,
|
|
||||||
Address = fileName,
|
|
||||||
Remarks = v2rayCon.remarks ?? subRemarks ?? "v2ray_custom",
|
|
||||||
};
|
|
||||||
lstResult.Add(profileIt);
|
lstResult.Add(profileIt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return lstResult;
|
return lstResult;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
|
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
|
||||||
{
|
{
|
||||||
var v2rayConfig = JsonUtils.Deserialize<V2rayConfig>(strData);
|
var config = JsonUtils.ParseJson(strData);
|
||||||
if (v2rayConfig?.inbounds?.Count > 0
|
if (config?["inbounds"] == null
|
||||||
&& v2rayConfig.outbounds?.Count > 0
|
|| config["outbounds"] == null
|
||||||
&& v2rayConfig.routing != null)
|
|| config["routing"] == null)
|
||||||
{
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var fileName = WriteAllText(strData);
|
var fileName = WriteAllText(strData);
|
||||||
|
|
||||||
var profileItem = new ProfileItem
|
var profileItem = new ProfileItem
|
||||||
{
|
{
|
||||||
CoreType = ECoreType.Xray,
|
CoreType = ECoreType.Xray,
|
||||||
Address = fileName,
|
Address = fileName,
|
||||||
Remarks = v2rayConfig.remarks ?? subRemarks ?? "v2ray_custom"
|
Remarks = config?["remarks"]?.ToString() ?? subRemarks ?? "v2ray_custom"
|
||||||
};
|
};
|
||||||
|
|
||||||
return profileItem;
|
return profileItem;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler.Fmt
|
namespace ServiceLib.Handler.Fmt;
|
||||||
|
|
||||||
|
public class VLESSFmt : BaseFmt
|
||||||
{
|
{
|
||||||
public class VLESSFmt : BaseFmt
|
|
||||||
{
|
|
||||||
public static ProfileItem? Resolve(string str, out string msg)
|
public static ProfileItem? Resolve(string str, out string msg)
|
||||||
{
|
{
|
||||||
msg = ResUI.ConfigurationFormatIncorrect;
|
msg = ResUI.ConfigurationFormatIncorrect;
|
||||||
@@ -56,5 +56,4 @@ namespace ServiceLib.Handler.Fmt
|
|||||||
|
|
||||||
return ToUri(EConfigType.VLESS, item.Address, item.Port, item.Id, dicQuery, remark);
|
return ToUri(EConfigType.VLESS, item.Address, item.Port, item.Id, dicQuery, remark);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler.Fmt
|
namespace ServiceLib.Handler.Fmt;
|
||||||
|
|
||||||
|
public class VmessFmt : BaseFmt
|
||||||
{
|
{
|
||||||
public class VmessFmt : BaseFmt
|
|
||||||
{
|
|
||||||
public static ProfileItem? Resolve(string str, out string msg)
|
public static ProfileItem? Resolve(string str, out string msg)
|
||||||
{
|
{
|
||||||
msg = ResUI.ConfigurationFormatIncorrect;
|
msg = ResUI.ConfigurationFormatIncorrect;
|
||||||
@@ -122,5 +122,4 @@ namespace ServiceLib.Handler.Fmt
|
|||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler.Fmt
|
namespace ServiceLib.Handler.Fmt;
|
||||||
|
|
||||||
|
public class WireguardFmt : BaseFmt
|
||||||
{
|
{
|
||||||
public class WireguardFmt : BaseFmt
|
|
||||||
{
|
|
||||||
public static ProfileItem? Resolve(string str, out string msg)
|
public static ProfileItem? Resolve(string str, out string msg)
|
||||||
{
|
{
|
||||||
msg = ResUI.ConfigurationFormatIncorrect;
|
msg = ResUI.ConfigurationFormatIncorrect;
|
||||||
@@ -64,5 +64,4 @@ namespace ServiceLib.Handler.Fmt
|
|||||||
}
|
}
|
||||||
return ToUri(EConfigType.WireGuard, item.Address, item.Port, item.Id, dicQuery, remark);
|
return ToUri(EConfigType.WireGuard, item.Address, item.Port, item.Id, dicQuery, remark);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace ServiceLib.Handler
|
namespace ServiceLib.Handler;
|
||||||
|
|
||||||
|
public class NoticeHandler
|
||||||
{
|
{
|
||||||
public class NoticeHandler
|
|
||||||
{
|
|
||||||
private static readonly Lazy<NoticeHandler> _instance = new(() => new());
|
private static readonly Lazy<NoticeHandler> _instance = new(() => new());
|
||||||
public static NoticeHandler Instance => _instance.Value;
|
public static NoticeHandler Instance => _instance.Value;
|
||||||
|
|
||||||
@@ -40,5 +40,4 @@ namespace ServiceLib.Handler
|
|||||||
Enqueue(msg);
|
Enqueue(msg);
|
||||||
SendMessage(msg);
|
SendMessage(msg);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace ServiceLib.Handler
|
namespace ServiceLib.Handler;
|
||||||
|
|
||||||
|
public class PacHandler
|
||||||
{
|
{
|
||||||
public class PacHandler
|
|
||||||
{
|
|
||||||
private static string _configPath;
|
private static string _configPath;
|
||||||
private static int _httpPort;
|
private static int _httpPort;
|
||||||
private static int _pacPort;
|
private static int _pacPort;
|
||||||
@@ -33,6 +33,13 @@ namespace ServiceLib.Handler
|
|||||||
private static async Task InitText()
|
private static async Task InitText()
|
||||||
{
|
{
|
||||||
var path = Path.Combine(_configPath, "pac.txt");
|
var path = Path.Combine(_configPath, "pac.txt");
|
||||||
|
|
||||||
|
// Delete the old pac file
|
||||||
|
if (File.Exists(path) && Utils.GetFileHash(path).Equals("b590c07280f058ef05d5394aa2f927fe"))
|
||||||
|
{
|
||||||
|
File.Delete(path);
|
||||||
|
}
|
||||||
|
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
{
|
{
|
||||||
var pac = EmbedUtils.GetEmbedText(Global.PacFileName);
|
var pac = EmbedUtils.GetEmbedText(Global.PacFileName);
|
||||||
@@ -104,5 +111,4 @@ namespace ServiceLib.Handler
|
|||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ using System.Collections.Concurrent;
|
|||||||
|
|
||||||
//using System.Reactive.Linq;
|
//using System.Reactive.Linq;
|
||||||
|
|
||||||
namespace ServiceLib.Handler
|
namespace ServiceLib.Handler;
|
||||||
|
|
||||||
|
public class ProfileExHandler
|
||||||
{
|
{
|
||||||
public class ProfileExHandler
|
|
||||||
{
|
|
||||||
private static readonly Lazy<ProfileExHandler> _instance = new(() => new());
|
private static readonly Lazy<ProfileExHandler> _instance = new(() => new());
|
||||||
private ConcurrentBag<ProfileExItem> _lstProfileEx = [];
|
private ConcurrentBag<ProfileExItem> _lstProfileEx = [];
|
||||||
private readonly Queue<string> _queIndexIds = new();
|
private readonly Queue<string> _queIndexIds = new();
|
||||||
@@ -178,5 +178,4 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
return _lstProfileEx.Max(t => t == null ? 0 : t.Sort);
|
return _lstProfileEx.Max(t => t == null ? 0 : t.Sort);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler
|
namespace ServiceLib.Handler;
|
||||||
|
|
||||||
|
public class StatisticsHandler
|
||||||
{
|
{
|
||||||
public class StatisticsHandler
|
|
||||||
{
|
|
||||||
private static readonly Lazy<StatisticsHandler> instance = new(() => new());
|
private static readonly Lazy<StatisticsHandler> instance = new(() => new());
|
||||||
public static StatisticsHandler Instance => instance.Value;
|
public static StatisticsHandler Instance => instance.Value;
|
||||||
|
|
||||||
@@ -160,5 +160,4 @@
|
|||||||
_serverStatItem.DateNow = ticks;
|
_serverStatItem.DateNow = ticks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler.SysProxy
|
namespace ServiceLib.Handler.SysProxy;
|
||||||
|
|
||||||
|
public class ProxySettingLinux
|
||||||
{
|
{
|
||||||
public class ProxySettingLinux
|
|
||||||
{
|
|
||||||
private static readonly string _proxySetFileName = $"{Global.ProxySetLinuxShellFileName.Replace(Global.NamespaceSample, "")}.sh";
|
private static readonly string _proxySetFileName = $"{Global.ProxySetLinuxShellFileName.Replace(Global.NamespaceSample, "")}.sh";
|
||||||
|
|
||||||
public static async Task SetProxy(string host, int port, string exceptions)
|
public static async Task SetProxy(string host, int port, string exceptions)
|
||||||
@@ -29,5 +29,4 @@ namespace ServiceLib.Handler.SysProxy
|
|||||||
|
|
||||||
await Utils.GetCliWrapOutput(fileName, args);
|
await Utils.GetCliWrapOutput(fileName, args);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler.SysProxy
|
namespace ServiceLib.Handler.SysProxy;
|
||||||
|
|
||||||
|
public class ProxySettingOSX
|
||||||
{
|
{
|
||||||
public class ProxySettingOSX
|
|
||||||
{
|
|
||||||
private static readonly string _proxySetFileName = $"{Global.ProxySetOSXShellFileName.Replace(Global.NamespaceSample, "")}.sh";
|
private static readonly string _proxySetFileName = $"{Global.ProxySetOSXShellFileName.Replace(Global.NamespaceSample, "")}.sh";
|
||||||
|
|
||||||
public static async Task SetProxy(string host, int port, string exceptions)
|
public static async Task SetProxy(string host, int port, string exceptions)
|
||||||
@@ -34,5 +34,4 @@ namespace ServiceLib.Handler.SysProxy
|
|||||||
|
|
||||||
await Utils.GetCliWrapOutput(fileName, args);
|
await Utils.GetCliWrapOutput(fileName, args);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using static ServiceLib.Handler.SysProxy.ProxySettingWindows.InternetConnectionOption;
|
using static ServiceLib.Handler.SysProxy.ProxySettingWindows.InternetConnectionOption;
|
||||||
|
|
||||||
namespace ServiceLib.Handler.SysProxy
|
namespace ServiceLib.Handler.SysProxy;
|
||||||
|
|
||||||
|
public class ProxySettingWindows
|
||||||
{
|
{
|
||||||
public class ProxySettingWindows
|
|
||||||
{
|
|
||||||
private const string _regPath = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings";
|
private const string _regPath = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings";
|
||||||
|
|
||||||
private static bool SetProxyFallback(string? strProxy, string? exceptions, int type)
|
private static bool SetProxyFallback(string? strProxy, string? exceptions, int type)
|
||||||
@@ -356,5 +356,4 @@ namespace ServiceLib.Handler.SysProxy
|
|||||||
ref int lpcEntries // Number of entries written to the buffer
|
ref int lpcEntries // Number of entries written to the buffer
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler.SysProxy
|
namespace ServiceLib.Handler.SysProxy;
|
||||||
|
|
||||||
|
public static class SysProxyHandler
|
||||||
{
|
{
|
||||||
public static class SysProxyHandler
|
|
||||||
{
|
|
||||||
private static readonly string _tag = "SysProxyHandler";
|
private static readonly string _tag = "SysProxyHandler";
|
||||||
|
|
||||||
public static async Task<bool> UpdateSysProxy(Config config, bool forceDisable)
|
public static async Task<bool> UpdateSysProxy(Config config, bool forceDisable)
|
||||||
@@ -95,5 +95,4 @@
|
|||||||
var strProxy = $"{Global.HttpProtocol}{Global.Loopback}:{portPac}/pac?t={DateTime.Now.Ticks}";
|
var strProxy = $"{Global.HttpProtocol}{Global.Loopback}:{portPac}/pac?t={DateTime.Now.Ticks}";
|
||||||
ProxySettingWindows.SetProxy(strProxy, "", 4);
|
ProxySettingWindows.SetProxy(strProxy, "", 4);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Handler
|
namespace ServiceLib.Handler;
|
||||||
|
|
||||||
|
public class TaskHandler
|
||||||
{
|
{
|
||||||
public class TaskHandler
|
|
||||||
{
|
|
||||||
private static readonly Lazy<TaskHandler> _instance = new(() => new());
|
private static readonly Lazy<TaskHandler> _instance = new(() => new());
|
||||||
public static TaskHandler Instance => _instance.Value;
|
public static TaskHandler Instance => _instance.Value;
|
||||||
|
|
||||||
@@ -94,5 +94,4 @@ namespace ServiceLib.Handler
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using WebDav;
|
using WebDav;
|
||||||
|
|
||||||
namespace ServiceLib.Handler
|
namespace ServiceLib.Handler;
|
||||||
|
|
||||||
|
public sealed class WebDavHandler
|
||||||
{
|
{
|
||||||
public sealed class WebDavHandler
|
|
||||||
{
|
|
||||||
private static readonly Lazy<WebDavHandler> _instance = new(() => new());
|
private static readonly Lazy<WebDavHandler> _instance = new(() => new());
|
||||||
public static WebDavHandler Instance => _instance.Value;
|
public static WebDavHandler Instance => _instance.Value;
|
||||||
|
|
||||||
@@ -178,5 +178,4 @@ namespace ServiceLib.Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string GetLastError() => _lastDescription ?? string.Empty;
|
public string GetLastError() => _lastDescription ?? string.Empty;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
public class CheckUpdateModel
|
||||||
{
|
{
|
||||||
public class CheckUpdateModel
|
|
||||||
{
|
|
||||||
public bool? IsSelected { get; set; }
|
public bool? IsSelected { get; set; }
|
||||||
public string? CoreType { get; set; }
|
public string? CoreType { get; set; }
|
||||||
public string? Remarks { get; set; }
|
public string? Remarks { get; set; }
|
||||||
public string? FileName { get; set; }
|
public string? FileName { get; set; }
|
||||||
public bool? IsFinished { get; set; }
|
public bool? IsFinished { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
public class ClashConnectionModel
|
||||||
{
|
{
|
||||||
public class ClashConnectionModel
|
|
||||||
{
|
|
||||||
public string? Id { get; set; }
|
public string? Id { get; set; }
|
||||||
public string? Network { get; set; }
|
public string? Network { get; set; }
|
||||||
public string? Type { get; set; }
|
public string? Type { get; set; }
|
||||||
@@ -13,5 +13,4 @@
|
|||||||
public double Time { get; set; }
|
public double Time { get; set; }
|
||||||
public string? Elapsed { get; set; }
|
public string? Elapsed { get; set; }
|
||||||
public string? Chain { get; set; }
|
public string? Chain { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
public class ClashConnections
|
||||||
{
|
{
|
||||||
public class ClashConnections
|
|
||||||
{
|
|
||||||
public ulong downloadTotal { get; set; }
|
public ulong downloadTotal { get; set; }
|
||||||
public ulong uploadTotal { get; set; }
|
public ulong uploadTotal { get; set; }
|
||||||
public List<ConnectionItem>? connections { get; set; }
|
public List<ConnectionItem>? connections { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ConnectionItem
|
public class ConnectionItem
|
||||||
{
|
{
|
||||||
public string? id { get; set; }
|
public string? id { get; set; }
|
||||||
public MetadataItem? metadata { get; set; }
|
public MetadataItem? metadata { get; set; }
|
||||||
public ulong upload { get; set; }
|
public ulong upload { get; set; }
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
public List<string>? chains { get; set; }
|
public List<string>? chains { get; set; }
|
||||||
public string? rule { get; set; }
|
public string? rule { get; set; }
|
||||||
public string? rulePayload { get; set; }
|
public string? rulePayload { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MetadataItem
|
public class MetadataItem
|
||||||
{
|
{
|
||||||
public string? network { get; set; }
|
public string? network { get; set; }
|
||||||
public string? type { get; set; }
|
public string? type { get; set; }
|
||||||
public string? sourceIP { get; set; }
|
public string? sourceIP { get; set; }
|
||||||
@@ -33,5 +33,4 @@
|
|||||||
public string? process { get; set; }
|
public string? process { get; set; }
|
||||||
public string? processPath { get; set; }
|
public string? processPath { get; set; }
|
||||||
public string? remoteDestination { get; set; }
|
public string? remoteDestination { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using static ServiceLib.Models.ClashProxies;
|
using static ServiceLib.Models.ClashProxies;
|
||||||
|
|
||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
public class ClashProviders
|
||||||
{
|
{
|
||||||
public class ClashProviders
|
|
||||||
{
|
|
||||||
public Dictionary<string, ProvidersItem>? providers { get; set; }
|
public Dictionary<string, ProvidersItem>? providers { get; set; }
|
||||||
|
|
||||||
public class ProvidersItem
|
public class ProvidersItem
|
||||||
@@ -13,5 +13,4 @@ namespace ServiceLib.Models
|
|||||||
public string? type { get; set; }
|
public string? type { get; set; }
|
||||||
public string? vehicleType { get; set; }
|
public string? vehicleType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
public class ClashProxies
|
||||||
{
|
{
|
||||||
public class ClashProxies
|
|
||||||
{
|
|
||||||
public Dictionary<string, ProxiesItem>? proxies { get; set; }
|
public Dictionary<string, ProxiesItem>? proxies { get; set; }
|
||||||
|
|
||||||
public class ProxiesItem
|
public class ProxiesItem
|
||||||
@@ -20,5 +20,4 @@
|
|||||||
public string? time { get; set; }
|
public string? time { get; set; }
|
||||||
public int delay { get; set; }
|
public int delay { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class ClashProxyModel
|
||||||
{
|
{
|
||||||
[Serializable]
|
|
||||||
public class ClashProxyModel
|
|
||||||
{
|
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
|
|
||||||
public string? Type { get; set; }
|
public string? Type { get; set; }
|
||||||
@@ -14,5 +14,4 @@
|
|||||||
public string? DelayName { get; set; }
|
public string? DelayName { get; set; }
|
||||||
|
|
||||||
public bool IsActive { get; set; }
|
public bool IsActive { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
public class CmdItem
|
||||||
{
|
{
|
||||||
public class CmdItem
|
|
||||||
{
|
|
||||||
public string? Cmd { get; set; }
|
public string? Cmd { get; set; }
|
||||||
public List<string>? Arguments { get; set; }
|
public List<string>? Arguments { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
public class ComboItem
|
||||||
{
|
{
|
||||||
public class ComboItem
|
|
||||||
{
|
|
||||||
public string? ID
|
public string? ID
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
@@ -11,5 +11,4 @@
|
|||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class Config
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 本软件配置文件实体类
|
|
||||||
/// </summary>
|
|
||||||
[Serializable]
|
|
||||||
public class Config
|
|
||||||
{
|
|
||||||
#region property
|
#region property
|
||||||
|
|
||||||
public string IndexId { get; set; }
|
public string IndexId { get; set; }
|
||||||
@@ -53,5 +50,4 @@
|
|||||||
public List<CoreTypeItem> CoreTypeItem { get; set; }
|
public List<CoreTypeItem> CoreTypeItem { get; set; }
|
||||||
|
|
||||||
#endregion other entities
|
#endregion other entities
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class CoreBasicItem
|
||||||
{
|
{
|
||||||
[Serializable]
|
|
||||||
public class CoreBasicItem
|
|
||||||
{
|
|
||||||
public bool LogEnabled { get; set; }
|
public bool LogEnabled { get; set; }
|
||||||
|
|
||||||
public string Loglevel { get; set; }
|
public string Loglevel { get; set; }
|
||||||
@@ -18,11 +18,11 @@ namespace ServiceLib.Models
|
|||||||
public bool EnableFragment { get; set; }
|
public bool EnableFragment { get; set; }
|
||||||
|
|
||||||
public bool EnableCacheFile4Sbox { get; set; } = true;
|
public bool EnableCacheFile4Sbox { get; set; } = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class InItem
|
public class InItem
|
||||||
{
|
{
|
||||||
public int LocalPort { get; set; }
|
public int LocalPort { get; set; }
|
||||||
public string Protocol { get; set; }
|
public string Protocol { get; set; }
|
||||||
public bool UdpEnabled { get; set; }
|
public bool UdpEnabled { get; set; }
|
||||||
@@ -34,11 +34,11 @@ namespace ServiceLib.Models
|
|||||||
public string User { get; set; }
|
public string User { get; set; }
|
||||||
public string Pass { get; set; }
|
public string Pass { get; set; }
|
||||||
public bool SecondLocalPortEnabled { get; set; }
|
public bool SecondLocalPortEnabled { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class KcpItem
|
public class KcpItem
|
||||||
{
|
{
|
||||||
public int Mtu { get; set; }
|
public int Mtu { get; set; }
|
||||||
|
|
||||||
public int Tti { get; set; }
|
public int Tti { get; set; }
|
||||||
@@ -52,20 +52,20 @@ namespace ServiceLib.Models
|
|||||||
public int ReadBufferSize { get; set; }
|
public int ReadBufferSize { get; set; }
|
||||||
|
|
||||||
public int WriteBufferSize { get; set; }
|
public int WriteBufferSize { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class GrpcItem
|
public class GrpcItem
|
||||||
{
|
{
|
||||||
public int? IdleTimeout { get; set; }
|
public int? IdleTimeout { get; set; }
|
||||||
public int? HealthCheckTimeout { get; set; }
|
public int? HealthCheckTimeout { get; set; }
|
||||||
public bool? PermitWithoutStream { get; set; }
|
public bool? PermitWithoutStream { get; set; }
|
||||||
public int? InitialWindowsSize { get; set; }
|
public int? InitialWindowsSize { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class GUIItem
|
public class GUIItem
|
||||||
{
|
{
|
||||||
public bool AutoRun { get; set; }
|
public bool AutoRun { get; set; }
|
||||||
public bool EnableStatistics { get; set; }
|
public bool EnableStatistics { get; set; }
|
||||||
public bool DisplayRealTimeSpeed { get; set; }
|
public bool DisplayRealTimeSpeed { get; set; }
|
||||||
@@ -75,18 +75,18 @@ namespace ServiceLib.Models
|
|||||||
public int TrayMenuServersLimit { get; set; } = 20;
|
public int TrayMenuServersLimit { get; set; } = 20;
|
||||||
public bool EnableHWA { get; set; } = false;
|
public bool EnableHWA { get; set; } = false;
|
||||||
public bool EnableLog { get; set; } = true;
|
public bool EnableLog { get; set; } = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class MsgUIItem
|
public class MsgUIItem
|
||||||
{
|
{
|
||||||
public string? MainMsgFilter { get; set; }
|
public string? MainMsgFilter { get; set; }
|
||||||
public bool? AutoRefresh { get; set; }
|
public bool? AutoRefresh { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class UIItem
|
public class UIItem
|
||||||
{
|
{
|
||||||
public bool EnableAutoAdjustMainLvColWidth { get; set; }
|
public bool EnableAutoAdjustMainLvColWidth { get; set; }
|
||||||
public bool EnableUpdateSubOnlyRemarksExist { get; set; }
|
public bool EnableUpdateSubOnlyRemarksExist { get; set; }
|
||||||
public double MainWidth { get; set; }
|
public double MainWidth { get; set; }
|
||||||
@@ -105,20 +105,20 @@ namespace ServiceLib.Models
|
|||||||
public bool Hide2TrayWhenClose { get; set; }
|
public bool Hide2TrayWhenClose { get; set; }
|
||||||
public List<ColumnItem> MainColumnItem { get; set; }
|
public List<ColumnItem> MainColumnItem { get; set; }
|
||||||
public bool ShowInTaskbar { get; set; }
|
public bool ShowInTaskbar { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ConstItem
|
public class ConstItem
|
||||||
{
|
{
|
||||||
public string? SubConvertUrl { get; set; }
|
public string? SubConvertUrl { get; set; }
|
||||||
public string? GeoSourceUrl { get; set; }
|
public string? GeoSourceUrl { get; set; }
|
||||||
public string? SrsSourceUrl { get; set; }
|
public string? SrsSourceUrl { get; set; }
|
||||||
public string? RouteRulesTemplateSourceUrl { get; set; }
|
public string? RouteRulesTemplateSourceUrl { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class KeyEventItem
|
public class KeyEventItem
|
||||||
{
|
{
|
||||||
public EGlobalHotkey EGlobalHotkey { get; set; }
|
public EGlobalHotkey EGlobalHotkey { get; set; }
|
||||||
|
|
||||||
public bool Alt { get; set; }
|
public bool Alt { get; set; }
|
||||||
@@ -128,19 +128,19 @@ namespace ServiceLib.Models
|
|||||||
public bool Shift { get; set; }
|
public bool Shift { get; set; }
|
||||||
|
|
||||||
public int? KeyCode { get; set; }
|
public int? KeyCode { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class CoreTypeItem
|
public class CoreTypeItem
|
||||||
{
|
{
|
||||||
public EConfigType ConfigType { get; set; }
|
public EConfigType ConfigType { get; set; }
|
||||||
|
|
||||||
public ECoreType CoreType { get; set; }
|
public ECoreType CoreType { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class TunModeItem
|
public class TunModeItem
|
||||||
{
|
{
|
||||||
public bool EnableTun { get; set; }
|
public bool EnableTun { get; set; }
|
||||||
public bool StrictRoute { get; set; } = true;
|
public bool StrictRoute { get; set; } = true;
|
||||||
public string Stack { get; set; }
|
public string Stack { get; set; }
|
||||||
@@ -148,61 +148,61 @@ namespace ServiceLib.Models
|
|||||||
public bool EnableExInbound { get; set; }
|
public bool EnableExInbound { get; set; }
|
||||||
public bool EnableIPv6Address { get; set; }
|
public bool EnableIPv6Address { get; set; }
|
||||||
public string? LinuxSudoPwd { get; set; }
|
public string? LinuxSudoPwd { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class SpeedTestItem
|
public class SpeedTestItem
|
||||||
{
|
{
|
||||||
public int SpeedTestTimeout { get; set; }
|
public int SpeedTestTimeout { get; set; }
|
||||||
public string SpeedTestUrl { get; set; }
|
public string SpeedTestUrl { get; set; }
|
||||||
public string SpeedPingTestUrl { get; set; }
|
public string SpeedPingTestUrl { get; set; }
|
||||||
public int MixedConcurrencyCount { get; set; }
|
public int MixedConcurrencyCount { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class RoutingBasicItem
|
public class RoutingBasicItem
|
||||||
{
|
{
|
||||||
public string DomainStrategy { get; set; }
|
public string DomainStrategy { get; set; }
|
||||||
public string DomainStrategy4Singbox { get; set; }
|
public string DomainStrategy4Singbox { get; set; }
|
||||||
public string DomainMatcher { get; set; }
|
public string DomainMatcher { get; set; }
|
||||||
public string RoutingIndexId { get; set; }
|
public string RoutingIndexId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ColumnItem
|
public class ColumnItem
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public int Width { get; set; }
|
public int Width { get; set; }
|
||||||
public int Index { get; set; }
|
public int Index { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class Mux4RayItem
|
public class Mux4RayItem
|
||||||
{
|
{
|
||||||
public int? Concurrency { get; set; }
|
public int? Concurrency { get; set; }
|
||||||
public int? XudpConcurrency { get; set; }
|
public int? XudpConcurrency { get; set; }
|
||||||
public string? XudpProxyUDP443 { get; set; }
|
public string? XudpProxyUDP443 { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class Mux4SboxItem
|
public class Mux4SboxItem
|
||||||
{
|
{
|
||||||
public string Protocol { get; set; }
|
public string Protocol { get; set; }
|
||||||
public int MaxConnections { get; set; }
|
public int MaxConnections { get; set; }
|
||||||
public bool? Padding { get; set; }
|
public bool? Padding { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class HysteriaItem
|
public class HysteriaItem
|
||||||
{
|
{
|
||||||
public int UpMbps { get; set; }
|
public int UpMbps { get; set; }
|
||||||
public int DownMbps { get; set; }
|
public int DownMbps { get; set; }
|
||||||
public int HopInterval { get; set; } = 30;
|
public int HopInterval { get; set; } = 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ClashUIItem
|
public class ClashUIItem
|
||||||
{
|
{
|
||||||
public ERuleMode RuleMode { get; set; }
|
public ERuleMode RuleMode { get; set; }
|
||||||
public bool EnableIPv6 { get; set; }
|
public bool EnableIPv6 { get; set; }
|
||||||
public bool EnableMixinContent { get; set; }
|
public bool EnableMixinContent { get; set; }
|
||||||
@@ -211,38 +211,37 @@ namespace ServiceLib.Models
|
|||||||
public int ProxiesAutoDelayTestInterval { get; set; } = 10;
|
public int ProxiesAutoDelayTestInterval { get; set; } = 10;
|
||||||
public bool ConnectionsAutoRefresh { get; set; }
|
public bool ConnectionsAutoRefresh { get; set; }
|
||||||
public int ConnectionsRefreshInterval { get; set; } = 2;
|
public int ConnectionsRefreshInterval { get; set; } = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class SystemProxyItem
|
public class SystemProxyItem
|
||||||
{
|
{
|
||||||
public ESysProxyType SysProxyType { get; set; }
|
public ESysProxyType SysProxyType { get; set; }
|
||||||
public string SystemProxyExceptions { get; set; }
|
public string SystemProxyExceptions { get; set; }
|
||||||
public bool NotProxyLocalAddress { get; set; } = true;
|
public bool NotProxyLocalAddress { get; set; } = true;
|
||||||
public string SystemProxyAdvancedProtocol { get; set; }
|
public string SystemProxyAdvancedProtocol { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class WebDavItem
|
public class WebDavItem
|
||||||
{
|
{
|
||||||
public string? Url { get; set; }
|
public string? Url { get; set; }
|
||||||
public string? UserName { get; set; }
|
public string? UserName { get; set; }
|
||||||
public string? Password { get; set; }
|
public string? Password { get; set; }
|
||||||
public string? DirName { get; set; }
|
public string? DirName { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class CheckUpdateItem
|
public class CheckUpdateItem
|
||||||
{
|
{
|
||||||
public bool CheckPreReleaseUpdate { get; set; }
|
public bool CheckPreReleaseUpdate { get; set; }
|
||||||
public List<string>? SelectedCoreTypes { get; set; }
|
public List<string>? SelectedCoreTypes { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class Fragment4RayItem
|
public class Fragment4RayItem
|
||||||
{
|
{
|
||||||
public string? Packets { get; set; }
|
public string? Packets { get; set; }
|
||||||
public string? Length { get; set; }
|
public string? Length { get; set; }
|
||||||
public string? Interval { get; set; }
|
public string? Interval { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class CoreInfo
|
||||||
{
|
{
|
||||||
[Serializable]
|
|
||||||
public class CoreInfo
|
|
||||||
{
|
|
||||||
public ECoreType CoreType { get; set; }
|
public ECoreType CoreType { get; set; }
|
||||||
public List<string>? CoreExes { get; set; }
|
public List<string>? CoreExes { get; set; }
|
||||||
public string? Arguments { get; set; }
|
public string? Arguments { get; set; }
|
||||||
@@ -17,5 +17,4 @@ namespace ServiceLib.Models
|
|||||||
public string? Match { get; set; }
|
public string? Match { get; set; }
|
||||||
public string? VersionArg { get; set; }
|
public string? VersionArg { get; set; }
|
||||||
public bool AbsolutePath { get; set; }
|
public bool AbsolutePath { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using SQLite;
|
using SQLite;
|
||||||
|
|
||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class DNSItem
|
||||||
{
|
{
|
||||||
[Serializable]
|
|
||||||
public class DNSItem
|
|
||||||
{
|
|
||||||
[PrimaryKey]
|
[PrimaryKey]
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
|
||||||
@@ -16,5 +16,4 @@ namespace ServiceLib.Models
|
|||||||
public string? TunDNS { get; set; }
|
public string? TunDNS { get; set; }
|
||||||
public string? DomainStrategy4Freedom { get; set; }
|
public string? DomainStrategy4Freedom { get; set; }
|
||||||
public string? DomainDNSAddress { get; set; }
|
public string? DomainDNSAddress { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
public class GitHubReleaseAsset
|
||||||
{
|
{
|
||||||
public class GitHubReleaseAsset
|
|
||||||
{
|
|
||||||
[JsonPropertyName("url")] public string? Url { get; set; }
|
[JsonPropertyName("url")] public string? Url { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("id")] public int Id { get; set; }
|
[JsonPropertyName("id")] public int Id { get; set; }
|
||||||
@@ -27,10 +27,10 @@ namespace ServiceLib.Models
|
|||||||
[JsonPropertyName("updated_at")] public DateTime UpdatedAt { get; set; }
|
[JsonPropertyName("updated_at")] public DateTime UpdatedAt { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("browser_download_url")] public string? BrowserDownloadUrl { get; set; }
|
[JsonPropertyName("browser_download_url")] public string? BrowserDownloadUrl { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GitHubRelease
|
public class GitHubRelease
|
||||||
{
|
{
|
||||||
[JsonPropertyName("url")] public string? Url { get; set; }
|
[JsonPropertyName("url")] public string? Url { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("assets_url")] public string? AssetsUrl { get; set; }
|
[JsonPropertyName("assets_url")] public string? AssetsUrl { get; set; }
|
||||||
@@ -64,5 +64,4 @@ namespace ServiceLib.Models
|
|||||||
[JsonPropertyName("zipball_url")] public string? ZipballUrl { get; set; }
|
[JsonPropertyName("zipball_url")] public string? ZipballUrl { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("body")] public string? Body { get; set; }
|
[JsonPropertyName("body")] public string? Body { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
internal class IPAPIInfo
|
||||||
{
|
{
|
||||||
internal class IPAPIInfo
|
|
||||||
{
|
|
||||||
public string? ip { get; set; }
|
public string? ip { get; set; }
|
||||||
public string? city { get; set; }
|
public string? city { get; set; }
|
||||||
public string? region { get; set; }
|
public string? region { get; set; }
|
||||||
@@ -9,5 +9,4 @@
|
|||||||
public string? country { get; set; }
|
public string? country { get; set; }
|
||||||
public string? country_name { get; set; }
|
public string? country_name { get; set; }
|
||||||
public string? country_code { get; set; }
|
public string? country_code { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
using SQLite;
|
using SQLite;
|
||||||
|
|
||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class ProfileExItem
|
||||||
{
|
{
|
||||||
[Serializable]
|
|
||||||
public class ProfileExItem
|
|
||||||
{
|
|
||||||
[PrimaryKey]
|
[PrimaryKey]
|
||||||
public string IndexId { get; set; }
|
public string IndexId { get; set; }
|
||||||
|
|
||||||
@@ -12,5 +12,4 @@ namespace ServiceLib.Models
|
|||||||
public decimal Speed { get; set; }
|
public decimal Speed { get; set; }
|
||||||
public int Sort { get; set; }
|
public int Sort { get; set; }
|
||||||
public string? Message { get; set; }
|
public string? Message { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using SQLite;
|
using SQLite;
|
||||||
|
|
||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class ProfileItem
|
||||||
{
|
{
|
||||||
[Serializable]
|
|
||||||
public class ProfileItem
|
|
||||||
{
|
|
||||||
public ProfileItem()
|
public ProfileItem()
|
||||||
{
|
{
|
||||||
IndexId = string.Empty;
|
IndexId = string.Empty;
|
||||||
@@ -64,6 +64,7 @@ namespace ServiceLib.Models
|
|||||||
|
|
||||||
[PrimaryKey]
|
[PrimaryKey]
|
||||||
public string IndexId { get; set; }
|
public string IndexId { get; set; }
|
||||||
|
|
||||||
public EConfigType ConfigType { get; set; }
|
public EConfigType ConfigType { get; set; }
|
||||||
public int ConfigVersion { get; set; }
|
public int ConfigVersion { get; set; }
|
||||||
public string Address { get; set; }
|
public string Address { get; set; }
|
||||||
@@ -92,5 +93,4 @@ namespace ServiceLib.Models
|
|||||||
public string ShortId { get; set; }
|
public string ShortId { get; set; }
|
||||||
public string SpiderX { get; set; }
|
public string SpiderX { get; set; }
|
||||||
public string Extra { get; set; }
|
public string Extra { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class ProfileItemModel : ProfileItem
|
||||||
{
|
{
|
||||||
[Serializable]
|
|
||||||
public class ProfileItemModel : ProfileItem
|
|
||||||
{
|
|
||||||
public bool IsActive { get; set; }
|
public bool IsActive { get; set; }
|
||||||
public string SubRemarks { get; set; }
|
public string SubRemarks { get; set; }
|
||||||
public int Delay { get; set; }
|
public int Delay { get; set; }
|
||||||
@@ -14,5 +14,4 @@
|
|||||||
public string TodayDown { get; set; }
|
public string TodayDown { get; set; }
|
||||||
public string TotalUp { get; set; }
|
public string TotalUp { get; set; }
|
||||||
public string TotalDown { get; set; }
|
public string TotalDown { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
public class RetResult
|
||||||
{
|
{
|
||||||
public class RetResult
|
|
||||||
{
|
|
||||||
public bool Success { get; set; }
|
public bool Success { get; set; }
|
||||||
public string? Msg { get; set; }
|
public string? Msg { get; set; }
|
||||||
public object? Data { get; set; }
|
public object? Data { get; set; }
|
||||||
@@ -23,5 +23,4 @@
|
|||||||
Msg = msg;
|
Msg = msg;
|
||||||
Data = data;
|
Data = data;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
using SQLite;
|
using SQLite;
|
||||||
|
|
||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class RoutingItem
|
||||||
{
|
{
|
||||||
[Serializable]
|
|
||||||
public class RoutingItem
|
|
||||||
{
|
|
||||||
[PrimaryKey]
|
[PrimaryKey]
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
|
||||||
@@ -19,5 +19,4 @@ namespace ServiceLib.Models
|
|||||||
public string DomainStrategy { get; set; }
|
public string DomainStrategy { get; set; }
|
||||||
public string DomainStrategy4Singbox { get; set; }
|
public string DomainStrategy4Singbox { get; set; }
|
||||||
public int Sort { get; set; }
|
public int Sort { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class RoutingItemModel : RoutingItem
|
||||||
{
|
{
|
||||||
[Serializable]
|
|
||||||
public class RoutingItemModel : RoutingItem
|
|
||||||
{
|
|
||||||
public bool IsActive { get; set; }
|
public bool IsActive { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class RoutingTemplate
|
||||||
{
|
{
|
||||||
[Serializable]
|
|
||||||
public class RoutingTemplate
|
|
||||||
{
|
|
||||||
public string Version { get; set; }
|
public string Version { get; set; }
|
||||||
public RoutingItem[] RoutingItems { get; set; }
|
public RoutingItem[] RoutingItems { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class RulesItem
|
||||||
{
|
{
|
||||||
[Serializable]
|
|
||||||
public class RulesItem
|
|
||||||
{
|
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
public string? Type { get; set; }
|
public string? Type { get; set; }
|
||||||
public string? Port { get; set; }
|
public string? Port { get; set; }
|
||||||
@@ -15,5 +15,4 @@
|
|||||||
public List<string>? Process { get; set; }
|
public List<string>? Process { get; set; }
|
||||||
public bool Enabled { get; set; } = true;
|
public bool Enabled { get; set; } = true;
|
||||||
public string? Remarks { get; set; }
|
public string? Remarks { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
namespace ServiceLib.Models
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class RulesItemModel : RulesItem
|
||||||
{
|
{
|
||||||
[Serializable]
|
|
||||||
public class RulesItemModel : RulesItem
|
|
||||||
{
|
|
||||||
public string InboundTags { get; set; }
|
public string InboundTags { get; set; }
|
||||||
public string Ips { get; set; }
|
public string Ips { get; set; }
|
||||||
public string Domains { get; set; }
|
public string Domains { get; set; }
|
||||||
public string Protocols { get; set; }
|
public string Protocols { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user