mirror of
https://github.com/2dust/v2rayN.git
synced 2026-05-30 01:34:08 +00:00
Merge branch '2dust:master' into master
This commit is contained in:
commit
c37ff8f870
83 changed files with 3962 additions and 1595 deletions
3
.github/workflows/build-all.yml
vendored
3
.github/workflows/build-all.yml
vendored
|
|
@ -7,6 +7,9 @@ on:
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
actions: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update:
|
update:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
||||||
6
.github/workflows/build-linux.yml
vendored
6
.github/workflows/build-linux.yml
vendored
|
|
@ -185,7 +185,7 @@ jobs:
|
||||||
(github.event_name == 'workflow_dispatch' && inputs.release_tag != '') ||
|
(github.event_name == 'workflow_dispatch' && inputs.release_tag != '') ||
|
||||||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
||||||
runs-on: ubuntu-24.04-riscv
|
runs-on: ubuntu-24.04-riscv
|
||||||
container: ghcr.io/xujiegb/fedora-riscv:43-latest
|
container: rockylinux/rockylinux:10
|
||||||
env:
|
env:
|
||||||
RELEASE_TAG: ${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}
|
RELEASE_TAG: ${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}
|
||||||
|
|
||||||
|
|
@ -196,8 +196,8 @@ jobs:
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
dnf -y makecache
|
dnf -y makecache
|
||||||
dnf -y install \
|
dnf -y install \
|
||||||
sudo git rpm-build rpmdevtools dnf-plugins-core rsync findutils tar gzip unzip which curl jq wget file \
|
sudo git rpm-build rpmdevtools dnf-plugins-core \
|
||||||
ca-certificates desktop-file-utils xdg-utils python3 gcc make glibc-devel kernel-headers libatomic libstdc++
|
rsync findutils tar gzip unzip which jq
|
||||||
|
|
||||||
- name: Checkout repo (for scripts)
|
- name: Checkout repo (for scripts)
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
|
||||||
3
.github/workflows/build-osx.yml
vendored
3
.github/workflows/build-osx.yml
vendored
|
|
@ -62,6 +62,9 @@ jobs:
|
||||||
- name: Package dmg
|
- name: Package dmg
|
||||||
run: ./package-osx.sh macos-$Arch v2rayN-macos-$Arch ${{ inputs.release_tag }}
|
run: ./package-osx.sh macos-$Arch v2rayN-macos-$Arch ${{ inputs.release_tag }}
|
||||||
|
|
||||||
|
- name: Sleep for race condition between matrix jobs
|
||||||
|
run: sleep $(awk 'BEGIN { srand(); printf "%.3f", rand()*2 }')
|
||||||
|
|
||||||
- name: Upload dmg to release
|
- name: Upload dmg to release
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
3
.github/workflows/package-zip.yml
vendored
3
.github/workflows/package-zip.yml
vendored
|
|
@ -55,6 +55,9 @@ jobs:
|
||||||
if: inputs.target == 'windows-desktop'
|
if: inputs.target == 'windows-desktop'
|
||||||
run: mv "v2rayN-$Target-$Arch.zip" "v2rayN-$Target-$Arch-desktop.zip"
|
run: mv "v2rayN-$Target-$Arch.zip" "v2rayN-$Target-$Arch-desktop.zip"
|
||||||
|
|
||||||
|
- name: Sleep for race condition between matrix jobs
|
||||||
|
run: sleep $(awk 'BEGIN { srand(); printf "%.3f", rand()*2 }')
|
||||||
|
|
||||||
- name: Upload zip archive to release
|
- name: Upload zip archive to release
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ DOTNET_RISCV_VERSION="10.0.105"
|
||||||
DOTNET_RISCV_BASE="https://github.com/filipnavara/dotnet-riscv/releases/download"
|
DOTNET_RISCV_BASE="https://github.com/filipnavara/dotnet-riscv/releases/download"
|
||||||
DOTNET_RISCV_FILE="dotnet-sdk-${DOTNET_RISCV_VERSION}-linux-riscv64.tar.gz"
|
DOTNET_RISCV_FILE="dotnet-sdk-${DOTNET_RISCV_VERSION}-linux-riscv64.tar.gz"
|
||||||
DOTNET_SDK_URL="${DOTNET_RISCV_BASE}/${DOTNET_RISCV_VERSION}/${DOTNET_RISCV_FILE}"
|
DOTNET_SDK_URL="${DOTNET_RISCV_BASE}/${DOTNET_RISCV_VERSION}/${DOTNET_RISCV_FILE}"
|
||||||
SKIA_VER="${SKIA_VER:-3.119.1}"
|
SKIA_VER="${SKIA_VER:-3.119.2}"
|
||||||
HARFBUZZ_VER="${HARFBUZZ_VER:-8.3.1.1}"
|
HARFBUZZ_VER="${HARFBUZZ_VER:-8.3.1.1}"
|
||||||
|
|
||||||
# If the first argument starts with --, do not treat it as a version number
|
# If the first argument starts with --, do not treat it as a version number
|
||||||
|
|
@ -111,9 +111,9 @@ build_sqlite_native_riscv64() {
|
||||||
mkdir -p "$outdir"
|
mkdir -p "$outdir"
|
||||||
workdir="$(mktemp -d)"
|
workdir="$(mktemp -d)"
|
||||||
|
|
||||||
# SQLite 3.49.1 amalgamation
|
# SQLite 3.51.3 amalgamation
|
||||||
sqlite_year="2025"
|
sqlite_year="2026"
|
||||||
sqlite_ver="3490100"
|
sqlite_ver="3510300"
|
||||||
sqlite_zip="sqlite-amalgamation-${sqlite_ver}.zip"
|
sqlite_zip="sqlite-amalgamation-${sqlite_ver}.zip"
|
||||||
|
|
||||||
echo "[+] Download SQLite amalgamation: ${sqlite_zip}"
|
echo "[+] Download SQLite amalgamation: ${sqlite_zip}"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<Project>
|
<Project>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>7.20.4</Version>
|
<Version>7.21.0</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,14 @@
|
||||||
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.3.13" />
|
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.3.13" />
|
||||||
<PackageVersion Include="Avalonia.Desktop" Version="11.3.13" />
|
<PackageVersion Include="Avalonia.Desktop" Version="11.3.13" />
|
||||||
<PackageVersion Include="Avalonia.Diagnostics" Version="11.3.13" />
|
<PackageVersion Include="Avalonia.Diagnostics" Version="11.3.13" />
|
||||||
|
<PackageVersion Include="AwesomeAssertions" Version="9.4.0" />
|
||||||
|
<PackageVersion Include="DialogHost.Avalonia" Version="0.11.0" />
|
||||||
<PackageVersion Include="ReactiveUI.Avalonia" Version="11.4.12" />
|
<PackageVersion Include="ReactiveUI.Avalonia" Version="11.4.12" />
|
||||||
<PackageVersion Include="CliWrap" Version="3.10.1" />
|
<PackageVersion Include="CliWrap" Version="3.10.1" />
|
||||||
<PackageVersion Include="Downloader" Version="5.1.0" />
|
<PackageVersion Include="Downloader" Version="5.2.0" />
|
||||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.4.0" />
|
||||||
<PackageVersion Include="H.NotifyIcon.Wpf" Version="2.4.1" />
|
<PackageVersion Include="H.NotifyIcon.Wpf" Version="2.4.1" />
|
||||||
<PackageVersion Include="MaterialDesignThemes" Version="5.3.1" />
|
<PackageVersion Include="MaterialDesignThemes" Version="5.3.1" />
|
||||||
<PackageVersion Include="MessageBox.Avalonia" Version="3.3.1.1" />
|
|
||||||
<PackageVersion Include="QRCoder" Version="1.8.0" />
|
<PackageVersion Include="QRCoder" Version="1.8.0" />
|
||||||
<PackageVersion Include="ReactiveUI" Version="23.2.1" />
|
<PackageVersion Include="ReactiveUI" Version="23.2.1" />
|
||||||
<PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" />
|
<PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" />
|
||||||
|
|
@ -27,8 +28,8 @@
|
||||||
<PackageVersion Include="sqlite-net-pcl" Version="1.9.172" />
|
<PackageVersion Include="sqlite-net-pcl" Version="1.9.172" />
|
||||||
<PackageVersion Include="TaskScheduler" Version="2.12.2" />
|
<PackageVersion Include="TaskScheduler" Version="2.12.2" />
|
||||||
<PackageVersion Include="WebDav.Client" Version="2.9.0" />
|
<PackageVersion Include="WebDav.Client" Version="2.9.0" />
|
||||||
<PackageVersion Include="xunit" Version="2.9.3" />
|
|
||||||
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
|
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
|
||||||
|
<PackageVersion Include="xunit.v3" Version="3.2.2" />
|
||||||
<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>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,113 @@
|
||||||
|
using AwesomeAssertions;
|
||||||
|
using ServiceLib.Enums;
|
||||||
|
using ServiceLib.Handler.Builder;
|
||||||
|
using ServiceLib.Helper;
|
||||||
|
using ServiceLib.Models;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace ServiceLib.Tests.CoreConfig.Context;
|
||||||
|
|
||||||
|
public class CoreConfigContextBuilderTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public async Task ResolveNodeAsync_DirectCycleDependency_ShouldFailWithCycleError()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig();
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var groupAId = NewId("group-a");
|
||||||
|
var groupBId = NewId("group-b");
|
||||||
|
var groupA = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, groupAId, "group-a", [groupBId]);
|
||||||
|
var groupB = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, groupBId, "group-b", [groupAId]);
|
||||||
|
|
||||||
|
await UpsertProfilesAsync(groupA, groupB);
|
||||||
|
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, groupA, ECoreType.Xray);
|
||||||
|
context.AllProxiesMap.Clear();
|
||||||
|
|
||||||
|
var (_, validatorResult) = await CoreConfigContextBuilder.ResolveNodeAsync(context, groupA, false);
|
||||||
|
|
||||||
|
validatorResult.Success.Should().BeFalse();
|
||||||
|
validatorResult.Errors.Should().Contain(msg => ContainsCycleDependencyMessage(msg));
|
||||||
|
context.AllProxiesMap.Should().NotContainKey(groupA.IndexId);
|
||||||
|
context.AllProxiesMap.Should().NotContainKey(groupB.IndexId);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task ResolveNodeAsync_IndirectCycleDependency_ShouldFailWithCycleError()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig();
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var groupAId = NewId("group-a");
|
||||||
|
var groupBId = NewId("group-b");
|
||||||
|
var groupCId = NewId("group-c");
|
||||||
|
var groupA = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, groupAId, "group-a", [groupBId]);
|
||||||
|
var groupB = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, groupBId, "group-b", [groupCId]);
|
||||||
|
var groupC = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, groupCId, "group-c", [groupAId]);
|
||||||
|
|
||||||
|
await UpsertProfilesAsync(groupA, groupB, groupC);
|
||||||
|
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, groupA, ECoreType.Xray);
|
||||||
|
context.AllProxiesMap.Clear();
|
||||||
|
|
||||||
|
var (_, validatorResult) = await CoreConfigContextBuilder.ResolveNodeAsync(context, groupA, false);
|
||||||
|
|
||||||
|
validatorResult.Success.Should().BeFalse();
|
||||||
|
validatorResult.Errors.Should().Contain(msg => ContainsCycleDependencyMessage(msg));
|
||||||
|
context.AllProxiesMap.Should().NotContainKey(groupA.IndexId);
|
||||||
|
context.AllProxiesMap.Should().NotContainKey(groupB.IndexId);
|
||||||
|
context.AllProxiesMap.Should().NotContainKey(groupC.IndexId);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task ResolveNodeAsync_CycleWithValidBranch_ShouldSkipCycleAndKeepValidChild()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig();
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var groupAId = NewId("group-a");
|
||||||
|
var groupBId = NewId("group-b");
|
||||||
|
var leafId = NewId("leaf");
|
||||||
|
var groupA = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, groupAId, "group-a", [groupBId, leafId]);
|
||||||
|
var groupB = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, groupBId, "group-b", [groupAId]);
|
||||||
|
var leaf = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, leafId, "leaf");
|
||||||
|
|
||||||
|
await UpsertProfilesAsync(groupA, groupB, leaf);
|
||||||
|
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, groupA, ECoreType.Xray);
|
||||||
|
context.AllProxiesMap.Clear();
|
||||||
|
|
||||||
|
var (_, validatorResult) = await CoreConfigContextBuilder.ResolveNodeAsync(context, groupA, false);
|
||||||
|
|
||||||
|
validatorResult.Success.Should().BeTrue();
|
||||||
|
validatorResult.Errors.Should().BeEmpty();
|
||||||
|
validatorResult.Warnings.Should().Contain(msg => ContainsCycleDependencyMessage(msg));
|
||||||
|
|
||||||
|
context.AllProxiesMap.Should().ContainKey(leaf.IndexId);
|
||||||
|
context.AllProxiesMap.Should().ContainKey(groupA.IndexId);
|
||||||
|
context.AllProxiesMap.Should().NotContainKey(groupB.IndexId);
|
||||||
|
groupA.GetProtocolExtra().ChildItems.Should().Be(leaf.IndexId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string NewId(string prefix)
|
||||||
|
{
|
||||||
|
return $"{prefix}-{Guid.NewGuid():N}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool ContainsCycleDependencyMessage(string message)
|
||||||
|
{
|
||||||
|
return message.Contains("cycle dependency", StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| message.Contains("循环依赖", StringComparison.Ordinal)
|
||||||
|
|| message.Contains("循環依賴", StringComparison.Ordinal);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task UpsertProfilesAsync(params ProfileItem[] profiles)
|
||||||
|
{
|
||||||
|
SQLiteHelper.Instance.CreateTable<ProfileItem>();
|
||||||
|
foreach (var profile in profiles)
|
||||||
|
{
|
||||||
|
await SQLiteHelper.Instance.ReplaceAsync(profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
197
v2rayN/ServiceLib.Tests/CoreConfig/CoreConfigTestFactory.cs
Normal file
197
v2rayN/ServiceLib.Tests/CoreConfig/CoreConfigTestFactory.cs
Normal file
|
|
@ -0,0 +1,197 @@
|
||||||
|
using ServiceLib.Enums;
|
||||||
|
using ServiceLib.Manager;
|
||||||
|
using ServiceLib.Models;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace ServiceLib.Tests.CoreConfig;
|
||||||
|
|
||||||
|
internal static class CoreConfigTestFactory
|
||||||
|
{
|
||||||
|
public static void BindAppManagerConfig(Config config)
|
||||||
|
{
|
||||||
|
var field = typeof(AppManager).GetField("_config", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||||
|
field?.SetValue(AppManager.Instance, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Config CreateConfig(ECoreType vmessCoreType = ECoreType.Xray)
|
||||||
|
{
|
||||||
|
return new Config
|
||||||
|
{
|
||||||
|
CoreBasicItem = new CoreBasicItem { Loglevel = "warning", MuxEnabled = false },
|
||||||
|
TunModeItem = new TunModeItem { EnableTun = false, IcmpRouting = "default" },
|
||||||
|
KcpItem = new KcpItem(),
|
||||||
|
GrpcItem = new GrpcItem(),
|
||||||
|
RoutingBasicItem =
|
||||||
|
new RoutingBasicItem
|
||||||
|
{
|
||||||
|
DomainStrategy = Global.AsIs,
|
||||||
|
DomainStrategy4Singbox = string.Empty,
|
||||||
|
RoutingIndexId = string.Empty,
|
||||||
|
},
|
||||||
|
GuiItem = new GUIItem { EnableStatistics = false, DisplayRealTimeSpeed = false, EnableLog = false },
|
||||||
|
MsgUIItem = new MsgUIItem(),
|
||||||
|
UiItem =
|
||||||
|
new UIItem
|
||||||
|
{
|
||||||
|
CurrentLanguage = "en", CurrentFontFamily = "sans", MainColumnItem = [], WindowSizeItem = []
|
||||||
|
},
|
||||||
|
ConstItem = new ConstItem(),
|
||||||
|
SpeedTestItem = new SpeedTestItem
|
||||||
|
{
|
||||||
|
SpeedPingTestUrl = Global.SpeedPingTestUrls.First(),
|
||||||
|
SpeedTestUrl = Global.SpeedTestUrls.First(),
|
||||||
|
SpeedTestTimeout = 10,
|
||||||
|
MixedConcurrencyCount = 1,
|
||||||
|
IPAPIUrl = string.Empty,
|
||||||
|
},
|
||||||
|
Mux4RayItem = new Mux4RayItem { Concurrency = 8, XudpConcurrency = 16, XudpProxyUDP443 = "reject" },
|
||||||
|
Mux4SboxItem = new Mux4SboxItem { Protocol = Global.SingboxMuxs.First(), MaxConnections = 8 },
|
||||||
|
HysteriaItem = new HysteriaItem { UpMbps = 100, DownMbps = 100 },
|
||||||
|
ClashUIItem = new ClashUIItem { ConnectionsColumnItem = [] },
|
||||||
|
SystemProxyItem =
|
||||||
|
new SystemProxyItem
|
||||||
|
{
|
||||||
|
SystemProxyExceptions = string.Empty, SystemProxyAdvancedProtocol = string.Empty
|
||||||
|
},
|
||||||
|
WebDavItem = new WebDavItem(),
|
||||||
|
CheckUpdateItem = new CheckUpdateItem(),
|
||||||
|
Fragment4RayItem = new Fragment4RayItem { Packets = "tlshello", Length = "100-200", Interval = "10-20" },
|
||||||
|
Inbound =
|
||||||
|
[
|
||||||
|
new InItem
|
||||||
|
{
|
||||||
|
Protocol = nameof(EInboundProtocol.socks),
|
||||||
|
LocalPort = 10808,
|
||||||
|
UdpEnabled = true,
|
||||||
|
SniffingEnabled = true,
|
||||||
|
RouteOnly = false,
|
||||||
|
DestOverride = ["http", "tls"],
|
||||||
|
}
|
||||||
|
],
|
||||||
|
GlobalHotkeys = [],
|
||||||
|
CoreTypeItem =
|
||||||
|
[
|
||||||
|
new CoreTypeItem { ConfigType = EConfigType.VMess, CoreType = vmessCoreType }
|
||||||
|
],
|
||||||
|
SimpleDNSItem = new SimpleDNSItem
|
||||||
|
{
|
||||||
|
BootstrapDNS = Global.DomainPureIPDNSAddress.FirstOrDefault(),
|
||||||
|
ServeStale = false,
|
||||||
|
ParallelQuery = false,
|
||||||
|
Strategy4Freedom = Global.AsIs,
|
||||||
|
Strategy4Proxy = Global.AsIs,
|
||||||
|
},
|
||||||
|
IndexId = string.Empty,
|
||||||
|
SubIndexId = string.Empty,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProfileItem CreateVmessNode(ECoreType coreType, string indexId = "node-1", string remarks = "demo")
|
||||||
|
{
|
||||||
|
var node = new ProfileItem
|
||||||
|
{
|
||||||
|
IndexId = indexId,
|
||||||
|
ConfigType = EConfigType.VMess,
|
||||||
|
CoreType = coreType,
|
||||||
|
Remarks = remarks,
|
||||||
|
Address = "example.com",
|
||||||
|
Port = 443,
|
||||||
|
Password = Guid.NewGuid().ToString(),
|
||||||
|
Network = nameof(ETransport.raw),
|
||||||
|
StreamSecurity = string.Empty,
|
||||||
|
Subid = string.Empty,
|
||||||
|
};
|
||||||
|
|
||||||
|
node.SetProtocolExtra(node.GetProtocolExtra() with { AlterId = "0", VmessSecurity = Global.DefaultSecurity, });
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProfileItem CreateSocksNode(ECoreType coreType, string indexId = "node-socks-1",
|
||||||
|
string remarks = "demo-socks")
|
||||||
|
{
|
||||||
|
return new ProfileItem
|
||||||
|
{
|
||||||
|
IndexId = indexId,
|
||||||
|
ConfigType = EConfigType.SOCKS,
|
||||||
|
CoreType = coreType,
|
||||||
|
Remarks = remarks,
|
||||||
|
Address = "127.0.0.1",
|
||||||
|
Port = 1080,
|
||||||
|
Password = "pass",
|
||||||
|
Username = "user",
|
||||||
|
Network = nameof(ETransport.raw),
|
||||||
|
StreamSecurity = string.Empty,
|
||||||
|
Subid = string.Empty,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProfileItem CreatePolicyGroupNode(ECoreType coreType, string indexId, string remarks,
|
||||||
|
IEnumerable<string> childIndexIds)
|
||||||
|
{
|
||||||
|
var node = new ProfileItem
|
||||||
|
{
|
||||||
|
IndexId = indexId, ConfigType = EConfigType.PolicyGroup, CoreType = coreType, Remarks = remarks,
|
||||||
|
};
|
||||||
|
node.SetProtocolExtra(node.GetProtocolExtra() with
|
||||||
|
{
|
||||||
|
GroupType = nameof(EConfigType.PolicyGroup), ChildItems = string.Join(",", childIndexIds),
|
||||||
|
});
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProfileItem CreateProxyChainNode(ECoreType coreType, string indexId, string remarks,
|
||||||
|
IEnumerable<string> childIndexIds)
|
||||||
|
{
|
||||||
|
var node = new ProfileItem
|
||||||
|
{
|
||||||
|
IndexId = indexId, ConfigType = EConfigType.ProxyChain, CoreType = coreType, Remarks = remarks,
|
||||||
|
};
|
||||||
|
node.SetProtocolExtra(node.GetProtocolExtra() with
|
||||||
|
{
|
||||||
|
GroupType = nameof(EConfigType.ProxyChain), ChildItems = string.Join(",", childIndexIds),
|
||||||
|
});
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CoreConfigContext CreateContext(Config config, ProfileItem node, ECoreType runCoreType)
|
||||||
|
{
|
||||||
|
return new CoreConfigContext
|
||||||
|
{
|
||||||
|
Node = node,
|
||||||
|
RunCoreType = runCoreType,
|
||||||
|
AppConfig = config,
|
||||||
|
RoutingItem = new RoutingItem
|
||||||
|
{
|
||||||
|
Id = "r1",
|
||||||
|
Remarks = "default",
|
||||||
|
RuleSet = "[]",
|
||||||
|
DomainStrategy = Global.AsIs,
|
||||||
|
DomainStrategy4Singbox = string.Empty,
|
||||||
|
},
|
||||||
|
RawDnsItem = null,
|
||||||
|
SimpleDnsItem = config.SimpleDNSItem,
|
||||||
|
AllProxiesMap = new Dictionary<string, ProfileItem> { [node.IndexId] = node },
|
||||||
|
FullConfigTemplate = null,
|
||||||
|
IsTunEnabled = false,
|
||||||
|
ProtectDomainList = [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Config CreateConfigWithDirectExpectedIPs(ECoreType coreType,
|
||||||
|
string directExpectedIPs = "192.168.0.0/16,geoip:cn")
|
||||||
|
{
|
||||||
|
var config = CreateConfig(coreType);
|
||||||
|
config.SimpleDNSItem.DirectExpectedIPs = directExpectedIPs;
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Config CreateConfigWithBootstrapDNS(ECoreType coreType, string bootstrapDns = "8.8.8.8")
|
||||||
|
{
|
||||||
|
var config = CreateConfig(coreType);
|
||||||
|
config.SimpleDNSItem.BootstrapDNS = bootstrapDns;
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,511 @@
|
||||||
|
using AwesomeAssertions;
|
||||||
|
using ServiceLib.Common;
|
||||||
|
using ServiceLib.Enums;
|
||||||
|
using ServiceLib.Models;
|
||||||
|
using ServiceLib.Services.CoreConfig;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace ServiceLib.Tests.CoreConfig.Singbox;
|
||||||
|
|
||||||
|
public class CoreConfigSingboxServiceTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_ShouldGenerateBasicProxyConfig()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box);
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box);
|
||||||
|
|
||||||
|
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||||
|
result.Data.Should().NotBeNull();
|
||||||
|
|
||||||
|
var singboxConfig = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString());
|
||||||
|
singboxConfig.Should().NotBeNull();
|
||||||
|
singboxConfig!.outbounds.Should().Contain(o => o.tag == Global.ProxyTag && o.type == "socks");
|
||||||
|
singboxConfig.inbounds.Should().Contain(i => i.type == nameof(EInboundProtocol.mixed));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_PolicyGroup_ShouldExpandChildrenAndBuildSelector()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n1", "node-1");
|
||||||
|
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n2", "node-2");
|
||||||
|
var group = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.sing_box, "g1", "group",
|
||||||
|
[n1.IndexId, n2.IndexId]);
|
||||||
|
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, group, ECoreType.sing_box);
|
||||||
|
context.AllProxiesMap[n1.IndexId] = n1;
|
||||||
|
context.AllProxiesMap[n2.IndexId] = n2;
|
||||||
|
context.AllProxiesMap[group.IndexId] = group;
|
||||||
|
|
||||||
|
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||||
|
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||||
|
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag == Global.ProxyTag && o.type == "selector");
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag == $"{Global.ProxyTag}-auto" && o.type == "urltest");
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("proxy-1-", StringComparison.Ordinal));
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("proxy-2-", StringComparison.Ordinal));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_ProxyChain_ShouldBuildDetourChain()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n1", "node-1");
|
||||||
|
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n2", "node-2");
|
||||||
|
var chain = CoreConfigTestFactory.CreateProxyChainNode(ECoreType.sing_box, "c1", "chain",
|
||||||
|
[n1.IndexId, n2.IndexId]);
|
||||||
|
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, chain, ECoreType.sing_box);
|
||||||
|
context.AllProxiesMap[n1.IndexId] = n1;
|
||||||
|
context.AllProxiesMap[n2.IndexId] = n2;
|
||||||
|
context.AllProxiesMap[chain.IndexId] = chain;
|
||||||
|
|
||||||
|
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||||
|
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||||
|
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag == Global.ProxyTag && o.type == "socks");
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("chain-proxy-1-", StringComparison.Ordinal));
|
||||||
|
cfg.outbounds.Should().Contain(o =>
|
||||||
|
o.tag == Global.ProxyTag &&
|
||||||
|
(o.detour ?? string.Empty).StartsWith("chain-proxy-1-", StringComparison.Ordinal));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_PolicyGroupWithProxyChain_ShouldBuildCombinedOutbounds()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n1", "node-1");
|
||||||
|
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n2", "node-2");
|
||||||
|
var n3 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n3", "node-3");
|
||||||
|
var chain = CoreConfigTestFactory.CreateProxyChainNode(ECoreType.sing_box, "c1", "chain",
|
||||||
|
[n1.IndexId, n2.IndexId]);
|
||||||
|
var group = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.sing_box, "g1", "group",
|
||||||
|
[chain.IndexId, n3.IndexId]);
|
||||||
|
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, group, ECoreType.sing_box);
|
||||||
|
context.AllProxiesMap[n1.IndexId] = n1;
|
||||||
|
context.AllProxiesMap[n2.IndexId] = n2;
|
||||||
|
context.AllProxiesMap[n3.IndexId] = n3;
|
||||||
|
context.AllProxiesMap[chain.IndexId] = chain;
|
||||||
|
context.AllProxiesMap[group.IndexId] = group;
|
||||||
|
|
||||||
|
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||||
|
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||||
|
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag == Global.ProxyTag && o.type == "selector");
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag == $"{Global.ProxyTag}-auto" && o.type == "urltest");
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("proxy-1-", StringComparison.Ordinal));
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("chain-proxy-1-", StringComparison.Ordinal));
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("proxy-2-", StringComparison.Ordinal));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_ProxyChainWithPolicyGroup_ShouldBuildClonedChainBranches()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n1", "node-1");
|
||||||
|
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n2", "node-2");
|
||||||
|
var n3 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n3", "node-3");
|
||||||
|
var group = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.sing_box, "g1", "group",
|
||||||
|
[n1.IndexId, n2.IndexId]);
|
||||||
|
var chain = CoreConfigTestFactory.CreateProxyChainNode(ECoreType.sing_box, "c1", "chain",
|
||||||
|
[group.IndexId, n3.IndexId]);
|
||||||
|
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, chain, ECoreType.sing_box);
|
||||||
|
context.AllProxiesMap[n1.IndexId] = n1;
|
||||||
|
context.AllProxiesMap[n2.IndexId] = n2;
|
||||||
|
context.AllProxiesMap[n3.IndexId] = n3;
|
||||||
|
context.AllProxiesMap[group.IndexId] = group;
|
||||||
|
context.AllProxiesMap[chain.IndexId] = chain;
|
||||||
|
|
||||||
|
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||||
|
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||||
|
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag == Global.ProxyTag && o.type == "selector");
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag == $"{Global.ProxyTag}-auto" && o.type == "urltest");
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("chain-proxy-1-group-1-", StringComparison.Ordinal));
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("chain-proxy-1-group-2-", StringComparison.Ordinal));
|
||||||
|
|
||||||
|
var proxyCloneCount = cfg.outbounds.Count(o => o.tag.StartsWith("proxy-clone-", StringComparison.Ordinal));
|
||||||
|
proxyCloneCount.Should().Be(2);
|
||||||
|
|
||||||
|
var allCloneDetoursPointToGroupBranches = cfg.outbounds
|
||||||
|
.Where(o => o.tag.StartsWith("proxy-clone-", StringComparison.Ordinal))
|
||||||
|
.All(o => (o.detour ?? string.Empty).StartsWith("chain-proxy-1-group-", StringComparison.Ordinal));
|
||||||
|
allCloneDetoursPointToGroupBranches.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_RoutingSplit_DirectAndBlock_ShouldApplyRules()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||||
|
{
|
||||||
|
RoutingItem = new RoutingItem
|
||||||
|
{
|
||||||
|
Id = "r-split-1",
|
||||||
|
Remarks = "split-direct-block",
|
||||||
|
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||||
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Enabled = true,
|
||||||
|
RuleType = ERuleType.Routing,
|
||||||
|
OutboundTag = Global.DirectTag,
|
||||||
|
Domain = ["full:direct.example.com"],
|
||||||
|
},
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Enabled = true,
|
||||||
|
RuleType = ERuleType.Routing,
|
||||||
|
OutboundTag = Global.BlockTag,
|
||||||
|
Domain = ["full:block.example.com"],
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
DomainStrategy = Global.AsIs,
|
||||||
|
DomainStrategy4Singbox = string.Empty,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||||
|
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||||
|
|
||||||
|
var hasDirectRule = cfg.route.rules.Any(r =>
|
||||||
|
r.domain != null
|
||||||
|
&& r.domain.Contains("direct.example.com")
|
||||||
|
&& r.outbound == Global.DirectTag);
|
||||||
|
hasDirectRule.Should().BeTrue();
|
||||||
|
|
||||||
|
var hasBlockRule = cfg.route.rules.Any(r =>
|
||||||
|
r.domain != null
|
||||||
|
&& r.domain.Contains("block.example.com")
|
||||||
|
&& r.action == "reject");
|
||||||
|
hasBlockRule.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_RoutingSplit_ByRemark_ShouldGenerateTargetOutbound()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||||
|
var routeNode = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-route", "route-node");
|
||||||
|
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||||
|
{
|
||||||
|
RoutingItem = new RoutingItem
|
||||||
|
{
|
||||||
|
Id = "r-split-2",
|
||||||
|
Remarks = "split-remark",
|
||||||
|
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||||
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Enabled = true,
|
||||||
|
RuleType = ERuleType.Routing,
|
||||||
|
OutboundTag = routeNode.Remarks,
|
||||||
|
Domain = ["full:route.example.com"],
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
DomainStrategy = Global.AsIs,
|
||||||
|
DomainStrategy4Singbox = string.Empty,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
context.AllProxiesMap[$"remark:{routeNode.Remarks}"] = routeNode;
|
||||||
|
|
||||||
|
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||||
|
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||||
|
var expectedPrefix = $"{routeNode.IndexId}-{Global.ProxyTag}-{routeNode.Remarks}";
|
||||||
|
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith(expectedPrefix, StringComparison.Ordinal));
|
||||||
|
|
||||||
|
var hasRouteRule = cfg.route.rules.Any(r =>
|
||||||
|
r.domain != null
|
||||||
|
&& r.domain.Contains("route.example.com")
|
||||||
|
&& (r.outbound ?? string.Empty).StartsWith(expectedPrefix, StringComparison.Ordinal));
|
||||||
|
hasRouteRule.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_DirectExpectedIPs_ShouldApplyGeoipAndCidrToDirectDnsRule()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfigWithDirectExpectedIPs(
|
||||||
|
ECoreType.sing_box,
|
||||||
|
"192.168.0.0/16,geoip:cn");
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||||
|
{
|
||||||
|
RoutingItem = new RoutingItem
|
||||||
|
{
|
||||||
|
Id = "r-dns-direct-expected",
|
||||||
|
Remarks = "dns-direct-expected",
|
||||||
|
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||||
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Enabled = true,
|
||||||
|
RuleType = ERuleType.DNS,
|
||||||
|
OutboundTag = Global.DirectTag,
|
||||||
|
Domain = ["geosite:cn"],
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
DomainStrategy = Global.AsIs,
|
||||||
|
DomainStrategy4Singbox = string.Empty,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||||
|
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||||
|
|
||||||
|
var hasExpectedRule = cfg.dns.rules?.Any(r =>
|
||||||
|
r.server == Global.SingboxDirectDNSTag
|
||||||
|
&& r.ip_cidr?.Contains("192.168.0.0/16") == true
|
||||||
|
&& r.rule_set?.Contains("geosite-cn") == true
|
||||||
|
&& r.rule_set?.Contains("geoip-cn") == true) ?? false;
|
||||||
|
|
||||||
|
hasExpectedRule.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_BootstrapDNS_ShouldConfigurePureIPResolver()
|
||||||
|
{
|
||||||
|
var bootstrapDns = "8.8.8.8";
|
||||||
|
var config = CoreConfigTestFactory.CreateConfigWithBootstrapDNS(ECoreType.sing_box, bootstrapDns);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box);
|
||||||
|
|
||||||
|
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||||
|
config.SimpleDNSItem.BootstrapDNS.Should().Be(bootstrapDns);
|
||||||
|
|
||||||
|
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||||
|
var bootstrapServer = cfg.dns.servers?.FirstOrDefault(s => s.tag == Global.SingboxLocalDNSTag);
|
||||||
|
bootstrapServer.Should().NotBeNull();
|
||||||
|
(bootstrapServer?.server ?? string.Empty).Should().Contain(bootstrapDns);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_DnsFallback_LastRuleDirect_ShouldUseDirectFinalDns()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||||
|
config.SimpleDNSItem.DirectDNS = "1.1.1.1";
|
||||||
|
config.SimpleDNSItem.RemoteDNS = "9.9.9.9";
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||||
|
{
|
||||||
|
RoutingItem = new RoutingItem
|
||||||
|
{
|
||||||
|
Id = "r-direct-final",
|
||||||
|
Remarks = "direct-final",
|
||||||
|
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||||
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Enabled = true,
|
||||||
|
RuleType = ERuleType.Routing,
|
||||||
|
OutboundTag = Global.DirectTag,
|
||||||
|
Ip = ["0.0.0.0/0"],
|
||||||
|
Port = "0-65535",
|
||||||
|
Network = "tcp,udp",
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
DomainStrategy = Global.AsIs,
|
||||||
|
DomainStrategy4Singbox = string.Empty,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||||
|
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||||
|
|
||||||
|
cfg.dns.final.Should().Be(Global.SingboxDirectDNSTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_DirectExpectedIPs_NonMatchingRegion_ShouldNotApplyExpectedRule()
|
||||||
|
{
|
||||||
|
var config =
|
||||||
|
CoreConfigTestFactory.CreateConfigWithDirectExpectedIPs(ECoreType.sing_box, "192.168.0.0/16,geoip:cn");
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||||
|
{
|
||||||
|
RoutingItem = new RoutingItem
|
||||||
|
{
|
||||||
|
Id = "r-dns-direct-unmatched",
|
||||||
|
Remarks = "dns-direct-unmatched",
|
||||||
|
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||||
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Enabled = true,
|
||||||
|
RuleType = ERuleType.DNS,
|
||||||
|
OutboundTag = Global.DirectTag,
|
||||||
|
Domain = ["geosite:us"],
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
DomainStrategy = Global.AsIs,
|
||||||
|
DomainStrategy4Singbox = string.Empty,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||||
|
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||||
|
|
||||||
|
var hasExpectedRule = cfg.dns.rules?.Any(r =>
|
||||||
|
r.server == Global.SingboxDirectDNSTag
|
||||||
|
&& r.ip_cidr?.Contains("192.168.0.0/16") == true
|
||||||
|
&& r.rule_set?.Contains("geoip-cn") == true) ?? false;
|
||||||
|
hasExpectedRule.Should().BeFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData("geosite:cn", "geosite-cn")]
|
||||||
|
[InlineData("geosite:geolocation-cn", "geosite-geolocation-cn")]
|
||||||
|
[InlineData("geosite:tld-cn", "geosite-tld-cn")]
|
||||||
|
public void GenerateClientConfigContent_DirectExpectedIPs_RegionVariant_ShouldApplyExpectedRule(string domainTag,
|
||||||
|
string expectedRuleSetTag)
|
||||||
|
{
|
||||||
|
var config =
|
||||||
|
CoreConfigTestFactory.CreateConfigWithDirectExpectedIPs(ECoreType.sing_box, "192.168.0.0/16,geoip:cn");
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||||
|
{
|
||||||
|
RoutingItem = new RoutingItem
|
||||||
|
{
|
||||||
|
Id = "r-dns-direct-variant",
|
||||||
|
Remarks = "dns-direct-variant",
|
||||||
|
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||||
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Enabled = true, RuleType = ERuleType.DNS, OutboundTag = Global.DirectTag, Domain = [domainTag],
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
DomainStrategy = Global.AsIs,
|
||||||
|
DomainStrategy4Singbox = string.Empty,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||||
|
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||||
|
|
||||||
|
var hasExpectedRule = cfg.dns.rules?.Any(r =>
|
||||||
|
r.server == Global.SingboxDirectDNSTag
|
||||||
|
&& r.ip_cidr?.Contains("192.168.0.0/16") == true
|
||||||
|
&& r.rule_set?.Contains(expectedRuleSetTag) == true
|
||||||
|
&& r.rule_set?.Contains("geoip-cn") == true) ?? false;
|
||||||
|
hasExpectedRule.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_Hosts_ShouldPopulateHostsServerAndDomainResolver()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||||
|
config.SimpleDNSItem.Hosts = "resolver.example 1.1.1.1";
|
||||||
|
config.SimpleDNSItem.DirectDNS = "https://resolver.example/dns-query";
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box);
|
||||||
|
|
||||||
|
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||||
|
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||||
|
|
||||||
|
var hostsServer = cfg.dns.servers.FirstOrDefault(s => s.tag == Global.SingboxHostsDNSTag);
|
||||||
|
hostsServer.Should().NotBeNull();
|
||||||
|
hostsServer!.predefined.Should().ContainKey("resolver.example");
|
||||||
|
hostsServer.predefined!["resolver.example"].Should().Contain("1.1.1.1");
|
||||||
|
|
||||||
|
var directServer = cfg.dns.servers.FirstOrDefault(s => s.tag == Global.SingboxDirectDNSTag);
|
||||||
|
directServer.Should().NotBeNull();
|
||||||
|
directServer!.domain_resolver.Should().Be(Global.SingboxHostsDNSTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_RawDnsEnabled_ShouldUseCustomDnsAndInjectLocalResolver()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||||
|
var rawDns = new Dns4Sbox
|
||||||
|
{
|
||||||
|
servers =
|
||||||
|
[
|
||||||
|
new Server4Sbox { tag = "remote", type = "udp", server = "8.8.8.8", detour = Global.ProxyTag, }
|
||||||
|
],
|
||||||
|
rules = [],
|
||||||
|
};
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||||
|
{
|
||||||
|
RawDnsItem = new DNSItem
|
||||||
|
{
|
||||||
|
Id = "dns-raw-1",
|
||||||
|
Remarks = "raw",
|
||||||
|
Enabled = true,
|
||||||
|
CoreType = ECoreType.sing_box,
|
||||||
|
NormalDNS = JsonUtils.Serialize(rawDns),
|
||||||
|
DomainDNSAddress = "1.1.1.1",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||||
|
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||||
|
|
||||||
|
cfg.dns.servers.Should().Contain(s => s.tag == "remote" && s.type == "udp" && s.server == "8.8.8.8");
|
||||||
|
cfg.dns.servers.Should().Contain(s => s.tag == Global.SingboxLocalDNSTag);
|
||||||
|
cfg.dns.rules.Should().Contain(r => r.clash_mode == ERuleMode.Global.ToString());
|
||||||
|
cfg.dns.rules.Should().Contain(r => r.clash_mode == ERuleMode.Direct.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,539 @@
|
||||||
|
using AwesomeAssertions;
|
||||||
|
using ServiceLib.Common;
|
||||||
|
using ServiceLib.Enums;
|
||||||
|
using ServiceLib.Models;
|
||||||
|
using ServiceLib.Services.CoreConfig;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace ServiceLib.Tests.CoreConfig.V2ray;
|
||||||
|
|
||||||
|
public class CoreConfigV2rayServiceTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_ShouldGenerateBasicProxyConfig()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray);
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray);
|
||||||
|
|
||||||
|
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue();
|
||||||
|
result.Data.Should().NotBeNull();
|
||||||
|
|
||||||
|
var v2rayConfig = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString());
|
||||||
|
v2rayConfig.Should().NotBeNull();
|
||||||
|
v2rayConfig!.outbounds.Should().Contain(o => o.tag == Global.ProxyTag && o.protocol == "vmess");
|
||||||
|
v2rayConfig.inbounds.Should().Contain(i => i.protocol == nameof(EInboundProtocol.mixed));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_PolicyGroup_ShouldExpandChildrenAndBuildBalancer()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n1", "node-1");
|
||||||
|
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n2", "node-2");
|
||||||
|
var group = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, "g1", "group",
|
||||||
|
[n1.IndexId, n2.IndexId]);
|
||||||
|
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, group, ECoreType.Xray);
|
||||||
|
context.AllProxiesMap[n1.IndexId] = n1;
|
||||||
|
context.AllProxiesMap[n2.IndexId] = n2;
|
||||||
|
context.AllProxiesMap[group.IndexId] = group;
|
||||||
|
|
||||||
|
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue();
|
||||||
|
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||||
|
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("proxy-1-", StringComparison.Ordinal));
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("proxy-2-", StringComparison.Ordinal));
|
||||||
|
cfg.routing.balancers.Should().NotBeNull();
|
||||||
|
cfg.routing.balancers!.Should().Contain(b => b.tag == Global.ProxyTag + Global.BalancerTagSuffix);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_ProxyChain_ShouldBuildDialerProxyChain()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n1", "node-1");
|
||||||
|
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n2", "node-2");
|
||||||
|
var chain = CoreConfigTestFactory.CreateProxyChainNode(ECoreType.Xray, "c1", "chain", [n1.IndexId, n2.IndexId]);
|
||||||
|
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, chain, ECoreType.Xray);
|
||||||
|
context.AllProxiesMap[n1.IndexId] = n1;
|
||||||
|
context.AllProxiesMap[n2.IndexId] = n2;
|
||||||
|
context.AllProxiesMap[chain.IndexId] = chain;
|
||||||
|
|
||||||
|
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue();
|
||||||
|
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||||
|
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("chain-proxy-1-", StringComparison.Ordinal));
|
||||||
|
var hasDialerChain = cfg.outbounds.Any(o =>
|
||||||
|
o.tag == Global.ProxyTag
|
||||||
|
&& o.streamSettings is not null
|
||||||
|
&& o.streamSettings.sockopt is not null
|
||||||
|
&& (o.streamSettings.sockopt.dialerProxy ?? string.Empty).StartsWith("chain-proxy-1-",
|
||||||
|
StringComparison.Ordinal));
|
||||||
|
hasDialerChain.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_PolicyGroupWithProxyChain_ShouldBuildCombinedOutbounds()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n1", "node-1");
|
||||||
|
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n2", "node-2");
|
||||||
|
var n3 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n3", "node-3");
|
||||||
|
var chain = CoreConfigTestFactory.CreateProxyChainNode(ECoreType.Xray, "c1", "chain", [n1.IndexId, n2.IndexId]);
|
||||||
|
var group = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, "g1", "group",
|
||||||
|
[chain.IndexId, n3.IndexId]);
|
||||||
|
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, group, ECoreType.Xray);
|
||||||
|
context.AllProxiesMap[n1.IndexId] = n1;
|
||||||
|
context.AllProxiesMap[n2.IndexId] = n2;
|
||||||
|
context.AllProxiesMap[n3.IndexId] = n3;
|
||||||
|
context.AllProxiesMap[chain.IndexId] = chain;
|
||||||
|
context.AllProxiesMap[group.IndexId] = group;
|
||||||
|
|
||||||
|
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue();
|
||||||
|
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||||
|
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("proxy-1-", StringComparison.Ordinal));
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("chain-proxy-1-", StringComparison.Ordinal));
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("proxy-2-", StringComparison.Ordinal));
|
||||||
|
cfg.routing.balancers.Should().NotBeNull();
|
||||||
|
cfg.routing.balancers!.Should().Contain(b => b.tag == Global.ProxyTag + Global.BalancerTagSuffix);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_ProxyChainWithPolicyGroup_ShouldBuildClonedChainBranches()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n1", "node-1");
|
||||||
|
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n2", "node-2");
|
||||||
|
var n3 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n3", "node-3");
|
||||||
|
var group = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, "g1", "group",
|
||||||
|
[n1.IndexId, n2.IndexId]);
|
||||||
|
var chain = CoreConfigTestFactory.CreateProxyChainNode(ECoreType.Xray, "c1", "chain",
|
||||||
|
[group.IndexId, n3.IndexId]);
|
||||||
|
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, chain, ECoreType.Xray);
|
||||||
|
context.AllProxiesMap[n1.IndexId] = n1;
|
||||||
|
context.AllProxiesMap[n2.IndexId] = n2;
|
||||||
|
context.AllProxiesMap[n3.IndexId] = n3;
|
||||||
|
context.AllProxiesMap[group.IndexId] = group;
|
||||||
|
context.AllProxiesMap[chain.IndexId] = chain;
|
||||||
|
|
||||||
|
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue();
|
||||||
|
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||||
|
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("chain-proxy-1-group-1-", StringComparison.Ordinal));
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("chain-proxy-1-group-2-", StringComparison.Ordinal));
|
||||||
|
|
||||||
|
var proxyCloneCount = cfg.outbounds.Count(o => o.tag.StartsWith("proxy-clone-", StringComparison.Ordinal));
|
||||||
|
proxyCloneCount.Should().Be(2);
|
||||||
|
|
||||||
|
var allCloneDialersPointToGroupBranches = cfg.outbounds
|
||||||
|
.Where(o => o.tag.StartsWith("proxy-clone-", StringComparison.Ordinal))
|
||||||
|
.All(o => (o.streamSettings?.sockopt?.dialerProxy ?? string.Empty).StartsWith("chain-proxy-1-group-",
|
||||||
|
StringComparison.Ordinal));
|
||||||
|
allCloneDialersPointToGroupBranches.Should().BeTrue();
|
||||||
|
|
||||||
|
cfg.routing.balancers.Should().NotBeNull();
|
||||||
|
cfg.routing.balancers!.Should().Contain(b => b.tag == Global.ProxyTag + Global.BalancerTagSuffix);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_RoutingSplit_DirectAndBlock_ShouldApplyRules()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
|
||||||
|
{
|
||||||
|
RoutingItem = new RoutingItem
|
||||||
|
{
|
||||||
|
Id = "r-split-1",
|
||||||
|
Remarks = "split-direct-block",
|
||||||
|
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||||
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Enabled = true,
|
||||||
|
RuleType = ERuleType.Routing,
|
||||||
|
OutboundTag = Global.DirectTag,
|
||||||
|
Domain = ["full:direct.example.com"],
|
||||||
|
},
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Enabled = true,
|
||||||
|
RuleType = ERuleType.Routing,
|
||||||
|
OutboundTag = Global.BlockTag,
|
||||||
|
Domain = ["full:block.example.com"],
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
DomainStrategy = Global.AsIs,
|
||||||
|
DomainStrategy4Singbox = string.Empty,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue();
|
||||||
|
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||||
|
|
||||||
|
var hasDirectRule = cfg.routing.rules.Any(r =>
|
||||||
|
r.domain != null
|
||||||
|
&& r.domain.Contains("full:direct.example.com")
|
||||||
|
&& r.outboundTag == Global.DirectTag);
|
||||||
|
hasDirectRule.Should().BeTrue();
|
||||||
|
|
||||||
|
var hasBlockRule = cfg.routing.rules.Any(r =>
|
||||||
|
r.domain != null
|
||||||
|
&& r.domain.Contains("full:block.example.com")
|
||||||
|
&& r.outboundTag == Global.BlockTag);
|
||||||
|
hasBlockRule.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_RoutingSplit_ByRemark_ShouldGenerateTargetOutbound()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||||
|
var routeNode = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n-route", "route-node");
|
||||||
|
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
|
||||||
|
{
|
||||||
|
RoutingItem = new RoutingItem
|
||||||
|
{
|
||||||
|
Id = "r-split-2",
|
||||||
|
Remarks = "split-remark",
|
||||||
|
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||||
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Enabled = true,
|
||||||
|
RuleType = ERuleType.Routing,
|
||||||
|
OutboundTag = routeNode.Remarks,
|
||||||
|
Domain = ["full:route.example.com"],
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
DomainStrategy = Global.AsIs,
|
||||||
|
DomainStrategy4Singbox = string.Empty,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
context.AllProxiesMap[$"remark:{routeNode.Remarks}"] = routeNode;
|
||||||
|
|
||||||
|
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue();
|
||||||
|
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||||
|
var expectedPrefix = $"{routeNode.IndexId}-{Global.ProxyTag}-{routeNode.Remarks}";
|
||||||
|
|
||||||
|
cfg.outbounds.Should().Contain(o => o.tag.StartsWith(expectedPrefix, StringComparison.Ordinal));
|
||||||
|
var hasRouteRule = cfg.routing.rules.Any(r =>
|
||||||
|
r.domain != null
|
||||||
|
&& r.domain.Contains("full:route.example.com")
|
||||||
|
&& (r.outboundTag ?? string.Empty).StartsWith(expectedPrefix, StringComparison.Ordinal));
|
||||||
|
hasRouteRule.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_DirectExpectedIPs_ShouldApplyExpectedIPsToDirectDnsServer()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfigWithDirectExpectedIPs(ECoreType.Xray, "192.168.0.0/16,geoip:cn");
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
|
||||||
|
{
|
||||||
|
RoutingItem = new RoutingItem
|
||||||
|
{
|
||||||
|
Id = "r-dns-direct-expected",
|
||||||
|
Remarks = "dns-direct-expected",
|
||||||
|
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||||
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Enabled = true,
|
||||||
|
RuleType = ERuleType.DNS,
|
||||||
|
OutboundTag = Global.DirectTag,
|
||||||
|
Domain = ["geosite:cn"],
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
DomainStrategy = Global.AsIs,
|
||||||
|
DomainStrategy4Singbox = string.Empty,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue();
|
||||||
|
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||||
|
var dns = JsonUtils.Deserialize<Dns4Ray>(JsonUtils.Serialize(cfg.dns))!;
|
||||||
|
|
||||||
|
var dnsServers = dns.servers
|
||||||
|
.Select(s => JsonUtils.Deserialize<DnsServer4Ray>(JsonUtils.Serialize(s)))
|
||||||
|
.Where(s => s is not null)
|
||||||
|
.Cast<DnsServer4Ray>()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var hasExpectedServer = dnsServers.Any(s =>
|
||||||
|
(s.tag ?? string.Empty).StartsWith(Global.DirectDnsTag, StringComparison.Ordinal)
|
||||||
|
&& s.domains?.Contains("geosite:cn") == true
|
||||||
|
&& s.expectedIPs?.Contains("192.168.0.0/16") == true
|
||||||
|
&& s.expectedIPs?.Contains("geoip:cn") == true);
|
||||||
|
hasExpectedServer.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_BootstrapDNS_ShouldApplyToDnsServerDomains()
|
||||||
|
{
|
||||||
|
var bootstrapDns = "8.8.8.8";
|
||||||
|
var config = CoreConfigTestFactory.CreateConfigWithBootstrapDNS(ECoreType.Xray, bootstrapDns);
|
||||||
|
config.SimpleDNSItem.DirectDNS = "https://dns-direct.example/dns-query";
|
||||||
|
config.SimpleDNSItem.RemoteDNS = "https://dns-remote.example/dns-query";
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray);
|
||||||
|
|
||||||
|
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue();
|
||||||
|
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||||
|
var dns = JsonUtils.Deserialize<Dns4Ray>(JsonUtils.Serialize(cfg.dns))!;
|
||||||
|
|
||||||
|
var dnsServers = dns.servers
|
||||||
|
.Select(s => JsonUtils.Deserialize<DnsServer4Ray>(JsonUtils.Serialize(s)))
|
||||||
|
.Where(s => s is not null)
|
||||||
|
.Cast<DnsServer4Ray>()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var hasBootstrapServer = dnsServers.Any(s =>
|
||||||
|
s.address == bootstrapDns
|
||||||
|
&& s.domains?.Contains("full:dns-direct.example") == true
|
||||||
|
&& s.domains?.Contains("full:dns-remote.example") == true);
|
||||||
|
hasBootstrapServer.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_DnsFallback_LastRuleDirect_ShouldUseDirectDnsServers()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||||
|
config.SimpleDNSItem.DirectDNS = "1.1.1.1";
|
||||||
|
config.SimpleDNSItem.RemoteDNS = "9.9.9.9";
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
|
||||||
|
{
|
||||||
|
RoutingItem = new RoutingItem
|
||||||
|
{
|
||||||
|
Id = "r-direct-final",
|
||||||
|
Remarks = "direct-final",
|
||||||
|
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||||
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Enabled = true,
|
||||||
|
RuleType = ERuleType.Routing,
|
||||||
|
OutboundTag = Global.DirectTag,
|
||||||
|
Ip = ["0.0.0.0/0"],
|
||||||
|
Port = "0-65535",
|
||||||
|
Network = "tcp,udp",
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
DomainStrategy = Global.AsIs,
|
||||||
|
DomainStrategy4Singbox = string.Empty,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue();
|
||||||
|
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||||
|
var dns = JsonUtils.Deserialize<Dns4Ray>(JsonUtils.Serialize(cfg.dns))!;
|
||||||
|
var dnsServers = dns.servers
|
||||||
|
.Select(s => JsonUtils.Deserialize<DnsServer4Ray>(JsonUtils.Serialize(s)))
|
||||||
|
.Where(s => s is not null)
|
||||||
|
.Cast<DnsServer4Ray>()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var hasDirectFallback = dnsServers.Any(s =>
|
||||||
|
(s.tag ?? string.Empty).StartsWith(Global.DirectDnsTag, StringComparison.Ordinal)
|
||||||
|
&& s.address == "1.1.1.1");
|
||||||
|
hasDirectFallback.Should().BeTrue();
|
||||||
|
|
||||||
|
var hasRemoteFallback = dnsServers.Any(s => s.address == "9.9.9.9");
|
||||||
|
hasRemoteFallback.Should().BeFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_DirectExpectedIPs_NonMatchingRegion_ShouldNotApplyExpectedIPs()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfigWithDirectExpectedIPs(ECoreType.Xray, "192.168.0.0/16,geoip:cn");
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
|
||||||
|
{
|
||||||
|
RoutingItem = new RoutingItem
|
||||||
|
{
|
||||||
|
Id = "r-dns-direct-unmatched",
|
||||||
|
Remarks = "dns-direct-unmatched",
|
||||||
|
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||||
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Enabled = true,
|
||||||
|
RuleType = ERuleType.DNS,
|
||||||
|
OutboundTag = Global.DirectTag,
|
||||||
|
Domain = ["geosite:us"],
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
DomainStrategy = Global.AsIs,
|
||||||
|
DomainStrategy4Singbox = string.Empty,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue();
|
||||||
|
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||||
|
var dns = JsonUtils.Deserialize<Dns4Ray>(JsonUtils.Serialize(cfg.dns))!;
|
||||||
|
var dnsServers = dns.servers
|
||||||
|
.Select(s => JsonUtils.Deserialize<DnsServer4Ray>(JsonUtils.Serialize(s)))
|
||||||
|
.Where(s => s is not null)
|
||||||
|
.Cast<DnsServer4Ray>()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var hasExpectedIPs = dnsServers.Any(s =>
|
||||||
|
s.expectedIPs?.Contains("192.168.0.0/16") == true
|
||||||
|
|| s.expectedIPs?.Contains("geoip:cn") == true);
|
||||||
|
hasExpectedIPs.Should().BeFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData("geosite:cn")]
|
||||||
|
[InlineData("geosite:geolocation-cn")]
|
||||||
|
[InlineData("geosite:tld-cn")]
|
||||||
|
public void GenerateClientConfigContent_DirectExpectedIPs_RegionVariant_ShouldApplyExpectedIPs(string domainTag)
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfigWithDirectExpectedIPs(ECoreType.Xray, "192.168.0.0/16,geoip:cn");
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
|
||||||
|
{
|
||||||
|
RoutingItem = new RoutingItem
|
||||||
|
{
|
||||||
|
Id = "r-dns-direct-variant",
|
||||||
|
Remarks = "dns-direct-variant",
|
||||||
|
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||||
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Enabled = true, RuleType = ERuleType.DNS, OutboundTag = Global.DirectTag, Domain = [domainTag],
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
DomainStrategy = Global.AsIs,
|
||||||
|
DomainStrategy4Singbox = string.Empty,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue();
|
||||||
|
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||||
|
var dns = JsonUtils.Deserialize<Dns4Ray>(JsonUtils.Serialize(cfg.dns))!;
|
||||||
|
var dnsServers = dns.servers
|
||||||
|
.Select(s => JsonUtils.Deserialize<DnsServer4Ray>(JsonUtils.Serialize(s)))
|
||||||
|
.Where(s => s is not null)
|
||||||
|
.Cast<DnsServer4Ray>()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var hasExpectedServer = dnsServers.Any(s =>
|
||||||
|
(s.tag ?? string.Empty).StartsWith(Global.DirectDnsTag, StringComparison.Ordinal)
|
||||||
|
&& s.domains?.Contains(domainTag) == true
|
||||||
|
&& s.expectedIPs?.Contains("192.168.0.0/16") == true
|
||||||
|
&& s.expectedIPs?.Contains("geoip:cn") == true);
|
||||||
|
hasExpectedServer.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_Hosts_ShouldPopulateDnsHosts()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||||
|
config.SimpleDNSItem.Hosts = "resolver.example 1.1.1.1";
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray);
|
||||||
|
|
||||||
|
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue();
|
||||||
|
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||||
|
var dns = JsonUtils.Deserialize<Dns4Ray>(JsonUtils.Serialize(cfg.dns))!;
|
||||||
|
|
||||||
|
dns.hosts.Should().NotBeNull();
|
||||||
|
dns.hosts!.Should().ContainKey("resolver.example");
|
||||||
|
JsonUtils.Serialize(dns.hosts!["resolver.example"]).Should().Contain("1.1.1.1");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GenerateClientConfigContent_RawDnsEnabled_ShouldUseCustomDnsConfig()
|
||||||
|
{
|
||||||
|
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||||
|
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||||
|
|
||||||
|
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||||
|
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
|
||||||
|
{
|
||||||
|
RawDnsItem = new DNSItem
|
||||||
|
{
|
||||||
|
Id = "dns-raw-1",
|
||||||
|
Remarks = "raw",
|
||||||
|
Enabled = true,
|
||||||
|
CoreType = ECoreType.Xray,
|
||||||
|
NormalDNS = "{\"servers\":[\"8.8.8.8\"],\"hosts\":{\"raw.example\":\"1.1.1.1\"}}",
|
||||||
|
DomainStrategy4Freedom = "UseIPv4",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||||
|
|
||||||
|
result.Success.Should().BeTrue();
|
||||||
|
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||||
|
var dns = JsonUtils.Deserialize<Dns4Ray>(JsonUtils.Serialize(cfg.dns))!;
|
||||||
|
|
||||||
|
JsonUtils.Serialize(dns.servers).Should().Contain("8.8.8.8");
|
||||||
|
dns.hosts.Should().NotBeNull();
|
||||||
|
dns.hosts!.Should().ContainKey("raw.example");
|
||||||
|
JsonUtils.Serialize(dns.hosts!["raw.example"]).Should().Contain("1.1.1.1");
|
||||||
|
|
||||||
|
var directOutbound = cfg.outbounds.FirstOrDefault(o => o.tag == Global.DirectTag && o.protocol == "freedom");
|
||||||
|
directOutbound.Should().NotBeNull();
|
||||||
|
directOutbound!.settings.domainStrategy.Should().Be("UseIPv4");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,228 +0,0 @@
|
||||||
using System.Text.Json.Nodes;
|
|
||||||
using ServiceLib;
|
|
||||||
using ServiceLib.Enums;
|
|
||||||
using ServiceLib.Models;
|
|
||||||
using ServiceLib.Services.CoreConfig;
|
|
||||||
using Xunit;
|
|
||||||
|
|
||||||
namespace ServiceLib.Tests;
|
|
||||||
|
|
||||||
public class CoreConfigV2rayServiceTests
|
|
||||||
{
|
|
||||||
private const string SendThrough = "198.51.100.10";
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void GenerateClientConfigContent_OnlyAppliesSendThroughToRemoteProxyOutbounds()
|
|
||||||
{
|
|
||||||
var node = CreateProxyNode("proxy-1", "198.51.100.1", 443);
|
|
||||||
var service = new CoreConfigV2rayService(CreateContext(node));
|
|
||||||
|
|
||||||
var result = service.GenerateClientConfigContent();
|
|
||||||
|
|
||||||
Assert.True(result.Success);
|
|
||||||
|
|
||||||
var outbounds = GetOutbounds(result.Data?.ToString());
|
|
||||||
var proxyOutbound = outbounds.Single(outbound => outbound["tag"]!.GetValue<string>() == Global.ProxyTag);
|
|
||||||
var directOutbound = outbounds.Single(outbound => outbound["tag"]!.GetValue<string>() == Global.DirectTag);
|
|
||||||
var blockOutbound = outbounds.Single(outbound => outbound["tag"]!.GetValue<string>() == Global.BlockTag);
|
|
||||||
|
|
||||||
Assert.Equal(SendThrough, proxyOutbound["sendThrough"]?.GetValue<string>());
|
|
||||||
Assert.Null(directOutbound["sendThrough"]);
|
|
||||||
Assert.Null(blockOutbound["sendThrough"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void GenerateClientConfigContent_OnlyAppliesSendThroughToChainExitOutbounds()
|
|
||||||
{
|
|
||||||
var exitNode = CreateProxyNode("exit", "198.51.100.2", 443);
|
|
||||||
var entryNode = CreateProxyNode("entry", "198.51.100.3", 443);
|
|
||||||
var chainNode = CreateChainNode("chain", exitNode, entryNode);
|
|
||||||
|
|
||||||
var service = new CoreConfigV2rayService(CreateContext(
|
|
||||||
chainNode,
|
|
||||||
allProxiesMap: new Dictionary<string, ProfileItem>
|
|
||||||
{
|
|
||||||
[exitNode.IndexId] = exitNode,
|
|
||||||
[entryNode.IndexId] = entryNode,
|
|
||||||
}));
|
|
||||||
|
|
||||||
var result = service.GenerateClientConfigContent();
|
|
||||||
|
|
||||||
Assert.True(result.Success);
|
|
||||||
|
|
||||||
var outbounds = GetOutbounds(result.Data?.ToString())
|
|
||||||
.Where(outbound => outbound["protocol"]?.GetValue<string>() is not ("freedom" or "blackhole" or "dns"))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var sendThroughOutbounds = outbounds
|
|
||||||
.Where(outbound => outbound["sendThrough"]?.GetValue<string>() == SendThrough)
|
|
||||||
.ToList();
|
|
||||||
var chainedOutbounds = outbounds
|
|
||||||
.Where(outbound => outbound["streamSettings"]?["sockopt"]?["dialerProxy"] is not null)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
Assert.Single(sendThroughOutbounds);
|
|
||||||
Assert.All(chainedOutbounds, outbound => Assert.Null(outbound["sendThrough"]));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void GenerateClientConfigContent_DoesNotApplySendThroughToTunRelayLoopbackOutbound()
|
|
||||||
{
|
|
||||||
var node = CreateProxyNode("proxy-1", "198.51.100.4", 443);
|
|
||||||
var config = CreateConfig();
|
|
||||||
config.TunModeItem.EnableLegacyProtect = false;
|
|
||||||
|
|
||||||
var service = new CoreConfigV2rayService(CreateContext(
|
|
||||||
node,
|
|
||||||
config,
|
|
||||||
isTunEnabled: true,
|
|
||||||
tunProtectSsPort: 10811,
|
|
||||||
proxyRelaySsPort: 10812));
|
|
||||||
|
|
||||||
var result = service.GenerateClientConfigContent();
|
|
||||||
|
|
||||||
Assert.True(result.Success);
|
|
||||||
|
|
||||||
var outbounds = GetOutbounds(result.Data?.ToString());
|
|
||||||
Assert.DoesNotContain(outbounds, outbound => outbound["sendThrough"]?.GetValue<string>() == SendThrough);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static CoreConfigContext CreateContext(
|
|
||||||
ProfileItem node,
|
|
||||||
Config? config = null,
|
|
||||||
Dictionary<string, ProfileItem>? allProxiesMap = null,
|
|
||||||
bool isTunEnabled = false,
|
|
||||||
int tunProtectSsPort = 0,
|
|
||||||
int proxyRelaySsPort = 0)
|
|
||||||
{
|
|
||||||
return new CoreConfigContext
|
|
||||||
{
|
|
||||||
Node = node,
|
|
||||||
RunCoreType = ECoreType.Xray,
|
|
||||||
AppConfig = config ?? CreateConfig(),
|
|
||||||
AllProxiesMap = allProxiesMap ?? new(),
|
|
||||||
SimpleDnsItem = new SimpleDNSItem(),
|
|
||||||
IsTunEnabled = isTunEnabled,
|
|
||||||
TunProtectSocksPort = tunProtectSsPort,
|
|
||||||
ProxyRelaySocksPort = proxyRelaySsPort,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Config CreateConfig()
|
|
||||||
{
|
|
||||||
return new Config
|
|
||||||
{
|
|
||||||
IndexId = string.Empty,
|
|
||||||
SubIndexId = string.Empty,
|
|
||||||
CoreBasicItem = new()
|
|
||||||
{
|
|
||||||
LogEnabled = false,
|
|
||||||
Loglevel = "warning",
|
|
||||||
MuxEnabled = false,
|
|
||||||
DefAllowInsecure = false,
|
|
||||||
DefFingerprint = Global.Fingerprints.First(),
|
|
||||||
DefUserAgent = string.Empty,
|
|
||||||
SendThrough = SendThrough,
|
|
||||||
EnableFragment = false,
|
|
||||||
EnableCacheFile4Sbox = true,
|
|
||||||
},
|
|
||||||
TunModeItem = new()
|
|
||||||
{
|
|
||||||
EnableTun = false,
|
|
||||||
AutoRoute = true,
|
|
||||||
StrictRoute = true,
|
|
||||||
Stack = string.Empty,
|
|
||||||
Mtu = 9000,
|
|
||||||
EnableIPv6Address = false,
|
|
||||||
IcmpRouting = Global.TunIcmpRoutingPolicies.First(),
|
|
||||||
EnableLegacyProtect = false,
|
|
||||||
},
|
|
||||||
KcpItem = new(),
|
|
||||||
GrpcItem = new(),
|
|
||||||
RoutingBasicItem = new()
|
|
||||||
{
|
|
||||||
DomainStrategy = Global.DomainStrategies.First(),
|
|
||||||
DomainStrategy4Singbox = Global.DomainStrategies4Sbox.First(),
|
|
||||||
RoutingIndexId = string.Empty,
|
|
||||||
},
|
|
||||||
GuiItem = new(),
|
|
||||||
MsgUIItem = new(),
|
|
||||||
UiItem = new()
|
|
||||||
{
|
|
||||||
CurrentLanguage = "en",
|
|
||||||
CurrentFontFamily = string.Empty,
|
|
||||||
MainColumnItem = [],
|
|
||||||
WindowSizeItem = [],
|
|
||||||
},
|
|
||||||
ConstItem = new(),
|
|
||||||
SpeedTestItem = new(),
|
|
||||||
Mux4RayItem = new()
|
|
||||||
{
|
|
||||||
Concurrency = 8,
|
|
||||||
XudpConcurrency = 8,
|
|
||||||
XudpProxyUDP443 = "reject",
|
|
||||||
},
|
|
||||||
Mux4SboxItem = new()
|
|
||||||
{
|
|
||||||
Protocol = string.Empty,
|
|
||||||
},
|
|
||||||
HysteriaItem = new(),
|
|
||||||
ClashUIItem = new()
|
|
||||||
{
|
|
||||||
ConnectionsColumnItem = [],
|
|
||||||
},
|
|
||||||
SystemProxyItem = new(),
|
|
||||||
WebDavItem = new(),
|
|
||||||
CheckUpdateItem = new(),
|
|
||||||
Fragment4RayItem = null,
|
|
||||||
Inbound = [new InItem
|
|
||||||
{
|
|
||||||
Protocol = EInboundProtocol.socks.ToString(),
|
|
||||||
LocalPort = 10808,
|
|
||||||
UdpEnabled = true,
|
|
||||||
SniffingEnabled = true,
|
|
||||||
RouteOnly = false,
|
|
||||||
}],
|
|
||||||
GlobalHotkeys = [],
|
|
||||||
CoreTypeItem = [],
|
|
||||||
SimpleDNSItem = new(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ProfileItem CreateProxyNode(string indexId, string address, int port)
|
|
||||||
{
|
|
||||||
return new ProfileItem
|
|
||||||
{
|
|
||||||
IndexId = indexId,
|
|
||||||
Remarks = indexId,
|
|
||||||
ConfigType = EConfigType.SOCKS,
|
|
||||||
CoreType = ECoreType.Xray,
|
|
||||||
Address = address,
|
|
||||||
Port = port,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ProfileItem CreateChainNode(string indexId, params ProfileItem[] nodes)
|
|
||||||
{
|
|
||||||
var chainNode = new ProfileItem
|
|
||||||
{
|
|
||||||
IndexId = indexId,
|
|
||||||
Remarks = indexId,
|
|
||||||
ConfigType = EConfigType.ProxyChain,
|
|
||||||
CoreType = ECoreType.Xray,
|
|
||||||
};
|
|
||||||
chainNode.SetProtocolExtra(new ProtocolExtraItem
|
|
||||||
{
|
|
||||||
ChildItems = string.Join(',', nodes.Select(node => node.IndexId)),
|
|
||||||
});
|
|
||||||
return chainNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<JsonObject> GetOutbounds(string? json)
|
|
||||||
{
|
|
||||||
var root = JsonNode.Parse(json ?? throw new InvalidOperationException("Config JSON is missing"))?.AsObject()
|
|
||||||
?? throw new InvalidOperationException("Failed to parse config JSON");
|
|
||||||
return root["outbounds"]?.AsArray().Select(node => node!.AsObject()).ToList()
|
|
||||||
?? throw new InvalidOperationException("Config JSON does not contain outbounds");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
173
v2rayN/ServiceLib.Tests/Fmt/FmtHandlerTests.cs
Normal file
173
v2rayN/ServiceLib.Tests/Fmt/FmtHandlerTests.cs
Normal file
|
|
@ -0,0 +1,173 @@
|
||||||
|
using AwesomeAssertions;
|
||||||
|
using ServiceLib.Handler.Fmt;
|
||||||
|
using ServiceLib.Models;
|
||||||
|
using ServiceLib.Enums;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace ServiceLib.Tests.Fmt;
|
||||||
|
|
||||||
|
public class FmtHandlerTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void GetShareUriAndResolveConfig_Vmess_ShouldRoundTripBasicFields()
|
||||||
|
{
|
||||||
|
var source = CreateVmessProfile();
|
||||||
|
|
||||||
|
var resolved = ExportThenImport(source);
|
||||||
|
|
||||||
|
resolved.ConfigType.Should().Be(EConfigType.VMess);
|
||||||
|
resolved.Remarks.Should().Be(source.Remarks);
|
||||||
|
resolved.Address.Should().Be(source.Address);
|
||||||
|
resolved.Port.Should().Be(source.Port);
|
||||||
|
resolved.Password.Should().Be(source.Password);
|
||||||
|
resolved.GetProtocolExtra().AlterId.Should().Be(source.GetProtocolExtra().AlterId);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GetShareUriAndResolveConfig_Vless_ShouldRoundTripBasicFields()
|
||||||
|
{
|
||||||
|
var source = CreateVlessProfile();
|
||||||
|
|
||||||
|
var resolved = ExportThenImport(source);
|
||||||
|
|
||||||
|
resolved.ConfigType.Should().Be(EConfigType.VLESS);
|
||||||
|
resolved.Remarks.Should().Be(source.Remarks);
|
||||||
|
resolved.Address.Should().Be(source.Address);
|
||||||
|
resolved.Port.Should().Be(source.Port);
|
||||||
|
resolved.Password.Should().Be(source.Password);
|
||||||
|
resolved.GetProtocolExtra().VlessEncryption.Should().Be(Global.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GetShareUriAndResolveConfig_Shadowsocks_ShouldRoundTripBasicFields()
|
||||||
|
{
|
||||||
|
var source = CreateShadowsocksProfile();
|
||||||
|
|
||||||
|
var resolved = ExportThenImport(source);
|
||||||
|
|
||||||
|
resolved.ConfigType.Should().Be(EConfigType.Shadowsocks);
|
||||||
|
resolved.Remarks.Should().Be(source.Remarks);
|
||||||
|
resolved.Address.Should().Be(source.Address);
|
||||||
|
resolved.Port.Should().Be(source.Port);
|
||||||
|
resolved.Password.Should().Be(source.Password);
|
||||||
|
resolved.GetProtocolExtra().SsMethod.Should().Be(source.GetProtocolExtra().SsMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GetShareUriAndResolveConfig_Socks_ShouldRoundTripBasicFields()
|
||||||
|
{
|
||||||
|
var source = CreateSocksProfile();
|
||||||
|
|
||||||
|
var resolved = ExportThenImport(source);
|
||||||
|
|
||||||
|
resolved.ConfigType.Should().Be(EConfigType.SOCKS);
|
||||||
|
resolved.Remarks.Should().Be(source.Remarks);
|
||||||
|
resolved.Address.Should().Be(source.Address);
|
||||||
|
resolved.Port.Should().Be(source.Port);
|
||||||
|
resolved.Username.Should().Be(source.Username);
|
||||||
|
resolved.Password.Should().Be(source.Password);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ResolveConfig_UnsupportedProtocol_ShouldReturnNull()
|
||||||
|
{
|
||||||
|
var resolved = FmtHandler.ResolveConfig("not-a-share-uri", out var msg);
|
||||||
|
|
||||||
|
resolved.Should().BeNull();
|
||||||
|
msg.Should().NotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GetShareUri_UnsupportedConfigType_ShouldReturnNull()
|
||||||
|
{
|
||||||
|
var item = new ProfileItem { ConfigType = EConfigType.PolicyGroup, Remarks = "group", };
|
||||||
|
|
||||||
|
var uri = FmtHandler.GetShareUri(item);
|
||||||
|
|
||||||
|
uri.Should().BeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ProfileItem ExportThenImport(ProfileItem source)
|
||||||
|
{
|
||||||
|
var uri = FmtHandler.GetShareUri(source);
|
||||||
|
|
||||||
|
uri.Should().NotBeNullOrWhiteSpace();
|
||||||
|
(uri!.StartsWith(Global.ProtocolShares[source.ConfigType], StringComparison.OrdinalIgnoreCase)).Should()
|
||||||
|
.BeTrue();
|
||||||
|
|
||||||
|
var resolved = FmtHandler.ResolveConfig(uri, out var msg);
|
||||||
|
|
||||||
|
resolved.Should().NotBeNull($"uri: {uri}, msg: {msg}");
|
||||||
|
return resolved!;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ProfileItem CreateVmessProfile()
|
||||||
|
{
|
||||||
|
var item = new ProfileItem
|
||||||
|
{
|
||||||
|
ConfigType = EConfigType.VMess,
|
||||||
|
Remarks = "vmess demo",
|
||||||
|
Address = "example.com",
|
||||||
|
Port = 443,
|
||||||
|
Password = Guid.NewGuid().ToString(),
|
||||||
|
Network = nameof(ETransport.raw),
|
||||||
|
StreamSecurity = string.Empty,
|
||||||
|
};
|
||||||
|
|
||||||
|
item.SetProtocolExtra(new ProtocolExtraItem { AlterId = "0", VmessSecurity = Global.DefaultSecurity, });
|
||||||
|
item.SetTransportExtra(new TransportExtraItem { RawHeaderType = Global.None, });
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ProfileItem CreateVlessProfile()
|
||||||
|
{
|
||||||
|
var item = new ProfileItem
|
||||||
|
{
|
||||||
|
ConfigType = EConfigType.VLESS,
|
||||||
|
Remarks = "vless demo",
|
||||||
|
Address = "vless.example",
|
||||||
|
Port = 8443,
|
||||||
|
Password = Guid.NewGuid().ToString(),
|
||||||
|
Network = nameof(ETransport.raw),
|
||||||
|
StreamSecurity = string.Empty,
|
||||||
|
};
|
||||||
|
|
||||||
|
item.SetProtocolExtra(new ProtocolExtraItem { VlessEncryption = Global.None, });
|
||||||
|
item.SetTransportExtra(new TransportExtraItem { RawHeaderType = Global.None, });
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ProfileItem CreateShadowsocksProfile()
|
||||||
|
{
|
||||||
|
var item = new ProfileItem
|
||||||
|
{
|
||||||
|
ConfigType = EConfigType.Shadowsocks,
|
||||||
|
Remarks = "ss demo",
|
||||||
|
Address = "1.2.3.4",
|
||||||
|
Port = 8388,
|
||||||
|
Password = "pass123",
|
||||||
|
Network = nameof(ETransport.raw),
|
||||||
|
StreamSecurity = string.Empty,
|
||||||
|
};
|
||||||
|
|
||||||
|
item.SetProtocolExtra(new ProtocolExtraItem { SsMethod = "aes-128-gcm", });
|
||||||
|
item.SetTransportExtra(new TransportExtraItem { RawHeaderType = Global.None, });
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ProfileItem CreateSocksProfile()
|
||||||
|
{
|
||||||
|
return new ProfileItem
|
||||||
|
{
|
||||||
|
ConfigType = EConfigType.SOCKS,
|
||||||
|
Remarks = "socks demo",
|
||||||
|
Address = "127.0.0.1",
|
||||||
|
Port = 1080,
|
||||||
|
Username = "user",
|
||||||
|
Password = "pass",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,17 +1,19 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
<IsTestProject>true</IsTestProject>
|
<IsTestProject>true</IsTestProject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AwesomeAssertions" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||||
<PackageReference Include="xunit" />
|
|
||||||
<PackageReference Include="xunit.runner.visualstudio">
|
<PackageReference Include="xunit.runner.visualstudio">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="xunit.v3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -52,10 +52,13 @@ internal static class WindowsUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task RemoveTunDevice()
|
public static async Task RemoveTunDevice()
|
||||||
|
{
|
||||||
|
var tunNameList = new List<string> { "wintunsingbox_tun", "xray_tun" };
|
||||||
|
foreach (var tunName in tunNameList)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sum = MD5.HashData(Encoding.UTF8.GetBytes("wintunsingbox_tun"));
|
var sum = MD5.HashData(Encoding.UTF8.GetBytes(tunName));
|
||||||
var guid = new Guid(sum);
|
var guid = new Guid(sum);
|
||||||
var pnpUtilPath = @"C:\Windows\System32\pnputil.exe";
|
var pnpUtilPath = @"C:\Windows\System32\pnputil.exe";
|
||||||
var arg = $$""" /remove-device "SWD\Wintun\{{{guid}}}" """;
|
var arg = $$""" /remove-device "SWD\Wintun\{{{guid}}}" """;
|
||||||
|
|
@ -68,4 +71,5 @@ internal static class WindowsUtils
|
||||||
Logging.SaveLog(_tag, ex);
|
Logging.SaveLog(_tag, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ namespace ServiceLib.Enums;
|
||||||
|
|
||||||
public enum ETransport
|
public enum ETransport
|
||||||
{
|
{
|
||||||
tcp,
|
raw,
|
||||||
kcp,
|
kcp,
|
||||||
ws,
|
ws,
|
||||||
httpupgrade,
|
httpupgrade,
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ public class Global
|
||||||
public const string V2raySampleHttpResponseFileName = NamespaceSample + "SampleHttpResponse";
|
public const string V2raySampleHttpResponseFileName = NamespaceSample + "SampleHttpResponse";
|
||||||
public const string V2raySampleInbound = NamespaceSample + "SampleInbound";
|
public const string V2raySampleInbound = NamespaceSample + "SampleInbound";
|
||||||
public const string V2raySampleOutbound = NamespaceSample + "SampleOutbound";
|
public const string V2raySampleOutbound = NamespaceSample + "SampleOutbound";
|
||||||
|
public const string V2raySampleTunInbound = NamespaceSample + "SampleTunInbound";
|
||||||
|
public const string V2raySampleTunRules = NamespaceSample + "SampleTunRules";
|
||||||
public const string SingboxSampleOutbound = NamespaceSample + "SingboxSampleOutbound";
|
public const string SingboxSampleOutbound = NamespaceSample + "SingboxSampleOutbound";
|
||||||
public const string CustomRoutingFileName = NamespaceSample + "custom_routing_";
|
public const string CustomRoutingFileName = NamespaceSample + "custom_routing_";
|
||||||
public const string TunSingboxDNSFileName = NamespaceSample + "tun_singbox_dns";
|
public const string TunSingboxDNSFileName = NamespaceSample + "tun_singbox_dns";
|
||||||
|
|
@ -42,12 +44,15 @@ public class Global
|
||||||
public const string SingboxFakeIPFilterFileName = NamespaceSample + "singbox_fakeip_filter";
|
public const string SingboxFakeIPFilterFileName = NamespaceSample + "singbox_fakeip_filter";
|
||||||
|
|
||||||
public const string DefaultSecurity = "auto";
|
public const string DefaultSecurity = "auto";
|
||||||
public const string DefaultNetwork = "tcp";
|
public const string DefaultNetwork = "raw";
|
||||||
public const string TcpHeaderHttp = "http";
|
public const string RawHeaderHttp = "http";
|
||||||
public const string None = "none";
|
public const string None = "none";
|
||||||
|
public const string RawNetworkAlias = "tcp";
|
||||||
|
public const string DefaultXhttpMode = "auto";
|
||||||
public const string ProxyTag = "proxy";
|
public const string ProxyTag = "proxy";
|
||||||
public const string DirectTag = "direct";
|
public const string DirectTag = "direct";
|
||||||
public const string BlockTag = "block";
|
public const string BlockTag = "block";
|
||||||
|
public const string DnsOutboundTag = "dns";
|
||||||
public const string DnsTag = "dns-module";
|
public const string DnsTag = "dns-module";
|
||||||
public const string DirectDnsTag = "direct-dns";
|
public const string DirectDnsTag = "direct-dns";
|
||||||
public const string BalancerTagSuffix = "-round";
|
public const string BalancerTagSuffix = "-round";
|
||||||
|
|
@ -89,7 +94,7 @@ public class Global
|
||||||
public const string SingboxHostsDNSTag = "hosts_dns";
|
public const string SingboxHostsDNSTag = "hosts_dns";
|
||||||
public const string SingboxFakeDNSTag = "fake_dns";
|
public const string SingboxFakeDNSTag = "fake_dns";
|
||||||
|
|
||||||
public const int Hysteria2DefaultHopInt = 10;
|
public const int Hysteria2DefaultHopInt = 30;
|
||||||
|
|
||||||
public const string PolicyGroupExcludeKeywords = @"剩余|过期|到期|重置|[Rr]emaining|[Ee]xpir|[Rr]eset";
|
public const string PolicyGroupExcludeKeywords = @"剩余|过期|到期|重置|[Rr]emaining|[Ee]xpir|[Rr]eset";
|
||||||
|
|
||||||
|
|
@ -182,7 +187,7 @@ public class Global
|
||||||
@"https://raw.githubusercontent.com/Chocolate4U/Iran-v2ray-rules/main/v2rayN/"
|
@"https://raw.githubusercontent.com/Chocolate4U/Iran-v2ray-rules/main/v2rayN/"
|
||||||
];
|
];
|
||||||
|
|
||||||
public static readonly Dictionary<string, string> TcpHttpUserAgentTexts = new()
|
public static readonly Dictionary<string, string> RawHttpUserAgentTexts = new()
|
||||||
{
|
{
|
||||||
{"chrome","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36" },
|
{"chrome","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36" },
|
||||||
{"firefox","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0" },
|
{"firefox","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0" },
|
||||||
|
|
@ -293,14 +298,12 @@ public class Global
|
||||||
|
|
||||||
public static readonly List<string> Networks =
|
public static readonly List<string> Networks =
|
||||||
[
|
[
|
||||||
"tcp",
|
"raw",
|
||||||
"kcp",
|
|
||||||
"ws",
|
|
||||||
"httpupgrade",
|
|
||||||
"xhttp",
|
"xhttp",
|
||||||
"h2",
|
"kcp",
|
||||||
"quic",
|
"grpc",
|
||||||
"grpc"
|
"ws",
|
||||||
|
"httpupgrade"
|
||||||
];
|
];
|
||||||
|
|
||||||
public static readonly List<string> KcpHeaderTypes =
|
public static readonly List<string> KcpHeaderTypes =
|
||||||
|
|
@ -508,6 +511,7 @@ public class Global
|
||||||
[
|
[
|
||||||
"http",
|
"http",
|
||||||
"tls",
|
"tls",
|
||||||
|
"quic",
|
||||||
"bittorrent"
|
"bittorrent"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -525,7 +529,6 @@ public class Global
|
||||||
"tls",
|
"tls",
|
||||||
"quic",
|
"quic",
|
||||||
"fakedns",
|
"fakedns",
|
||||||
"fakedns+others"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public static readonly List<int> TunMtus =
|
public static readonly List<int> TunMtus =
|
||||||
|
|
|
||||||
|
|
@ -23,19 +23,6 @@ public record CoreConfigContextBuilderAllResult(
|
||||||
public NodeValidatorResult CombinedValidatorResult => new(
|
public NodeValidatorResult CombinedValidatorResult => new(
|
||||||
[.. MainResult.ValidatorResult.Errors, .. PreSocksResult?.ValidatorResult.Errors ?? []],
|
[.. MainResult.ValidatorResult.Errors, .. PreSocksResult?.ValidatorResult.Errors ?? []],
|
||||||
[.. MainResult.ValidatorResult.Warnings, .. PreSocksResult?.ValidatorResult.Warnings ?? []]);
|
[.. MainResult.ValidatorResult.Warnings, .. PreSocksResult?.ValidatorResult.Warnings ?? []]);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The main context with TunProtectSocksPort/ProxyRelaySocksPort and ProtectDomainList merged in
|
|
||||||
/// from the pre-socks result (if any). Pass this to the core runner.
|
|
||||||
/// </summary>
|
|
||||||
public CoreConfigContext ResolvedMainContext => PreSocksResult is not null
|
|
||||||
? MainResult.Context with
|
|
||||||
{
|
|
||||||
TunProtectSocksPort = PreSocksResult.Context.TunProtectSocksPort,
|
|
||||||
ProxyRelaySocksPort = PreSocksResult.Context.ProxyRelaySocksPort,
|
|
||||||
ProtectDomainList = [.. MainResult.Context.ProtectDomainList ?? [], .. PreSocksResult.Context.ProtectDomainList ?? []],
|
|
||||||
}
|
|
||||||
: MainResult.Context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CoreConfigContextBuilder
|
public class CoreConfigContextBuilder
|
||||||
|
|
@ -58,8 +45,6 @@ public class CoreConfigContextBuilder
|
||||||
IsTunEnabled = config.TunModeItem.EnableTun,
|
IsTunEnabled = config.TunModeItem.EnableTun,
|
||||||
SimpleDnsItem = config.SimpleDNSItem,
|
SimpleDnsItem = config.SimpleDNSItem,
|
||||||
ProtectDomainList = [],
|
ProtectDomainList = [],
|
||||||
TunProtectSocksPort = 0,
|
|
||||||
ProxyRelaySocksPort = 0,
|
|
||||||
RawDnsItem = await AppManager.Instance.GetDNSItem(coreType),
|
RawDnsItem = await AppManager.Instance.GetDNSItem(coreType),
|
||||||
RoutingItem = await ConfigHandler.GetDefaultRouting(config),
|
RoutingItem = await ConfigHandler.GetDefaultRouting(config),
|
||||||
};
|
};
|
||||||
|
|
@ -122,7 +107,20 @@ public class CoreConfigContextBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
var preResult = await BuildPreSocksIfNeeded(mainResult.Context);
|
var preResult = await BuildPreSocksIfNeeded(mainResult.Context);
|
||||||
return new CoreConfigContextBuilderAllResult(mainResult, preResult);
|
if (preResult is null)
|
||||||
|
{
|
||||||
|
return new CoreConfigContextBuilderAllResult(mainResult, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
var resolvedMainResult = mainResult with
|
||||||
|
{
|
||||||
|
Context = mainResult.Context with
|
||||||
|
{
|
||||||
|
IsTunEnabled = false, // main core doesn't handle tun directly when pre-socks is used
|
||||||
|
ProtectDomainList = [.. mainResult.Context.ProtectDomainList, .. preResult.Context.ProtectDomainList],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return new CoreConfigContextBuilderAllResult(resolvedMainResult, preResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -148,34 +146,9 @@ public class CoreConfigContextBuilder
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nodeContext.IsTunEnabled
|
|
||||||
|| coreType != ECoreType.Xray
|
|
||||||
|| node.ConfigType == EConfigType.Custom)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var tunProtectSocksPort = Utils.GetFreePort();
|
|
||||||
var proxyRelaySocksPort = Utils.GetFreePort();
|
|
||||||
var preItem = new ProfileItem()
|
|
||||||
{
|
|
||||||
CoreType = ECoreType.sing_box,
|
|
||||||
ConfigType = EConfigType.SOCKS,
|
|
||||||
Address = Global.Loopback,
|
|
||||||
Port = proxyRelaySocksPort,
|
|
||||||
};
|
|
||||||
var preResult2 = await Build(nodeContext.AppConfig, preItem);
|
|
||||||
return preResult2 with
|
|
||||||
{
|
|
||||||
Context = preResult2.Context with
|
|
||||||
{
|
|
||||||
ProtectDomainList = [.. nodeContext.ProtectDomainList ?? [], .. preResult2.Context.ProtectDomainList ?? []],
|
|
||||||
TunProtectSocksPort = tunProtectSocksPort,
|
|
||||||
ProxyRelaySocksPort = proxyRelaySocksPort,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resolves a node into the context, optionally wrapping it in a subscription-level proxy chain.
|
/// Resolves a node into the context, optionally wrapping it in a subscription-level proxy chain.
|
||||||
/// Returns the effective (possibly replaced) node and the validation result.
|
/// Returns the effective (possibly replaced) node and the validation result.
|
||||||
|
|
@ -340,8 +313,9 @@ public class CoreConfigContextBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
// xhttp downloadSettings address protect
|
// xhttp downloadSettings address protect
|
||||||
if (!string.IsNullOrEmpty(node.Extra)
|
var xhttpExtra = node.GetTransportExtra().XhttpExtra;
|
||||||
&& JsonUtils.ParseJson(node.Extra) is JsonObject extra
|
if (!string.IsNullOrEmpty(xhttpExtra)
|
||||||
|
&& JsonUtils.ParseJson(xhttpExtra) is JsonObject extra
|
||||||
&& extra.TryGetPropertyValue("downloadSettings", out var dsNode)
|
&& extra.TryGetPropertyValue("downloadSettings", out var dsNode)
|
||||||
&& dsNode is JsonObject downloadSettings
|
&& dsNode is JsonObject downloadSettings
|
||||||
&& downloadSettings.TryGetPropertyValue("address", out var dAddrNode)
|
&& downloadSettings.TryGetPropertyValue("address", out var dAddrNode)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ public class NodeValidator
|
||||||
[EConfigType.VMess, EConfigType.VLESS, EConfigType.Trojan, EConfigType.Shadowsocks];
|
[EConfigType.VMess, EConfigType.VLESS, EConfigType.Trojan, EConfigType.Shadowsocks];
|
||||||
|
|
||||||
private static readonly HashSet<string> SingboxShadowsocksAllowedTransports =
|
private static readonly HashSet<string> SingboxShadowsocksAllowedTransports =
|
||||||
[nameof(ETransport.tcp), nameof(ETransport.ws), nameof(ETransport.quic)];
|
[nameof(ETransport.raw), nameof(ETransport.ws)];
|
||||||
|
|
||||||
public static NodeValidatorResult Validate(ProfileItem item, ECoreType coreType)
|
public static NodeValidatorResult Validate(ProfileItem item, ECoreType coreType)
|
||||||
{
|
{
|
||||||
|
|
@ -141,9 +141,10 @@ public class NodeValidator
|
||||||
v.Assert(!item.PublicKey.IsNullOrEmpty(), string.Format(ResUI.MsgInvalidProperty, "PublicKey"));
|
v.Assert(!item.PublicKey.IsNullOrEmpty(), string.Format(ResUI.MsgInvalidProperty, "PublicKey"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.Network == nameof(ETransport.xhttp) && !item.Extra.IsNullOrEmpty())
|
var transport = item.GetTransportExtra();
|
||||||
|
if (item.Network == nameof(ETransport.xhttp) && !transport.XhttpExtra.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
if (JsonUtils.ParseJson(item.Extra) is not JsonObject)
|
if (JsonUtils.ParseJson(transport.XhttpExtra) is not JsonObject)
|
||||||
{
|
{
|
||||||
v.Error(string.Format(ResUI.MsgInvalidProperty, "XHTTP Extra"));
|
v.Error(string.Format(ResUI.MsgInvalidProperty, "XHTTP Extra"));
|
||||||
}
|
}
|
||||||
|
|
@ -167,7 +168,7 @@ public class NodeValidator
|
||||||
}
|
}
|
||||||
|
|
||||||
// sing-box does not support non-tcp transports for protocols other than vmess/trojan/vless/shadowsocks
|
// sing-box does not support non-tcp transports for protocols other than vmess/trojan/vless/shadowsocks
|
||||||
if (!SingboxTransportSupportedProtocols.Contains(configType) && net != nameof(ETransport.tcp))
|
if (!SingboxTransportSupportedProtocols.Contains(configType) && net != nameof(ETransport.raw))
|
||||||
{
|
{
|
||||||
return string.Format(ResUI.MsgCoreNotSupportProtocolTransport,
|
return string.Format(ResUI.MsgCoreNotSupportProtocolTransport,
|
||||||
nameof(ECoreType.sing_box), configType.ToString(), net);
|
nameof(ECoreType.sing_box), configType.ToString(), net);
|
||||||
|
|
|
||||||
|
|
@ -77,10 +77,11 @@ public static class ConfigHandler
|
||||||
Tti = 50,
|
Tti = 50,
|
||||||
UplinkCapacity = 12,
|
UplinkCapacity = 12,
|
||||||
DownlinkCapacity = 100,
|
DownlinkCapacity = 100,
|
||||||
ReadBufferSize = 2,
|
CwndMultiplier = 1,
|
||||||
WriteBufferSize = 2,
|
MaxSendingWindow = 2 * 1024 * 1024,
|
||||||
Congestion = false
|
|
||||||
};
|
};
|
||||||
|
config.KcpItem.CwndMultiplier = config.KcpItem.CwndMultiplier <= 0 ? 1 : config.KcpItem.CwndMultiplier;
|
||||||
|
config.KcpItem.MaxSendingWindow = config.KcpItem.MaxSendingWindow <= 0 ? (2 * 1024 * 1024) : config.KcpItem.MaxSendingWindow;
|
||||||
config.GrpcItem ??= new GrpcItem
|
config.GrpcItem ??= new GrpcItem
|
||||||
{
|
{
|
||||||
IdleTimeout = 60,
|
IdleTimeout = 60,
|
||||||
|
|
@ -161,7 +162,7 @@ public static class ConfigHandler
|
||||||
config.Fragment4RayItem ??= new()
|
config.Fragment4RayItem ??= new()
|
||||||
{
|
{
|
||||||
Packets = "tlshello",
|
Packets = "tlshello",
|
||||||
Length = "100-200",
|
Length = "50-100",
|
||||||
Interval = "10-20"
|
Interval = "10-20"
|
||||||
};
|
};
|
||||||
config.GlobalHotkeys ??= new();
|
config.GlobalHotkeys ??= new();
|
||||||
|
|
@ -236,9 +237,6 @@ public static class ConfigHandler
|
||||||
item.Password = profileItem.Password;
|
item.Password = profileItem.Password;
|
||||||
|
|
||||||
item.Network = profileItem.Network;
|
item.Network = profileItem.Network;
|
||||||
item.HeaderType = profileItem.HeaderType;
|
|
||||||
item.RequestHost = profileItem.RequestHost;
|
|
||||||
item.Path = profileItem.Path;
|
|
||||||
|
|
||||||
item.StreamSecurity = profileItem.StreamSecurity;
|
item.StreamSecurity = profileItem.StreamSecurity;
|
||||||
item.Sni = profileItem.Sni;
|
item.Sni = profileItem.Sni;
|
||||||
|
|
@ -250,7 +248,6 @@ public static class ConfigHandler
|
||||||
item.ShortId = profileItem.ShortId;
|
item.ShortId = profileItem.ShortId;
|
||||||
item.SpiderX = profileItem.SpiderX;
|
item.SpiderX = profileItem.SpiderX;
|
||||||
item.Mldsa65Verify = profileItem.Mldsa65Verify;
|
item.Mldsa65Verify = profileItem.Mldsa65Verify;
|
||||||
item.Extra = profileItem.Extra;
|
|
||||||
item.MuxEnabled = profileItem.MuxEnabled;
|
item.MuxEnabled = profileItem.MuxEnabled;
|
||||||
item.Cert = profileItem.Cert;
|
item.Cert = profileItem.Cert;
|
||||||
item.CertSha = profileItem.CertSha;
|
item.CertSha = profileItem.CertSha;
|
||||||
|
|
@ -258,6 +255,7 @@ public static class ConfigHandler
|
||||||
item.EchForceQuery = profileItem.EchForceQuery;
|
item.EchForceQuery = profileItem.EchForceQuery;
|
||||||
item.Finalmask = profileItem.Finalmask;
|
item.Finalmask = profileItem.Finalmask;
|
||||||
item.ProtoExtra = profileItem.ProtoExtra;
|
item.ProtoExtra = profileItem.ProtoExtra;
|
||||||
|
item.TransportExtra = profileItem.TransportExtra;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ret = item.ConfigType switch
|
var ret = item.ConfigType switch
|
||||||
|
|
@ -297,9 +295,6 @@ public static class ConfigHandler
|
||||||
VmessSecurity = profileItem.GetProtocolExtra().VmessSecurity?.TrimEx()
|
VmessSecurity = profileItem.GetProtocolExtra().VmessSecurity?.TrimEx()
|
||||||
});
|
});
|
||||||
profileItem.Network = profileItem.Network.TrimEx();
|
profileItem.Network = profileItem.Network.TrimEx();
|
||||||
profileItem.HeaderType = profileItem.HeaderType.TrimEx();
|
|
||||||
profileItem.RequestHost = profileItem.RequestHost.TrimEx();
|
|
||||||
profileItem.Path = profileItem.Path.TrimEx();
|
|
||||||
profileItem.StreamSecurity = profileItem.StreamSecurity.TrimEx();
|
profileItem.StreamSecurity = profileItem.StreamSecurity.TrimEx();
|
||||||
|
|
||||||
if (!Global.VmessSecurities.Contains(profileItem.GetProtocolExtra().VmessSecurity))
|
if (!Global.VmessSecurities.Contains(profileItem.GetProtocolExtra().VmessSecurity))
|
||||||
|
|
@ -751,10 +746,12 @@ public static class ConfigHandler
|
||||||
profileItem.Password = profileItem.Password.TrimEx();
|
profileItem.Password = profileItem.Password.TrimEx();
|
||||||
profileItem.Network = string.Empty;
|
profileItem.Network = string.Empty;
|
||||||
|
|
||||||
if (!Global.TuicCongestionControls.Contains(profileItem.HeaderType))
|
var congestionControl = profileItem.GetProtocolExtra().CongestionControl;
|
||||||
|
if (!Global.TuicCongestionControls.Contains(congestionControl))
|
||||||
{
|
{
|
||||||
profileItem.HeaderType = Global.TuicCongestionControls.FirstOrDefault()!;
|
congestionControl = Global.TuicCongestionControls.FirstOrDefault()!;
|
||||||
}
|
}
|
||||||
|
profileItem.SetProtocolExtra(profileItem.GetProtocolExtra() with { CongestionControl = congestionControl });
|
||||||
|
|
||||||
if (profileItem.StreamSecurity.IsNullOrEmpty())
|
if (profileItem.StreamSecurity.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
|
|
@ -996,9 +993,6 @@ public static class ConfigHandler
|
||||||
profileItem.Address = profileItem.Address.TrimEx();
|
profileItem.Address = profileItem.Address.TrimEx();
|
||||||
profileItem.Password = profileItem.Password.TrimEx();
|
profileItem.Password = profileItem.Password.TrimEx();
|
||||||
profileItem.Network = profileItem.Network.TrimEx();
|
profileItem.Network = profileItem.Network.TrimEx();
|
||||||
profileItem.HeaderType = profileItem.HeaderType.TrimEx();
|
|
||||||
profileItem.RequestHost = profileItem.RequestHost.TrimEx();
|
|
||||||
profileItem.Path = profileItem.Path.TrimEx();
|
|
||||||
profileItem.StreamSecurity = profileItem.StreamSecurity.TrimEx();
|
profileItem.StreamSecurity = profileItem.StreamSecurity.TrimEx();
|
||||||
|
|
||||||
var vlessEncryption = profileItem.GetProtocolExtra().VlessEncryption?.TrimEx();
|
var vlessEncryption = profileItem.GetProtocolExtra().VlessEncryption?.TrimEx();
|
||||||
|
|
@ -1067,7 +1061,7 @@ public static class ConfigHandler
|
||||||
/// <returns>0 if successful</returns>
|
/// <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 = 3;
|
profileItem.ConfigVersion = 4;
|
||||||
|
|
||||||
if (profileItem.StreamSecurity.IsNotEmpty())
|
if (profileItem.StreamSecurity.IsNotEmpty())
|
||||||
{
|
{
|
||||||
|
|
@ -1135,6 +1129,8 @@ public static class ConfigHandler
|
||||||
|
|
||||||
var oProtocolExtra = o.GetProtocolExtra();
|
var oProtocolExtra = o.GetProtocolExtra();
|
||||||
var nProtocolExtra = n.GetProtocolExtra();
|
var nProtocolExtra = n.GetProtocolExtra();
|
||||||
|
var oTransport = o.GetTransportExtra();
|
||||||
|
var nTransport = n.GetTransportExtra();
|
||||||
|
|
||||||
return o.ConfigType == n.ConfigType
|
return o.ConfigType == n.ConfigType
|
||||||
&& AreEqual(o.Address, n.Address)
|
&& AreEqual(o.Address, n.Address)
|
||||||
|
|
@ -1145,9 +1141,16 @@ public static class ConfigHandler
|
||||||
&& AreEqual(oProtocolExtra.SsMethod, nProtocolExtra.SsMethod)
|
&& AreEqual(oProtocolExtra.SsMethod, nProtocolExtra.SsMethod)
|
||||||
&& AreEqual(oProtocolExtra.VmessSecurity, nProtocolExtra.VmessSecurity)
|
&& AreEqual(oProtocolExtra.VmessSecurity, nProtocolExtra.VmessSecurity)
|
||||||
&& AreEqual(o.Network, n.Network)
|
&& AreEqual(o.Network, n.Network)
|
||||||
&& AreEqual(o.HeaderType, n.HeaderType)
|
&& AreEqual(oTransport.RawHeaderType, nTransport.RawHeaderType)
|
||||||
&& AreEqual(o.RequestHost, n.RequestHost)
|
&& AreEqual(oTransport.Host, nTransport.Host)
|
||||||
&& AreEqual(o.Path, n.Path)
|
&& AreEqual(oTransport.Path, nTransport.Path)
|
||||||
|
&& AreEqual(oTransport.XhttpMode, nTransport.XhttpMode)
|
||||||
|
&& AreEqual(oTransport.XhttpExtra, nTransport.XhttpExtra)
|
||||||
|
&& AreEqual(oTransport.GrpcAuthority, nTransport.GrpcAuthority)
|
||||||
|
&& AreEqual(oTransport.GrpcServiceName, nTransport.GrpcServiceName)
|
||||||
|
&& AreEqual(oTransport.GrpcMode, nTransport.GrpcMode)
|
||||||
|
&& AreEqual(oTransport.KcpHeaderType, nTransport.KcpHeaderType)
|
||||||
|
&& AreEqual(oTransport.KcpSeed, nTransport.KcpSeed)
|
||||||
&& (o.ConfigType == EConfigType.Trojan || o.StreamSecurity == n.StreamSecurity)
|
&& (o.ConfigType == EConfigType.Trojan || o.StreamSecurity == n.StreamSecurity)
|
||||||
&& AreEqual(oProtocolExtra.Flow, nProtocolExtra.Flow)
|
&& AreEqual(oProtocolExtra.Flow, nProtocolExtra.Flow)
|
||||||
&& AreEqual(oProtocolExtra.SalamanderPass, nProtocolExtra.SalamanderPass)
|
&& AreEqual(oProtocolExtra.SalamanderPass, nProtocolExtra.SalamanderPass)
|
||||||
|
|
@ -1417,10 +1420,12 @@ public static class ConfigHandler
|
||||||
public static ProfileItem? GetPreSocksItem(Config config, ProfileItem node, ECoreType coreType)
|
public static ProfileItem? GetPreSocksItem(Config config, ProfileItem node, ECoreType coreType)
|
||||||
{
|
{
|
||||||
ProfileItem? itemSocks = null;
|
ProfileItem? itemSocks = null;
|
||||||
|
var enableLegacyProtect = config.TunModeItem.EnableLegacyProtect
|
||||||
|
|| Utils.IsNonWindows();
|
||||||
if (node.ConfigType != EConfigType.Custom
|
if (node.ConfigType != EConfigType.Custom
|
||||||
&& coreType != ECoreType.sing_box
|
&& coreType != ECoreType.sing_box
|
||||||
&& config.TunModeItem.EnableTun
|
&& config.TunModeItem.EnableTun
|
||||||
&& config.TunModeItem.EnableLegacyProtect)
|
&& enableLegacyProtect)
|
||||||
{
|
{
|
||||||
itemSocks = new ProfileItem()
|
itemSocks = new ProfileItem()
|
||||||
{
|
{
|
||||||
|
|
@ -1931,6 +1936,12 @@ public static class ConfigHandler
|
||||||
await SQLiteHelper.Instance.DeleteAsync(item);
|
await SQLiteHelper.Instance.DeleteAsync(item);
|
||||||
await RemoveServersViaSubid(config, id, false);
|
await RemoveServersViaSubid(config, id, false);
|
||||||
|
|
||||||
|
if (item.Id == config.SubIndexId)
|
||||||
|
{
|
||||||
|
var subs = await AppManager.Instance.SubItems();
|
||||||
|
config.SubIndexId = subs.LastOrDefault()?.Id;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ namespace ServiceLib.Handler.Fmt;
|
||||||
public class BaseFmt
|
public class BaseFmt
|
||||||
{
|
{
|
||||||
private static readonly string[] _allowInsecureArray = new[] { "insecure", "allowInsecure", "allow_insecure" };
|
private static readonly string[] _allowInsecureArray = new[] { "insecure", "allowInsecure", "allow_insecure" };
|
||||||
|
private static string UrlEncodeSafe(string? value) => Utils.UrlEncode(value ?? string.Empty);
|
||||||
|
|
||||||
protected static string GetIpv6(string address)
|
protected static string GetIpv6(string address)
|
||||||
{
|
{
|
||||||
|
|
@ -21,6 +22,8 @@ public class BaseFmt
|
||||||
|
|
||||||
protected static int ToUriQuery(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery)
|
protected static int ToUriQuery(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery)
|
||||||
{
|
{
|
||||||
|
var transport = item.GetTransportExtra();
|
||||||
|
|
||||||
if (item.StreamSecurity.IsNotEmpty())
|
if (item.StreamSecurity.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("security", item.StreamSecurity);
|
dicQuery.Add("security", item.StreamSecurity);
|
||||||
|
|
@ -87,54 +90,65 @@ public class BaseFmt
|
||||||
dicQuery.Add("fm", Utils.UrlEncode(finalmask));
|
dicQuery.Add("fm", Utils.UrlEncode(finalmask));
|
||||||
}
|
}
|
||||||
|
|
||||||
dicQuery.Add("type", item.Network.IsNotEmpty() ? item.Network : nameof(ETransport.tcp));
|
var network = item.GetNetwork();
|
||||||
|
if (!Global.Networks.Contains(network))
|
||||||
|
{
|
||||||
|
network = nameof(ETransport.raw);
|
||||||
|
}
|
||||||
|
|
||||||
switch (item.Network)
|
//dicQuery.Add("type", network);
|
||||||
|
dicQuery.Add("type", network == nameof(ETransport.raw) ? Global.RawNetworkAlias : network);
|
||||||
|
|
||||||
|
switch (network)
|
||||||
{
|
{
|
||||||
case nameof(ETransport.tcp):
|
case nameof(ETransport.raw):
|
||||||
dicQuery.Add("headerType", item.HeaderType.IsNotEmpty() ? item.HeaderType : Global.None);
|
dicQuery.Add("headerType", transport.RawHeaderType.IsNotEmpty() ? transport.RawHeaderType : Global.None);
|
||||||
if (item.RequestHost.IsNotEmpty())
|
if (transport.Host.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
|
dicQuery.Add("host", UrlEncodeSafe(transport.Host));
|
||||||
|
}
|
||||||
|
if (transport.Path.IsNotEmpty())
|
||||||
|
{
|
||||||
|
dicQuery.Add("path", UrlEncodeSafe(transport.Path));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.kcp):
|
case nameof(ETransport.kcp):
|
||||||
dicQuery.Add("headerType", item.HeaderType.IsNotEmpty() ? item.HeaderType : Global.None);
|
dicQuery.Add("headerType", transport.KcpHeaderType.IsNotEmpty() ? transport.KcpHeaderType : Global.None);
|
||||||
if (item.Path.IsNotEmpty())
|
if (transport.KcpSeed.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("seed", Utils.UrlEncode(item.Path));
|
dicQuery.Add("seed", UrlEncodeSafe(transport.KcpSeed));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.ws):
|
case nameof(ETransport.ws):
|
||||||
case nameof(ETransport.httpupgrade):
|
case nameof(ETransport.httpupgrade):
|
||||||
if (item.RequestHost.IsNotEmpty())
|
if (transport.Host.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
|
dicQuery.Add("host", UrlEncodeSafe(transport.Host));
|
||||||
}
|
}
|
||||||
if (item.Path.IsNotEmpty())
|
if (transport.Path.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("path", Utils.UrlEncode(item.Path));
|
dicQuery.Add("path", UrlEncodeSafe(transport.Path));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.xhttp):
|
case nameof(ETransport.xhttp):
|
||||||
if (item.RequestHost.IsNotEmpty())
|
if (transport.Host.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
|
dicQuery.Add("host", UrlEncodeSafe(transport.Host));
|
||||||
}
|
}
|
||||||
if (item.Path.IsNotEmpty())
|
if (transport.Path.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("path", Utils.UrlEncode(item.Path));
|
dicQuery.Add("path", UrlEncodeSafe(transport.Path));
|
||||||
}
|
}
|
||||||
if (item.HeaderType.IsNotEmpty() && Global.XhttpMode.Contains(item.HeaderType))
|
if (transport.XhttpMode.IsNotEmpty() && Global.XhttpMode.Contains(transport.XhttpMode))
|
||||||
{
|
{
|
||||||
dicQuery.Add("mode", Utils.UrlEncode(item.HeaderType));
|
dicQuery.Add("mode", UrlEncodeSafe(transport.XhttpMode));
|
||||||
}
|
}
|
||||||
if (item.Extra.IsNotEmpty())
|
if (transport.XhttpExtra.IsNotEmpty())
|
||||||
{
|
{
|
||||||
var node = JsonUtils.ParseJson(item.Extra);
|
var node = JsonUtils.ParseJson(transport.XhttpExtra);
|
||||||
var extra = node != null
|
var extra = node != null
|
||||||
? JsonUtils.Serialize(node, new JsonSerializerOptions
|
? JsonUtils.Serialize(node, new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
|
|
@ -142,38 +156,19 @@ public class BaseFmt
|
||||||
DefaultIgnoreCondition = JsonIgnoreCondition.Never,
|
DefaultIgnoreCondition = JsonIgnoreCondition.Never,
|
||||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||||
})
|
})
|
||||||
: item.Extra;
|
: transport.XhttpExtra;
|
||||||
dicQuery.Add("extra", Utils.UrlEncode(extra));
|
dicQuery.Add("extra", UrlEncodeSafe(extra));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.http):
|
|
||||||
case nameof(ETransport.h2):
|
|
||||||
dicQuery["type"] = nameof(ETransport.http);
|
|
||||||
if (item.RequestHost.IsNotEmpty())
|
|
||||||
{
|
|
||||||
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
|
|
||||||
}
|
|
||||||
if (item.Path.IsNotEmpty())
|
|
||||||
{
|
|
||||||
dicQuery.Add("path", Utils.UrlEncode(item.Path));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case nameof(ETransport.quic):
|
|
||||||
dicQuery.Add("headerType", item.HeaderType.IsNotEmpty() ? item.HeaderType : Global.None);
|
|
||||||
dicQuery.Add("quicSecurity", Utils.UrlEncode(item.RequestHost));
|
|
||||||
dicQuery.Add("key", Utils.UrlEncode(item.Path));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case nameof(ETransport.grpc):
|
case nameof(ETransport.grpc):
|
||||||
if (item.Path.IsNotEmpty())
|
if (transport.GrpcServiceName.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("authority", Utils.UrlEncode(item.RequestHost));
|
dicQuery.Add("authority", UrlEncodeSafe(transport.GrpcAuthority));
|
||||||
dicQuery.Add("serviceName", Utils.UrlEncode(item.Path));
|
dicQuery.Add("serviceName", UrlEncodeSafe(transport.GrpcServiceName));
|
||||||
if (item.HeaderType is Global.GrpcGunMode or Global.GrpcMultiMode)
|
if (transport.GrpcMode is Global.GrpcGunMode or Global.GrpcMultiMode)
|
||||||
{
|
{
|
||||||
dicQuery.Add("mode", Utils.UrlEncode(item.HeaderType));
|
dicQuery.Add("mode", UrlEncodeSafe(transport.GrpcMode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -216,6 +211,8 @@ public class BaseFmt
|
||||||
|
|
||||||
protected static int ResolveUriQuery(NameValueCollection query, ref ProfileItem item)
|
protected static int ResolveUriQuery(NameValueCollection query, ref ProfileItem item)
|
||||||
{
|
{
|
||||||
|
var transport = item.GetTransportExtra();
|
||||||
|
|
||||||
item.StreamSecurity = GetQueryValue(query, "security");
|
item.StreamSecurity = GetQueryValue(query, "security");
|
||||||
item.Sni = GetQueryValue(query, "sni");
|
item.Sni = GetQueryValue(query, "sni");
|
||||||
item.Alpn = GetQueryDecoded(query, "alpn");
|
item.Alpn = GetQueryDecoded(query, "alpn");
|
||||||
|
|
@ -258,36 +255,54 @@ public class BaseFmt
|
||||||
item.AllowInsecure = string.Empty;
|
item.AllowInsecure = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.Network = GetQueryValue(query, "type", nameof(ETransport.tcp));
|
var net = GetQueryValue(query, "type", nameof(ETransport.raw));
|
||||||
|
if (net == Global.RawNetworkAlias)
|
||||||
|
{
|
||||||
|
net = nameof(ETransport.raw);
|
||||||
|
}
|
||||||
|
if (!Global.Networks.Contains(net))
|
||||||
|
{
|
||||||
|
net = nameof(ETransport.raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
item.Network = net;
|
||||||
switch (item.Network)
|
switch (item.Network)
|
||||||
{
|
{
|
||||||
case nameof(ETransport.tcp):
|
case nameof(ETransport.raw):
|
||||||
item.HeaderType = GetQueryValue(query, "headerType", Global.None);
|
transport = transport with
|
||||||
item.RequestHost = GetQueryDecoded(query, "host");
|
{
|
||||||
|
RawHeaderType = GetQueryValue(query, "headerType", Global.None),
|
||||||
|
Host = GetQueryDecoded(query, "host"),
|
||||||
|
Path = GetQueryDecoded(query, "path"),
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.kcp):
|
case nameof(ETransport.kcp):
|
||||||
item.HeaderType = GetQueryValue(query, "headerType", Global.None);
|
var kcpSeed = GetQueryDecoded(query, "seed");
|
||||||
item.Path = GetQueryDecoded(query, "seed");
|
transport = transport with
|
||||||
|
{
|
||||||
|
KcpHeaderType = GetQueryValue(query, "headerType", Global.None),
|
||||||
|
KcpSeed = kcpSeed,
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.ws):
|
case nameof(ETransport.ws):
|
||||||
case nameof(ETransport.httpupgrade):
|
case nameof(ETransport.httpupgrade):
|
||||||
item.RequestHost = GetQueryDecoded(query, "host");
|
transport = transport with
|
||||||
item.Path = GetQueryDecoded(query, "path", "/");
|
{
|
||||||
|
Host = GetQueryDecoded(query, "host"),
|
||||||
|
Path = GetQueryDecoded(query, "path", "/"),
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.xhttp):
|
case nameof(ETransport.xhttp):
|
||||||
item.RequestHost = GetQueryDecoded(query, "host");
|
var xhttpExtra = GetQueryDecoded(query, "extra");
|
||||||
item.Path = GetQueryDecoded(query, "path", "/");
|
if (xhttpExtra.IsNotEmpty())
|
||||||
item.HeaderType = GetQueryDecoded(query, "mode");
|
|
||||||
var extraDecoded = GetQueryDecoded(query, "extra");
|
|
||||||
if (extraDecoded.IsNotEmpty())
|
|
||||||
{
|
{
|
||||||
var node = JsonUtils.ParseJson(extraDecoded);
|
var node = JsonUtils.ParseJson(xhttpExtra);
|
||||||
if (node != null)
|
if (node != null)
|
||||||
{
|
{
|
||||||
extraDecoded = JsonUtils.Serialize(node, new JsonSerializerOptions
|
xhttpExtra = JsonUtils.Serialize(node, new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
WriteIndented = true,
|
WriteIndented = true,
|
||||||
DefaultIgnoreCondition = JsonIgnoreCondition.Never,
|
DefaultIgnoreCondition = JsonIgnoreCondition.Never,
|
||||||
|
|
@ -295,31 +310,32 @@ public class BaseFmt
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
item.Extra = extraDecoded;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case nameof(ETransport.http):
|
transport = transport with
|
||||||
case nameof(ETransport.h2):
|
{
|
||||||
item.Network = nameof(ETransport.h2);
|
Host = GetQueryDecoded(query, "host"),
|
||||||
item.RequestHost = GetQueryDecoded(query, "host");
|
Path = GetQueryDecoded(query, "path", "/"),
|
||||||
item.Path = GetQueryDecoded(query, "path", "/");
|
XhttpMode = GetQueryDecoded(query, "mode"),
|
||||||
break;
|
XhttpExtra = xhttpExtra,
|
||||||
|
};
|
||||||
case nameof(ETransport.quic):
|
|
||||||
item.HeaderType = GetQueryValue(query, "headerType", Global.None);
|
|
||||||
item.RequestHost = GetQueryValue(query, "quicSecurity", Global.None);
|
|
||||||
item.Path = GetQueryDecoded(query, "key");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.grpc):
|
case nameof(ETransport.grpc):
|
||||||
item.RequestHost = GetQueryDecoded(query, "authority");
|
transport = transport with
|
||||||
item.Path = GetQueryDecoded(query, "serviceName");
|
{
|
||||||
item.HeaderType = GetQueryDecoded(query, "mode", Global.GrpcGunMode);
|
GrpcAuthority = GetQueryDecoded(query, "authority"),
|
||||||
|
GrpcServiceName = GetQueryDecoded(query, "serviceName"),
|
||||||
|
GrpcMode = GetQueryDecoded(query, "mode", Global.GrpcGunMode),
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
item.Network = nameof(ETransport.raw);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item.SetTransportExtra(transport);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,31 +42,28 @@ public class ShadowsocksFmt : BaseFmt
|
||||||
//url = Utile.Base64Encode(url);
|
//url = Utile.Base64Encode(url);
|
||||||
//new Sip002
|
//new Sip002
|
||||||
var pw = Utils.Base64Encode($"{item.GetProtocolExtra().SsMethod}:{item.Password}", true);
|
var pw = Utils.Base64Encode($"{item.GetProtocolExtra().SsMethod}:{item.Password}", true);
|
||||||
|
var transport = item.GetTransportExtra();
|
||||||
|
|
||||||
// plugin
|
// plugin
|
||||||
var plugin = string.Empty;
|
var plugin = string.Empty;
|
||||||
var pluginArgs = string.Empty;
|
var pluginArgs = string.Empty;
|
||||||
|
|
||||||
if (item.Network == nameof(ETransport.tcp) && item.HeaderType == Global.TcpHeaderHttp)
|
if (item.Network == nameof(ETransport.raw) && transport.RawHeaderType == Global.RawHeaderHttp)
|
||||||
{
|
{
|
||||||
plugin = "obfs-local";
|
plugin = "obfs-local";
|
||||||
pluginArgs = $"obfs=http;obfs-host={item.RequestHost};";
|
pluginArgs = $"obfs=http;obfs-host={transport.Host};";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (item.Network == nameof(ETransport.ws))
|
if (item.Network == nameof(ETransport.ws))
|
||||||
{
|
{
|
||||||
pluginArgs += "mode=websocket;";
|
pluginArgs += "mode=websocket;";
|
||||||
pluginArgs += $"host={item.RequestHost};";
|
pluginArgs += $"host={transport.Host};";
|
||||||
// https://github.com/shadowsocks/v2ray-plugin/blob/e9af1cdd2549d528deb20a4ab8d61c5fbe51f306/args.go#L172
|
// https://github.com/shadowsocks/v2ray-plugin/blob/e9af1cdd2549d528deb20a4ab8d61c5fbe51f306/args.go#L172
|
||||||
// Equal signs and commas [and backslashes] must be escaped with a backslash.
|
// Equal signs and commas [and backslashes] must be escaped with a backslash.
|
||||||
var path = item.Path.Replace("\\", "\\\\").Replace("=", "\\=").Replace(",", "\\,");
|
var path = (transport.Path ?? string.Empty).Replace("\\", "\\\\").Replace("=", "\\=").Replace(",", "\\,");
|
||||||
pluginArgs += $"path={path};";
|
pluginArgs += $"path={path};";
|
||||||
}
|
}
|
||||||
else if (item.Network == nameof(ETransport.quic))
|
|
||||||
{
|
|
||||||
pluginArgs += "mode=quic;";
|
|
||||||
}
|
|
||||||
if (item.StreamSecurity == Global.StreamSecurity)
|
if (item.StreamSecurity == Global.StreamSecurity)
|
||||||
{
|
{
|
||||||
pluginArgs += "tls;";
|
pluginArgs += "tls;";
|
||||||
|
|
@ -213,8 +210,11 @@ public class ShadowsocksFmt : BaseFmt
|
||||||
{
|
{
|
||||||
obfsHost = obfsHost.Replace("obfs-host=", "");
|
obfsHost = obfsHost.Replace("obfs-host=", "");
|
||||||
item.Network = Global.DefaultNetwork;
|
item.Network = Global.DefaultNetwork;
|
||||||
item.HeaderType = Global.TcpHeaderHttp;
|
item.SetTransportExtra(item.GetTransportExtra() with
|
||||||
item.RequestHost = obfsHost;
|
{
|
||||||
|
RawHeaderType = Global.RawHeaderHttp,
|
||||||
|
Host = obfsHost,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Parse v2ray-plugin
|
// Parse v2ray-plugin
|
||||||
|
|
@ -231,21 +231,20 @@ public class ShadowsocksFmt : BaseFmt
|
||||||
if (modeValue == "websocket")
|
if (modeValue == "websocket")
|
||||||
{
|
{
|
||||||
item.Network = nameof(ETransport.ws);
|
item.Network = nameof(ETransport.ws);
|
||||||
|
var t = item.GetTransportExtra();
|
||||||
if (!host.IsNullOrEmpty())
|
if (!host.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
item.RequestHost = host.Replace("host=", "");
|
var wsHost = host.Replace("host=", "");
|
||||||
item.Sni = item.RequestHost;
|
t = t with { Host = wsHost };
|
||||||
|
item.Sni = wsHost;
|
||||||
}
|
}
|
||||||
if (!path.IsNullOrEmpty())
|
if (!path.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
var pathValue = path.Replace("path=", "");
|
var pathValue = path.Replace("path=", "");
|
||||||
pathValue = pathValue.Replace("\\=", "=").Replace("\\,", ",").Replace("\\\\", "\\");
|
pathValue = pathValue.Replace("\\=", "=").Replace("\\,", ",").Replace("\\\\", "\\");
|
||||||
item.Path = pathValue;
|
t = t with { Path = pathValue };
|
||||||
}
|
}
|
||||||
}
|
item.SetTransportExtra(t);
|
||||||
else if (modeValue == "quic")
|
|
||||||
{
|
|
||||||
item.Network = nameof(ETransport.quic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasTls)
|
if (hasTls)
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ public class VmessFmt : BaseFmt
|
||||||
|
|
||||||
var vmessQRCode = new VmessQRCode
|
var vmessQRCode = new VmessQRCode
|
||||||
{
|
{
|
||||||
|
// vmess link keeps shared transport keys; map from new transport model on export.
|
||||||
v = 2,
|
v = 2,
|
||||||
ps = item.Remarks.TrimEx(),
|
ps = item.Remarks.TrimEx(),
|
||||||
add = item.Address,
|
add = item.Address,
|
||||||
|
|
@ -33,10 +34,34 @@ public class VmessFmt : BaseFmt
|
||||||
id = item.Password,
|
id = item.Password,
|
||||||
aid = int.TryParse(item.GetProtocolExtra()?.AlterId, out var result) ? result : 0,
|
aid = int.TryParse(item.GetProtocolExtra()?.AlterId, out var result) ? result : 0,
|
||||||
scy = item.GetProtocolExtra().VmessSecurity ?? "",
|
scy = item.GetProtocolExtra().VmessSecurity ?? "",
|
||||||
net = item.Network,
|
net = item.GetNetwork() == nameof(ETransport.raw) ? Global.RawNetworkAlias : item.Network,
|
||||||
type = item.HeaderType,
|
type = item.GetNetwork() switch
|
||||||
host = item.RequestHost,
|
{
|
||||||
path = item.Path,
|
nameof(ETransport.raw) => item.GetTransportExtra().RawHeaderType,
|
||||||
|
nameof(ETransport.kcp) => item.GetTransportExtra().KcpHeaderType,
|
||||||
|
nameof(ETransport.xhttp) => item.GetTransportExtra().XhttpMode,
|
||||||
|
nameof(ETransport.grpc) => item.GetTransportExtra().GrpcMode,
|
||||||
|
_ => Global.None,
|
||||||
|
},
|
||||||
|
host = item.GetNetwork() switch
|
||||||
|
{
|
||||||
|
nameof(ETransport.raw) => item.GetTransportExtra().Host,
|
||||||
|
nameof(ETransport.ws) => item.GetTransportExtra().Host,
|
||||||
|
nameof(ETransport.httpupgrade) => item.GetTransportExtra().Host,
|
||||||
|
nameof(ETransport.xhttp) => item.GetTransportExtra().Host,
|
||||||
|
nameof(ETransport.grpc) => item.GetTransportExtra().GrpcAuthority,
|
||||||
|
_ => null,
|
||||||
|
},
|
||||||
|
path = item.GetNetwork() switch
|
||||||
|
{
|
||||||
|
nameof(ETransport.raw) => item.GetTransportExtra().Path,
|
||||||
|
nameof(ETransport.kcp) => item.GetTransportExtra().KcpSeed,
|
||||||
|
nameof(ETransport.ws) => item.GetTransportExtra().Path,
|
||||||
|
nameof(ETransport.httpupgrade) => item.GetTransportExtra().Path,
|
||||||
|
nameof(ETransport.xhttp) => item.GetTransportExtra().Path,
|
||||||
|
nameof(ETransport.grpc) => item.GetTransportExtra().GrpcServiceName,
|
||||||
|
_ => null,
|
||||||
|
},
|
||||||
tls = item.StreamSecurity,
|
tls = item.StreamSecurity,
|
||||||
sni = item.Sni,
|
sni = item.Sni,
|
||||||
alpn = item.Alpn,
|
alpn = item.Alpn,
|
||||||
|
|
@ -70,7 +95,10 @@ public class VmessFmt : BaseFmt
|
||||||
}
|
}
|
||||||
|
|
||||||
item.Network = Global.DefaultNetwork;
|
item.Network = Global.DefaultNetwork;
|
||||||
item.HeaderType = Global.None;
|
var transport = new TransportExtraItem
|
||||||
|
{
|
||||||
|
RawHeaderType = Global.None,
|
||||||
|
};
|
||||||
|
|
||||||
//item.ConfigVersion = vmessQRCode.v;
|
//item.ConfigVersion = vmessQRCode.v;
|
||||||
item.Remarks = Utils.ToString(vmessQRCode.ps);
|
item.Remarks = Utils.ToString(vmessQRCode.ps);
|
||||||
|
|
@ -84,15 +112,30 @@ public class VmessFmt : BaseFmt
|
||||||
});
|
});
|
||||||
if (vmessQRCode.net.IsNotEmpty())
|
if (vmessQRCode.net.IsNotEmpty())
|
||||||
{
|
{
|
||||||
item.Network = vmessQRCode.net;
|
item.Network = vmessQRCode.net == Global.RawNetworkAlias ? nameof(ETransport.raw) : vmessQRCode.net;
|
||||||
}
|
}
|
||||||
if (vmessQRCode.type.IsNotEmpty())
|
if (vmessQRCode.type.IsNotEmpty())
|
||||||
{
|
{
|
||||||
item.HeaderType = vmessQRCode.type;
|
transport = item.GetNetwork() switch
|
||||||
|
{
|
||||||
|
nameof(ETransport.raw) => transport with { RawHeaderType = vmessQRCode.type },
|
||||||
|
nameof(ETransport.kcp) => transport with { KcpHeaderType = vmessQRCode.type },
|
||||||
|
nameof(ETransport.xhttp) => transport with { XhttpMode = vmessQRCode.type },
|
||||||
|
nameof(ETransport.grpc) => transport with { GrpcMode = vmessQRCode.type },
|
||||||
|
_ => transport,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
transport = item.GetNetwork() switch
|
||||||
item.RequestHost = Utils.ToString(vmessQRCode.host);
|
{
|
||||||
item.Path = Utils.ToString(vmessQRCode.path);
|
nameof(ETransport.raw) => transport with { Host = Utils.ToString(vmessQRCode.host), Path = Utils.ToString(vmessQRCode.path) },
|
||||||
|
nameof(ETransport.kcp) => transport with { KcpSeed = Utils.ToString(vmessQRCode.path) },
|
||||||
|
nameof(ETransport.ws) => transport with { Host = Utils.ToString(vmessQRCode.host), Path = Utils.ToString(vmessQRCode.path) },
|
||||||
|
nameof(ETransport.httpupgrade) => transport with { Host = Utils.ToString(vmessQRCode.host), Path = Utils.ToString(vmessQRCode.path) },
|
||||||
|
nameof(ETransport.xhttp) => transport with { Host = Utils.ToString(vmessQRCode.host), Path = Utils.ToString(vmessQRCode.path) },
|
||||||
|
nameof(ETransport.grpc) => transport with { GrpcAuthority = Utils.ToString(vmessQRCode.host), GrpcServiceName = Utils.ToString(vmessQRCode.path) },
|
||||||
|
_ => transport,
|
||||||
|
};
|
||||||
|
item.SetTransportExtra(transport);
|
||||||
item.StreamSecurity = Utils.ToString(vmessQRCode.tls);
|
item.StreamSecurity = Utils.ToString(vmessQRCode.tls);
|
||||||
item.Sni = Utils.ToString(vmessQRCode.sni);
|
item.Sni = Utils.ToString(vmessQRCode.sni);
|
||||||
item.Alpn = Utils.ToString(vmessQRCode.alpn);
|
item.Alpn = Utils.ToString(vmessQRCode.alpn);
|
||||||
|
|
@ -122,7 +165,7 @@ public class VmessFmt : BaseFmt
|
||||||
|
|
||||||
item.SetProtocolExtra(new ProtocolExtraItem
|
item.SetProtocolExtra(new ProtocolExtraItem
|
||||||
{
|
{
|
||||||
VmessSecurity = "auto",
|
VmessSecurity = Global.DefaultSecurity,
|
||||||
});
|
});
|
||||||
|
|
||||||
var query = Utils.ParseQueryString(url.Query);
|
var query = Utils.ParseQueryString(url.Query);
|
||||||
|
|
|
||||||
|
|
@ -309,8 +309,15 @@ public sealed class AppManager
|
||||||
|
|
||||||
public async Task MigrateProfileExtra()
|
public async Task MigrateProfileExtra()
|
||||||
{
|
{
|
||||||
await MigrateProfileExtraGroup();
|
await MigrateProfileExtraGroupV2ToV3();
|
||||||
|
|
||||||
|
await MigrateProfileExtraV2ToV3();
|
||||||
|
|
||||||
|
await MigrateProfileTransportV3ToV4();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task MigrateProfileExtraV2ToV3()
|
||||||
|
{
|
||||||
const int pageSize = 100;
|
const int pageSize = 100;
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
|
|
||||||
|
|
@ -326,7 +333,7 @@ public sealed class AppManager
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var batchSuccessCount = await MigrateProfileExtraSub(batch);
|
var batchSuccessCount = await MigrateProfileExtraV2ToV3Sub(batch);
|
||||||
|
|
||||||
// Only increment offset by the number of failed items that remain in the result set
|
// Only increment offset by the number of failed items that remain in the result set
|
||||||
// Successfully updated items are automatically excluded from future queries due to ConfigVersion = 3
|
// Successfully updated items are automatically excluded from future queries due to ConfigVersion = 3
|
||||||
|
|
@ -336,7 +343,120 @@ public sealed class AppManager
|
||||||
//await ProfileGroupItemManager.Instance.ClearAll();
|
//await ProfileGroupItemManager.Instance.ClearAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<int> MigrateProfileExtraSub(List<ProfileItem> batch)
|
private async Task MigrateProfileTransportV3ToV4()
|
||||||
|
{
|
||||||
|
const int pageSize = 100;
|
||||||
|
var offset = 0;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
var sql = $"SELECT * FROM ProfileItem WHERE ConfigVersion = 3 LIMIT {pageSize} OFFSET {offset}";
|
||||||
|
var batch = await SQLiteHelper.Instance.QueryAsync<ProfileItem>(sql);
|
||||||
|
if (batch is null || batch.Count == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var updateProfileItems = new List<ProfileItem>();
|
||||||
|
foreach (var item in batch)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (item.Network == Global.RawNetworkAlias)
|
||||||
|
{
|
||||||
|
item.Network = nameof(ETransport.raw);
|
||||||
|
}
|
||||||
|
var transport = item.GetTransportExtra();
|
||||||
|
var network = item.GetNetwork();
|
||||||
|
|
||||||
|
switch (network)
|
||||||
|
{
|
||||||
|
case nameof(ETransport.raw):
|
||||||
|
transport = transport with
|
||||||
|
{
|
||||||
|
RawHeaderType = item.HeaderType.NullIfEmpty(),
|
||||||
|
Host = item.RequestHost.NullIfEmpty(),
|
||||||
|
Path = item.Path.NullIfEmpty(),
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.ws):
|
||||||
|
case nameof(ETransport.httpupgrade):
|
||||||
|
transport = transport with
|
||||||
|
{
|
||||||
|
Host = item.RequestHost.NullIfEmpty(),
|
||||||
|
Path = item.Path.NullIfEmpty(),
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.xhttp):
|
||||||
|
transport = transport with
|
||||||
|
{
|
||||||
|
Host = item.RequestHost.NullIfEmpty(),
|
||||||
|
Path = item.Path.NullIfEmpty(),
|
||||||
|
XhttpMode = item.HeaderType.NullIfEmpty(),
|
||||||
|
XhttpExtra = item.Extra.NullIfEmpty(),
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.grpc):
|
||||||
|
transport = transport with
|
||||||
|
{
|
||||||
|
GrpcAuthority = item.RequestHost.NullIfEmpty(),
|
||||||
|
GrpcServiceName = item.Path.NullIfEmpty(),
|
||||||
|
GrpcMode = item.HeaderType.NullIfEmpty(),
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.kcp):
|
||||||
|
transport = transport with
|
||||||
|
{
|
||||||
|
KcpHeaderType = item.HeaderType.NullIfEmpty(),
|
||||||
|
KcpSeed = item.Path.NullIfEmpty(),
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
item.Network = Global.DefaultNetwork;
|
||||||
|
transport = transport with
|
||||||
|
{
|
||||||
|
RawHeaderType = item.HeaderType.NullIfEmpty(),
|
||||||
|
Host = item.RequestHost.NullIfEmpty(),
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
item.SetTransportExtra(transport);
|
||||||
|
item.ConfigVersion = 4;
|
||||||
|
updateProfileItems.Add(item);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logging.SaveLog($"MigrateProfileTransportV3ToV4 Error: {ex}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updateProfileItems.Count > 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var count = await SQLiteHelper.Instance.UpdateAllAsync(updateProfileItems);
|
||||||
|
offset += batch.Count - count;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logging.SaveLog($"MigrateProfileTransportV3ToV4 update error: {ex}");
|
||||||
|
offset += batch.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
offset += batch.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<int> MigrateProfileExtraV2ToV3Sub(List<ProfileItem> batch)
|
||||||
{
|
{
|
||||||
var updateProfileItems = new List<ProfileItem>();
|
var updateProfileItems = new List<ProfileItem>();
|
||||||
|
|
||||||
|
|
@ -434,7 +554,7 @@ public sealed class AppManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> MigrateProfileExtraGroup()
|
private async Task<bool> MigrateProfileExtraGroupV2ToV3()
|
||||||
{
|
{
|
||||||
var list = await SQLiteHelper.Instance.TableAsync<ProfileGroupItem>().ToListAsync();
|
var list = await SQLiteHelper.Instance.TableAsync<ProfileGroupItem>().ToListAsync();
|
||||||
var groupItems = new ConcurrentDictionary<string, ProfileGroupItem>(list.Where(t => !string.IsNullOrEmpty(t.IndexId)).ToDictionary(t => t.IndexId!));
|
var groupItems = new ConcurrentDictionary<string, ProfileGroupItem>(list.Where(t => !string.IsNullOrEmpty(t.IndexId)).ToDictionary(t => t.IndexId!));
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@ public class CertPemManager
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get certificate in PEM format from a server with CA pinning validation
|
/// Get certificate in PEM format from a server with CA pinning validation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<(string?, string?)> GetCertPemAsync(string target, string serverName, int timeout = 4)
|
public async Task<(string?, string?)> GetCertPemAsync(string target, string serverName, int timeout = 4, bool allowInsecure = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -215,12 +215,14 @@ public class CertPemManager
|
||||||
using var client = new TcpClient();
|
using var client = new TcpClient();
|
||||||
await client.ConnectAsync(domain, port > 0 ? port : 443, cts.Token);
|
await client.ConnectAsync(domain, port > 0 ? port : 443, cts.Token);
|
||||||
|
|
||||||
await using var ssl = new SslStream(client.GetStream(), false, ValidateServerCertificate);
|
var callback = new RemoteCertificateValidationCallback((sender, certificate, chain, sslPolicyErrors) =>
|
||||||
|
ValidateServerCertificate(sender, certificate, chain, sslPolicyErrors, allowInsecure));
|
||||||
|
await using var ssl = new SslStream(client.GetStream(), false, callback);
|
||||||
|
|
||||||
var sslOptions = new SslClientAuthenticationOptions
|
var sslOptions = new SslClientAuthenticationOptions
|
||||||
{
|
{
|
||||||
TargetHost = serverName,
|
TargetHost = serverName,
|
||||||
RemoteCertificateValidationCallback = ValidateServerCertificate
|
RemoteCertificateValidationCallback = callback
|
||||||
};
|
};
|
||||||
|
|
||||||
await ssl.AuthenticateAsClientAsync(sslOptions, cts.Token);
|
await ssl.AuthenticateAsClientAsync(sslOptions, cts.Token);
|
||||||
|
|
@ -249,7 +251,7 @@ public class CertPemManager
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get certificate chain in PEM format from a server with CA pinning validation
|
/// Get certificate chain in PEM format from a server with CA pinning validation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<(List<string>, string?)> GetCertChainPemAsync(string target, string serverName, int timeout = 4)
|
public async Task<(List<string>, string?)> GetCertChainPemAsync(string target, string serverName, int timeout = 4, bool allowInsecure = false)
|
||||||
{
|
{
|
||||||
var pemList = new List<string>();
|
var pemList = new List<string>();
|
||||||
try
|
try
|
||||||
|
|
@ -262,12 +264,14 @@ public class CertPemManager
|
||||||
using var client = new TcpClient();
|
using var client = new TcpClient();
|
||||||
await client.ConnectAsync(domain, port > 0 ? port : 443, cts.Token);
|
await client.ConnectAsync(domain, port > 0 ? port : 443, cts.Token);
|
||||||
|
|
||||||
await using var ssl = new SslStream(client.GetStream(), false, ValidateServerCertificate);
|
var callback = new RemoteCertificateValidationCallback((sender, certificate, chain, sslPolicyErrors) =>
|
||||||
|
ValidateServerCertificate(sender, certificate, chain, sslPolicyErrors, allowInsecure));
|
||||||
|
await using var ssl = new SslStream(client.GetStream(), false, callback);
|
||||||
|
|
||||||
var sslOptions = new SslClientAuthenticationOptions
|
var sslOptions = new SslClientAuthenticationOptions
|
||||||
{
|
{
|
||||||
TargetHost = serverName,
|
TargetHost = serverName,
|
||||||
RemoteCertificateValidationCallback = ValidateServerCertificate
|
RemoteCertificateValidationCallback = callback
|
||||||
};
|
};
|
||||||
|
|
||||||
await ssl.AuthenticateAsClientAsync(sslOptions, cts.Token);
|
await ssl.AuthenticateAsClientAsync(sslOptions, cts.Token);
|
||||||
|
|
@ -300,16 +304,23 @@ public class CertPemManager
|
||||||
/// Validate server certificate with CA pinning
|
/// Validate server certificate with CA pinning
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool ValidateServerCertificate(
|
private bool ValidateServerCertificate(
|
||||||
object sender,
|
object _,
|
||||||
X509Certificate? certificate,
|
X509Certificate? certificate,
|
||||||
X509Chain? chain,
|
X509Chain? chain,
|
||||||
SslPolicyErrors sslPolicyErrors)
|
SslPolicyErrors sslPolicyErrors,
|
||||||
|
bool allowInsecure)
|
||||||
{
|
{
|
||||||
if (certificate == null)
|
if (certificate == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In insecure mode, accept any certificate so self-signed certs can be fetched.
|
||||||
|
if (allowInsecure)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Check certificate name mismatch
|
// Check certificate name mismatch
|
||||||
if (sslPolicyErrors.HasFlag(SslPolicyErrors.RemoteCertificateNameMismatch))
|
if (sslPolicyErrors.HasFlag(SslPolicyErrors.RemoteCertificateNameMismatch))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,9 @@ public class KcpItem
|
||||||
|
|
||||||
public int DownlinkCapacity { get; set; }
|
public int DownlinkCapacity { get; set; }
|
||||||
|
|
||||||
public bool Congestion { get; set; }
|
public int CwndMultiplier { get; set; }
|
||||||
|
|
||||||
public int ReadBufferSize { get; set; }
|
public int MaxSendingWindow { get; set; }
|
||||||
|
|
||||||
public int WriteBufferSize { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
|
@ -200,7 +198,7 @@ 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; } = Global.Hysteria2DefaultHopInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,5 @@ public record CoreConfigContext
|
||||||
|
|
||||||
// TUN Compatibility
|
// TUN Compatibility
|
||||||
public bool IsTunEnabled { get; init; } = false;
|
public bool IsTunEnabled { get; init; } = false;
|
||||||
public HashSet<string> ProtectDomainList { get; init; } = new();
|
public HashSet<string> ProtectDomainList { get; init; } = [];
|
||||||
// -> tun inbound --(if routing proxy)--> relay outbound
|
|
||||||
// -> proxy core (relay inbound --> proxy outbound --(dialerProxy)--> protect outbound)
|
|
||||||
// -> protect inbound -> direct proxy outbound data -> internet
|
|
||||||
public int TunProtectSocksPort { get; init; } = 0;
|
|
||||||
public int ProxyRelaySocksPort { get; init; } = 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,13 @@ namespace ServiceLib.Models;
|
||||||
public class ProfileItem
|
public class ProfileItem
|
||||||
{
|
{
|
||||||
private ProtocolExtraItem? _protocolExtraCache;
|
private ProtocolExtraItem? _protocolExtraCache;
|
||||||
|
private TransportExtraItem? _transportExtraCache;
|
||||||
|
|
||||||
public ProfileItem()
|
public ProfileItem()
|
||||||
{
|
{
|
||||||
IndexId = string.Empty;
|
IndexId = string.Empty;
|
||||||
ConfigType = EConfigType.VMess;
|
ConfigType = EConfigType.VMess;
|
||||||
ConfigVersion = 3;
|
ConfigVersion = 4;
|
||||||
Subid = string.Empty;
|
Subid = string.Empty;
|
||||||
Address = string.Empty;
|
Address = string.Empty;
|
||||||
Port = 0;
|
Port = 0;
|
||||||
|
|
@ -17,9 +18,6 @@ public class ProfileItem
|
||||||
Username = string.Empty;
|
Username = string.Empty;
|
||||||
Network = string.Empty;
|
Network = string.Empty;
|
||||||
Remarks = string.Empty;
|
Remarks = string.Empty;
|
||||||
HeaderType = string.Empty;
|
|
||||||
RequestHost = string.Empty;
|
|
||||||
Path = string.Empty;
|
|
||||||
StreamSecurity = string.Empty;
|
StreamSecurity = string.Empty;
|
||||||
AllowInsecure = string.Empty;
|
AllowInsecure = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
@ -126,20 +124,26 @@ public class ProfileItem
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProtocolExtraItem GetProtocolExtra()
|
||||||
|
{
|
||||||
|
return _protocolExtraCache ??= JsonUtils.Deserialize<ProtocolExtraItem>(ProtoExtra) ?? new ProtocolExtraItem();
|
||||||
|
}
|
||||||
|
|
||||||
public void SetProtocolExtra(ProtocolExtraItem extraItem)
|
public void SetProtocolExtra(ProtocolExtraItem extraItem)
|
||||||
{
|
{
|
||||||
_protocolExtraCache = extraItem;
|
_protocolExtraCache = extraItem;
|
||||||
ProtoExtra = JsonUtils.Serialize(extraItem, false);
|
ProtoExtra = JsonUtils.Serialize(extraItem, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetProtocolExtra()
|
public TransportExtraItem GetTransportExtra()
|
||||||
{
|
{
|
||||||
ProtoExtra = JsonUtils.Serialize(_protocolExtraCache, false);
|
return _transportExtraCache ??= JsonUtils.Deserialize<TransportExtraItem>(TransportExtra) ?? new TransportExtraItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolExtraItem GetProtocolExtra()
|
public void SetTransportExtra(TransportExtraItem transportExtra)
|
||||||
{
|
{
|
||||||
return _protocolExtraCache ??= JsonUtils.Deserialize<ProtocolExtraItem>(ProtoExtra) ?? new ProtocolExtraItem();
|
_transportExtraCache = transportExtra;
|
||||||
|
TransportExtra = JsonUtils.Serialize(transportExtra, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion function
|
#endregion function
|
||||||
|
|
@ -160,9 +164,16 @@ public class ProfileItem
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
public string Network { get; set; }
|
public string Network { get; set; }
|
||||||
|
|
||||||
|
[Obsolete("Use TransportExtra.RawHeaderType/XhttpMode/GrpcMode/KcpHeaderType instead.")]
|
||||||
public string HeaderType { get; set; }
|
public string HeaderType { get; set; }
|
||||||
|
|
||||||
|
[Obsolete("Use TransportExtra.Host/GrpcAuthority instead.")]
|
||||||
public string RequestHost { get; set; }
|
public string RequestHost { get; set; }
|
||||||
|
|
||||||
|
[Obsolete("Use TransportExtra.Path/GrpcServiceName/KcpSeed instead.")]
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
|
|
||||||
public string StreamSecurity { get; set; }
|
public string StreamSecurity { get; set; }
|
||||||
public string AllowInsecure { get; set; }
|
public string AllowInsecure { get; set; }
|
||||||
public string Sni { get; set; }
|
public string Sni { get; set; }
|
||||||
|
|
@ -172,7 +183,10 @@ public class ProfileItem
|
||||||
public string ShortId { get; set; }
|
public string ShortId { get; set; }
|
||||||
public string SpiderX { get; set; }
|
public string SpiderX { get; set; }
|
||||||
public string Mldsa65Verify { get; set; }
|
public string Mldsa65Verify { get; set; }
|
||||||
|
|
||||||
|
[Obsolete("Use TransportExtra.XhttpExtra instead.")]
|
||||||
public string Extra { get; set; }
|
public string Extra { get; set; }
|
||||||
|
|
||||||
public bool? MuxEnabled { get; set; }
|
public bool? MuxEnabled { get; set; }
|
||||||
public string Cert { get; set; }
|
public string Cert { get; set; }
|
||||||
public string CertSha { get; set; }
|
public string CertSha { get; set; }
|
||||||
|
|
@ -181,6 +195,7 @@ public class ProfileItem
|
||||||
public string Finalmask { get; set; }
|
public string Finalmask { get; set; }
|
||||||
|
|
||||||
public string ProtoExtra { get; set; }
|
public string ProtoExtra { get; set; }
|
||||||
|
public string TransportExtra { get; set; }
|
||||||
|
|
||||||
[Obsolete("Use ProtocolExtraItem.Ports instead.")]
|
[Obsolete("Use ProtocolExtraItem.Ports instead.")]
|
||||||
public string Ports { get; set; }
|
public string Ports { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -261,14 +261,6 @@ public class Server4Sbox : BaseServer4Sbox
|
||||||
|
|
||||||
// public List<string>? path { get; set; } // hosts
|
// public List<string>? path { get; set; } // hosts
|
||||||
public Dictionary<string, List<string>>? predefined { get; set; }
|
public Dictionary<string, List<string>>? predefined { get; set; }
|
||||||
|
|
||||||
// Deprecated in sing-box 1.12.0 , kept for backward compatibility
|
|
||||||
public string? address { get; set; }
|
|
||||||
|
|
||||||
public string? address_resolver { get; set; }
|
|
||||||
public string? address_strategy { get; set; }
|
|
||||||
public string? strategy { get; set; }
|
|
||||||
// Deprecated End
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Experimental4Sbox
|
public class Experimental4Sbox
|
||||||
|
|
|
||||||
18
v2rayN/ServiceLib/Models/TransportExtraItem.cs
Normal file
18
v2rayN/ServiceLib/Models/TransportExtraItem.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
|
public record TransportExtraItem
|
||||||
|
{
|
||||||
|
public string? RawHeaderType { get; init; }
|
||||||
|
|
||||||
|
public string? Host { get; init; }
|
||||||
|
public string? Path { get; init; }
|
||||||
|
public string? XhttpMode { get; init; }
|
||||||
|
public string? XhttpExtra { get; init; }
|
||||||
|
|
||||||
|
public string? GrpcAuthority { get; init; }
|
||||||
|
public string? GrpcServiceName { get; init; }
|
||||||
|
public string? GrpcMode { get; init; }
|
||||||
|
|
||||||
|
public string? KcpHeaderType { get; init; }
|
||||||
|
public string? KcpSeed { get; init; }
|
||||||
|
}
|
||||||
|
|
@ -47,9 +47,9 @@ public class Inbounds4Ray
|
||||||
{
|
{
|
||||||
public string tag { get; set; }
|
public string tag { get; set; }
|
||||||
|
|
||||||
public int port { get; set; }
|
public int? port { get; set; }
|
||||||
|
|
||||||
public string listen { get; set; }
|
public string? listen { get; set; }
|
||||||
|
|
||||||
public string protocol { get; set; }
|
public string protocol { get; set; }
|
||||||
|
|
||||||
|
|
@ -75,6 +75,18 @@ public class Inboundsettings4Ray
|
||||||
public bool? allowTransparent { get; set; }
|
public bool? allowTransparent { get; set; }
|
||||||
|
|
||||||
public List<AccountsItem4Ray>? accounts { get; set; }
|
public List<AccountsItem4Ray>? accounts { get; set; }
|
||||||
|
|
||||||
|
public string? name { get; set; }
|
||||||
|
|
||||||
|
public int? MTU { get; set; }
|
||||||
|
|
||||||
|
public List<string>? gateway { get; set; }
|
||||||
|
|
||||||
|
public List<string>? autoSystemRoutingTable { get; set; }
|
||||||
|
|
||||||
|
public string? autoOutboundsInterface { get; set; }
|
||||||
|
|
||||||
|
// public List<string>? dns { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UsersItem4Ray
|
public class UsersItem4Ray
|
||||||
|
|
@ -128,11 +140,10 @@ public class Outboundsettings4Ray
|
||||||
|
|
||||||
public int? userLevel { get; set; }
|
public int? userLevel { get; set; }
|
||||||
|
|
||||||
public FragmentItem4Ray? fragment { get; set; }
|
|
||||||
|
|
||||||
public string? secretKey { get; set; }
|
public string? secretKey { get; set; }
|
||||||
|
|
||||||
public Object? address { get; set; }
|
public object? address { get; set; }
|
||||||
|
|
||||||
public int? port { get; set; }
|
public int? port { get; set; }
|
||||||
|
|
||||||
public List<WireguardPeer4Ray>? peers { get; set; }
|
public List<WireguardPeer4Ray>? peers { get; set; }
|
||||||
|
|
@ -319,7 +330,7 @@ public class StreamSettings4Ray
|
||||||
|
|
||||||
public TlsSettings4Ray? tlsSettings { get; set; }
|
public TlsSettings4Ray? tlsSettings { get; set; }
|
||||||
|
|
||||||
public TcpSettings4Ray? tcpSettings { get; set; }
|
public RawSettings4Ray? rawSettings { get; set; }
|
||||||
|
|
||||||
public KcpSettings4Ray? kcpSettings { get; set; }
|
public KcpSettings4Ray? kcpSettings { get; set; }
|
||||||
|
|
||||||
|
|
@ -373,7 +384,7 @@ public class CertificateSettings4Ray
|
||||||
public string? usage { get; set; }
|
public string? usage { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TcpSettings4Ray
|
public class RawSettings4Ray
|
||||||
{
|
{
|
||||||
public Header4Ray header { get; set; }
|
public Header4Ray header { get; set; }
|
||||||
}
|
}
|
||||||
|
|
@ -397,11 +408,9 @@ public class KcpSettings4Ray
|
||||||
|
|
||||||
public int downlinkCapacity { get; set; }
|
public int downlinkCapacity { get; set; }
|
||||||
|
|
||||||
public bool congestion { get; set; }
|
public int cwndMultiplier { get; set; }
|
||||||
|
|
||||||
public int readBufferSize { get; set; }
|
public int maxSendingWindow { get; set; }
|
||||||
|
|
||||||
public int writeBufferSize { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WsSettings4Ray
|
public class WsSettings4Ray
|
||||||
|
|
@ -491,6 +500,19 @@ public class MaskSettings4Ray
|
||||||
{
|
{
|
||||||
public string? password { get; set; }
|
public string? password { get; set; }
|
||||||
public string? domain { get; set; }
|
public string? domain { get; set; }
|
||||||
|
// fragment
|
||||||
|
public string? packets { get; set; }
|
||||||
|
public string? length { get; set; }
|
||||||
|
public string? delay { get; set; }
|
||||||
|
// noise
|
||||||
|
public int? reset { get; set; }
|
||||||
|
public List<NoiseMask4Ray>? noise { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NoiseMask4Ray
|
||||||
|
{
|
||||||
|
public string? rand { get; set; }
|
||||||
|
public string? delay { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class QuicParams4Ray
|
public class QuicParams4Ray
|
||||||
|
|
@ -511,6 +533,8 @@ public class AccountsItem4Ray
|
||||||
public class Sockopt4Ray
|
public class Sockopt4Ray
|
||||||
{
|
{
|
||||||
public string? dialerProxy { get; set; }
|
public string? dialerProxy { get; set; }
|
||||||
|
[JsonPropertyName("interface")]
|
||||||
|
public string? Interface { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FragmentItem4Ray
|
public class FragmentItem4Ray
|
||||||
|
|
|
||||||
94
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
94
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
|
|
@ -2580,6 +2580,24 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 Allow insecure cert fetch (self-signed) 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string TbAllowInsecureCertFetch {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("TbAllowInsecureCertFetch", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 Only for fetching self-signed certificates. This may expose you to MITM risks. 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string TbAllowInsecureCertFetchTips {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("TbAllowInsecureCertFetchTips", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 ALPN 的本地化字符串。
|
/// 查找类似 ALPN 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -2670,6 +2688,15 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 Camouflage domain 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string TbCamouflageDomain {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("TbCamouflageDomain", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 Cancel 的本地化字符串。
|
/// 查找类似 Cancel 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -3087,6 +3114,15 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 Host 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string TbHost {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("TbHost", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 ICMP routing policy 的本地化字符串。
|
/// 查找类似 ICMP routing policy 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -3393,15 +3429,6 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查找类似 Camouflage domain(host) 的本地化字符串。
|
|
||||||
/// </summary>
|
|
||||||
public static string TbRequestHost {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("TbRequestHost", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 Reserved (2,3,4) 的本地化字符串。
|
/// 查找类似 Reserved (2,3,4) 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -3772,7 +3799,7 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 This parameter is valid only for tcp/http, ws, gRPC and xhttp 的本地化字符串。
|
/// 查找类似 This parameter is valid only for raw/http, ws, gRPC and xhttp 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string TbSettingsDefUserAgentTips {
|
public static string TbSettingsDefUserAgentTips {
|
||||||
get {
|
get {
|
||||||
|
|
@ -4681,7 +4708,7 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 *Default value tcp 的本地化字符串。
|
/// 查找类似 *Default value raw 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string TipNetwork {
|
public static string TipNetwork {
|
||||||
get {
|
get {
|
||||||
|
|
@ -4699,7 +4726,16 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 XHTTP Extra raw JSON, format: { XHTTP Object } 的本地化字符串。
|
/// 查找类似 XHTTP Extra 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string TransportExtra {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("TransportExtra", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 Raw JSON, format: { XHTTP Object } 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string TransportExtraTip {
|
public static string TransportExtraTip {
|
||||||
get {
|
get {
|
||||||
|
|
@ -4708,47 +4744,47 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 *tcp camouflage type 的本地化字符串。
|
/// 查找类似 raw camouflage type 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string TransportHeaderTypeTip1 {
|
public static string TransportHeaderType1 {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("TransportHeaderTypeTip1", resourceCulture);
|
return ResourceManager.GetString("TransportHeaderType1", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 *kcp camouflage type 的本地化字符串。
|
/// 查找类似 kcp camouflage type 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string TransportHeaderTypeTip2 {
|
public static string TransportHeaderType2 {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("TransportHeaderTypeTip2", resourceCulture);
|
return ResourceManager.GetString("TransportHeaderType2", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 *QUIC camouflage type 的本地化字符串。
|
/// 查找类似 QUIC camouflage type 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string TransportHeaderTypeTip3 {
|
public static string TransportHeaderType3 {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("TransportHeaderTypeTip3", resourceCulture);
|
return ResourceManager.GetString("TransportHeaderType3", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 *grpc mode 的本地化字符串。
|
/// 查找类似 gRPC mode 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string TransportHeaderTypeTip4 {
|
public static string TransportHeaderType4 {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("TransportHeaderTypeTip4", resourceCulture);
|
return ResourceManager.GetString("TransportHeaderType4", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 *xhttp mode 的本地化字符串。
|
/// 查找类似 xhttp mode 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string TransportHeaderTypeTip5 {
|
public static string TransportHeaderType5 {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("TransportHeaderTypeTip5", resourceCulture);
|
return ResourceManager.GetString("TransportHeaderType5", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4780,7 +4816,7 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 *grpc service name 的本地化字符串。
|
/// 查找类似 gRPC service name 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string TransportPathTip4 {
|
public static string TransportPathTip4 {
|
||||||
get {
|
get {
|
||||||
|
|
@ -4834,7 +4870,7 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 *grpc Authority 的本地化字符串。
|
/// 查找类似 gRPC Authority 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string TransportRequestHostTip5 {
|
public static string TransportRequestHostTip5 {
|
||||||
get {
|
get {
|
||||||
|
|
|
||||||
|
|
@ -343,7 +343,7 @@
|
||||||
<value>*QUIC key/Kcp seed</value>
|
<value>*QUIC key/Kcp seed</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportPathTip4" xml:space="preserve">
|
<data name="TransportPathTip4" xml:space="preserve">
|
||||||
<value>*grpc serviceName</value>
|
<value>gRPC serviceName</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportRequestHostTip1" xml:space="preserve">
|
<data name="TransportRequestHostTip1" xml:space="preserve">
|
||||||
<value>*هاست http جدا شده با کاما (،)</value>
|
<value>*هاست http جدا شده با کاما (،)</value>
|
||||||
|
|
@ -357,17 +357,17 @@
|
||||||
<data name="TransportRequestHostTip4" xml:space="preserve">
|
<data name="TransportRequestHostTip4" xml:space="preserve">
|
||||||
<value>*QUIC securty</value>
|
<value>*QUIC securty</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip1" xml:space="preserve">
|
<data name="TransportHeaderType1" xml:space="preserve">
|
||||||
<value>*tcp camouflage type</value>
|
<value>raw camouflage type</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip2" xml:space="preserve">
|
<data name="TransportHeaderType2" xml:space="preserve">
|
||||||
<value>*kcp camouflage type</value>
|
<value>kcp camouflage type</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip3" xml:space="preserve">
|
<data name="TransportHeaderType3" xml:space="preserve">
|
||||||
<value>*QUIC camouflage type</value>
|
<value>QUIC camouflage type</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip4" xml:space="preserve">
|
<data name="TransportHeaderType4" xml:space="preserve">
|
||||||
<value>*حالت grpc</value>
|
<value>حالت grpc</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="LvTLS" xml:space="preserve">
|
<data name="LvTLS" xml:space="preserve">
|
||||||
<value>TLS</value>
|
<value>TLS</value>
|
||||||
|
|
@ -606,9 +606,6 @@
|
||||||
<data name="TbRemarks" xml:space="preserve">
|
<data name="TbRemarks" xml:space="preserve">
|
||||||
<value>نام مستعار (ملاحظات)</value>
|
<value>نام مستعار (ملاحظات)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbRequestHost" xml:space="preserve">
|
|
||||||
<value>Camouflage domain(host)</value>
|
|
||||||
</data>
|
|
||||||
<data name="TbSecurity" xml:space="preserve">
|
<data name="TbSecurity" xml:space="preserve">
|
||||||
<value>روش رمزگذاری (امنیتی)</value>
|
<value>روش رمزگذاری (امنیتی)</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
@ -619,7 +616,7 @@
|
||||||
<value>TLS</value>
|
<value>TLS</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TipNetwork" xml:space="preserve">
|
<data name="TipNetwork" xml:space="preserve">
|
||||||
<value>*مقدار پیش فرض tcp</value>
|
<value>*مقدار پیش فرض raw</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbCoreType" xml:space="preserve">
|
<data name="TbCoreType" xml:space="preserve">
|
||||||
<value>نوع هسته</value>
|
<value>نوع هسته</value>
|
||||||
|
|
@ -937,7 +934,7 @@
|
||||||
<value>User-Agent</value>
|
<value>User-Agent</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||||
<value>This parameter is valid only for tcp/http, ws, gRPC and xhttp</value>
|
<value>This parameter is valid only for raw/http, ws, gRPC and xhttp</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||||
<value>FontFamily (نیاز به راه اندازی مجدد)</value>
|
<value>FontFamily (نیاز به راه اندازی مجدد)</value>
|
||||||
|
|
@ -1102,7 +1099,7 @@
|
||||||
<value>پایان تست...</value>
|
<value>پایان تست...</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||||
<value>*grpc Authority</value>
|
<value>RPC Authority</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="menuAddHttpServer" xml:space="preserve">
|
<data name="menuAddHttpServer" xml:space="preserve">
|
||||||
<value>افزودن سرور [HTTP]</value>
|
<value>افزودن سرور [HTTP]</value>
|
||||||
|
|
@ -1320,11 +1317,11 @@
|
||||||
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
||||||
<value>The password will be validated via the command line. If a validation error causes the application to malfunction, please restart the application. The password will not be stored and must be entered again after each restart.</value>
|
<value>The password will be validated via the command line. If a validation error causes the application to malfunction, please restart the application. The password will not be stored and must be entered again after each restart.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
<data name="TransportHeaderType5" xml:space="preserve">
|
||||||
<value>*حالت xhttp</value>
|
<value>حالت xhttp</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportExtraTip" xml:space="preserve">
|
<data name="TransportExtraTip" xml:space="preserve">
|
||||||
<value>جیسون خام XHTTP Extra, فرمت: { XHTTPObject }</value>
|
<value>Raw JSON, format: { XHTTP Object }</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
||||||
<value>هنگام بستن پنجره در سینی پنهان شوید</value>
|
<value>هنگام بستن پنجره در سینی پنهان شوید</value>
|
||||||
|
|
@ -1710,4 +1707,19 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||||
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="TbCamouflageDomain" xml:space="preserve">
|
||||||
|
<value>Camouflage domain</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbHost" xml:space="preserve">
|
||||||
|
<value>Host</value>
|
||||||
|
</data>
|
||||||
|
<data name="TransportExtra" xml:space="preserve">
|
||||||
|
<value>XHTTP Extra</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbAllowInsecureCertFetch" xml:space="preserve">
|
||||||
|
<value>Allow insecure cert fetch (self-signed)</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbAllowInsecureCertFetchTips" xml:space="preserve">
|
||||||
|
<value>Only for fetching self-signed certificates. This may expose you to MITM risks.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
@ -343,7 +343,7 @@
|
||||||
<value>*clé de chiffrement QUIC</value>
|
<value>*clé de chiffrement QUIC</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportPathTip4" xml:space="preserve">
|
<data name="TransportPathTip4" xml:space="preserve">
|
||||||
<value>*nom de service gRPC</value>
|
<value>nom de service gRPC</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportRequestHostTip1" xml:space="preserve">
|
<data name="TransportRequestHostTip1" xml:space="preserve">
|
||||||
<value>*hôte http, séparés par des virgules (,)</value>
|
<value>*hôte http, séparés par des virgules (,)</value>
|
||||||
|
|
@ -357,17 +357,17 @@
|
||||||
<data name="TransportRequestHostTip4" xml:space="preserve">
|
<data name="TransportRequestHostTip4" xml:space="preserve">
|
||||||
<value>*méthode de chiffrement QUIC</value>
|
<value>*méthode de chiffrement QUIC</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip1" xml:space="preserve">
|
<data name="TransportHeaderType1" xml:space="preserve">
|
||||||
<value>*type de camouflage tcp</value>
|
<value>type de camouflage raw</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip2" xml:space="preserve">
|
<data name="TransportHeaderType2" xml:space="preserve">
|
||||||
<value>*type de camouflage kcp</value>
|
<value>type de camouflage kcp</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip3" xml:space="preserve">
|
<data name="TransportHeaderType3" xml:space="preserve">
|
||||||
<value>*type de camouflage QUIC</value>
|
<value>type de camouflage QUIC</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip4" xml:space="preserve">
|
<data name="TransportHeaderType4" xml:space="preserve">
|
||||||
<value>*mode gRPC</value>
|
<value>mode gRPC</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="LvTLS" xml:space="preserve">
|
<data name="LvTLS" xml:space="preserve">
|
||||||
<value>TLS</value>
|
<value>TLS</value>
|
||||||
|
|
@ -606,9 +606,6 @@
|
||||||
<data name="TbRemarks" xml:space="preserve">
|
<data name="TbRemarks" xml:space="preserve">
|
||||||
<value>Alias (remarks)</value>
|
<value>Alias (remarks)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbRequestHost" xml:space="preserve">
|
|
||||||
<value>Domaine de camouflage (host)</value>
|
|
||||||
</data>
|
|
||||||
<data name="TbSecurity" xml:space="preserve">
|
<data name="TbSecurity" xml:space="preserve">
|
||||||
<value>Méthode de chiffrement (security)</value>
|
<value>Méthode de chiffrement (security)</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
@ -619,7 +616,7 @@
|
||||||
<value>Sécurité couche transport (TLS)</value>
|
<value>Sécurité couche transport (TLS)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TipNetwork" xml:space="preserve">
|
<data name="TipNetwork" xml:space="preserve">
|
||||||
<value>*tcp par défaut ; un mauvais choix bloque la connexion</value>
|
<value>*raw par défaut ; un mauvais choix bloque la connexion</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbCoreType" xml:space="preserve">
|
<data name="TbCoreType" xml:space="preserve">
|
||||||
<value>Type de Core</value>
|
<value>Type de Core</value>
|
||||||
|
|
@ -937,7 +934,7 @@
|
||||||
<value>Agent utilisateur (User-Agent)</value>
|
<value>Agent utilisateur (User-Agent)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||||
<value>This parameter is valid only for tcp/http, ws, gRPC and xhttp</value>
|
<value>This parameter is valid only for raw/http, ws, gRPC and xhttp</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||||
<value>Police actuelle (redémarrage requis)</value>
|
<value>Police actuelle (redémarrage requis)</value>
|
||||||
|
|
@ -1099,7 +1096,7 @@
|
||||||
<value>Arrêt du test en cours...</value>
|
<value>Arrêt du test en cours...</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||||
<value>*Autorité gRPC</value>
|
<value>Autorité gRPC</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="menuAddHttpServer" xml:space="preserve">
|
<data name="menuAddHttpServer" xml:space="preserve">
|
||||||
<value>Ajouter [HTTP]</value>
|
<value>Ajouter [HTTP]</value>
|
||||||
|
|
@ -1321,16 +1318,16 @@
|
||||||
<value>Adresse sortante locale (SendThrough)</value>
|
<value>Adresse sortante locale (SendThrough)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||||
<value>Pour environnement multi-interfaces, veuillez saisir l’adresse IPv4 de la machine locale.</value>
|
<value>Pour environnements multi-interfaces, entrez l'adresse IPv4 de la machine locale.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
||||||
<value>Veuillez saisir l’adresse IPv4 correcte de SendThrough.</value>
|
<value>Veuillez saisir l’adresse IPv4 correcte de SendThrough.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
<data name="TransportHeaderType5" xml:space="preserve">
|
||||||
<value>*Mode XHTTP</value>
|
<value>Mode XHTTP</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportExtraTip" xml:space="preserve">
|
<data name="TransportExtraTip" xml:space="preserve">
|
||||||
<value>JSON brut XHTTP Extra, format : { XHTTPObject }</value>
|
<value>Raw JSON, format: { XHTTP Object }</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
||||||
<value>Masquer dans la barre d’état à la fermeture de la fenêtre</value>
|
<value>Masquer dans la barre d’état à la fermeture de la fenêtre</value>
|
||||||
|
|
@ -1713,7 +1710,19 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||||
<data name="TbLegacyProtect" xml:space="preserve">
|
<data name="TbLegacyProtect" xml:space="preserve">
|
||||||
<value>Protection TUN héritée</value>
|
<value>Protection TUN héritée</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
<data name="TbCamouflageDomain" xml:space="preserve">
|
||||||
<value>Pour environnements multi-interfaces, entrez l’adresse IPv4 de la machine locale.</value>
|
<value>Domaine de camouflage</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbHost" xml:space="preserve">
|
||||||
|
<value>Host</value>
|
||||||
|
</data>
|
||||||
|
<data name="TransportExtra" xml:space="preserve">
|
||||||
|
<value>XHTTP Extra</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbAllowInsecureCertFetch" xml:space="preserve">
|
||||||
|
<value>Allow insecure cert fetch (self-signed)</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbAllowInsecureCertFetchTips" xml:space="preserve">
|
||||||
|
<value>Only for fetching self-signed certificates. This may expose you to MITM risks.</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
@ -343,7 +343,7 @@
|
||||||
<value>*QUIC kulcs/KCP seed</value>
|
<value>*QUIC kulcs/KCP seed</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportPathTip4" xml:space="preserve">
|
<data name="TransportPathTip4" xml:space="preserve">
|
||||||
<value>*grpc szolgáltatásnév</value>
|
<value>gRPC szolgáltatásnév</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportRequestHostTip1" xml:space="preserve">
|
<data name="TransportRequestHostTip1" xml:space="preserve">
|
||||||
<value>*http host vesszővel elválasztva (,)</value>
|
<value>*http host vesszővel elválasztva (,)</value>
|
||||||
|
|
@ -357,17 +357,17 @@
|
||||||
<data name="TransportRequestHostTip4" xml:space="preserve">
|
<data name="TransportRequestHostTip4" xml:space="preserve">
|
||||||
<value>*QUIC biztonság</value>
|
<value>*QUIC biztonság</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip1" xml:space="preserve">
|
<data name="TransportHeaderType1" xml:space="preserve">
|
||||||
<value>*tcp álcázási típus</value>
|
<value>raw álcázási típus</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip2" xml:space="preserve">
|
<data name="TransportHeaderType2" xml:space="preserve">
|
||||||
<value>*kcp álcázási típus</value>
|
<value>kcp álcázási típus</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip3" xml:space="preserve">
|
<data name="TransportHeaderType3" xml:space="preserve">
|
||||||
<value>*QUIC álcázási típus</value>
|
<value>QUIC álcázási típus</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip4" xml:space="preserve">
|
<data name="TransportHeaderType4" xml:space="preserve">
|
||||||
<value>*grpc mód</value>
|
<value>gRPC mód</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="LvTLS" xml:space="preserve">
|
<data name="LvTLS" xml:space="preserve">
|
||||||
<value>TLS</value>
|
<value>TLS</value>
|
||||||
|
|
@ -606,9 +606,6 @@
|
||||||
<data name="TbRemarks" xml:space="preserve">
|
<data name="TbRemarks" xml:space="preserve">
|
||||||
<value>Alias (megjegyzések)</value>
|
<value>Alias (megjegyzések)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbRequestHost" xml:space="preserve">
|
|
||||||
<value>Álcázási tartomány(host)</value>
|
|
||||||
</data>
|
|
||||||
<data name="TbSecurity" xml:space="preserve">
|
<data name="TbSecurity" xml:space="preserve">
|
||||||
<value>Titkosítási módszer (biztonság)</value>
|
<value>Titkosítási módszer (biztonság)</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
@ -619,7 +616,7 @@
|
||||||
<value>TLS</value>
|
<value>TLS</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TipNetwork" xml:space="preserve">
|
<data name="TipNetwork" xml:space="preserve">
|
||||||
<value>*Alapértelmezett érték tcp</value>
|
<value>*Alapértelmezett érték raw</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbCoreType" xml:space="preserve">
|
<data name="TbCoreType" xml:space="preserve">
|
||||||
<value>Core Típus</value>
|
<value>Core Típus</value>
|
||||||
|
|
@ -937,7 +934,7 @@
|
||||||
<value>User-Agent</value>
|
<value>User-Agent</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||||
<value>This parameter is valid only for tcp/http, ws, gRPC and xhttp</value>
|
<value>This parameter is valid only for raw/http, ws, gRPC and xhttp</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||||
<value>Betűtípus (újraindítást igényel)</value>
|
<value>Betűtípus (újraindítást igényel)</value>
|
||||||
|
|
@ -1102,7 +1099,7 @@
|
||||||
<value>Teszt megszakítása...</value>
|
<value>Teszt megszakítása...</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||||
<value>*grpc Authority</value>
|
<value>gRPC Authority</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="menuAddHttpServer" xml:space="preserve">
|
<data name="menuAddHttpServer" xml:space="preserve">
|
||||||
<value>HTTP konfiguráció hozzáadása</value>
|
<value>HTTP konfiguráció hozzáadása</value>
|
||||||
|
|
@ -1320,11 +1317,11 @@
|
||||||
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
||||||
<value>A jelszót a parancssoron keresztül ellenőrizzük. Ha egy érvényesítési hiba miatt az alkalmazás hibásan működik, indítsa újra az alkalmazást. A jelszó nem kerül tárolásra, és minden újraindítás után újra meg kell adni.</value>
|
<value>A jelszót a parancssoron keresztül ellenőrizzük. Ha egy érvényesítési hiba miatt az alkalmazás hibásan működik, indítsa újra az alkalmazást. A jelszó nem kerül tárolásra, és minden újraindítás után újra meg kell adni.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
<data name="TransportHeaderType5" xml:space="preserve">
|
||||||
<value>*xhttp mód</value>
|
<value>xhttp mód</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportExtraTip" xml:space="preserve">
|
<data name="TransportExtraTip" xml:space="preserve">
|
||||||
<value>XHTTP Extra nyers JSON, formátum: { XHTTP Objektum }</value>
|
<value>Raw JSON, format: { XHTTP Object }</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
||||||
<value>Ablak bezárásakor a tálcára rejtés</value>
|
<value>Ablak bezárásakor a tálcára rejtés</value>
|
||||||
|
|
@ -1710,4 +1707,19 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||||
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="TbCamouflageDomain" xml:space="preserve">
|
||||||
|
<value>Álcázási tartomány</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbHost" xml:space="preserve">
|
||||||
|
<value>Host</value>
|
||||||
|
</data>
|
||||||
|
<data name="TransportExtra" xml:space="preserve">
|
||||||
|
<value>XHTTP Extra</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbAllowInsecureCertFetch" xml:space="preserve">
|
||||||
|
<value>Allow insecure cert fetch (self-signed)</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbAllowInsecureCertFetchTips" xml:space="preserve">
|
||||||
|
<value>Only for fetching self-signed certificates. This may expose you to MITM risks.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
@ -343,7 +343,7 @@
|
||||||
<value>*QUIC key/KCP seed</value>
|
<value>*QUIC key/KCP seed</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportPathTip4" xml:space="preserve">
|
<data name="TransportPathTip4" xml:space="preserve">
|
||||||
<value>*grpc service name</value>
|
<value>gRPC service name</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportRequestHostTip1" xml:space="preserve">
|
<data name="TransportRequestHostTip1" xml:space="preserve">
|
||||||
<value>*http host separated by commas (,)</value>
|
<value>*http host separated by commas (,)</value>
|
||||||
|
|
@ -357,17 +357,17 @@
|
||||||
<data name="TransportRequestHostTip4" xml:space="preserve">
|
<data name="TransportRequestHostTip4" xml:space="preserve">
|
||||||
<value>*QUIC security</value>
|
<value>*QUIC security</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip1" xml:space="preserve">
|
<data name="TransportHeaderType1" xml:space="preserve">
|
||||||
<value>*tcp camouflage type</value>
|
<value>raw camouflage type</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip2" xml:space="preserve">
|
<data name="TransportHeaderType2" xml:space="preserve">
|
||||||
<value>*kcp camouflage type</value>
|
<value>kcp camouflage type</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip3" xml:space="preserve">
|
<data name="TransportHeaderType3" xml:space="preserve">
|
||||||
<value>*QUIC camouflage type</value>
|
<value>QUIC camouflage type</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip4" xml:space="preserve">
|
<data name="TransportHeaderType4" xml:space="preserve">
|
||||||
<value>*grpc mode</value>
|
<value>gRPC mode</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="LvTLS" xml:space="preserve">
|
<data name="LvTLS" xml:space="preserve">
|
||||||
<value>TLS</value>
|
<value>TLS</value>
|
||||||
|
|
@ -606,9 +606,6 @@
|
||||||
<data name="TbRemarks" xml:space="preserve">
|
<data name="TbRemarks" xml:space="preserve">
|
||||||
<value>Alias (remarks)</value>
|
<value>Alias (remarks)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbRequestHost" xml:space="preserve">
|
|
||||||
<value>Camouflage domain(host)</value>
|
|
||||||
</data>
|
|
||||||
<data name="TbSecurity" xml:space="preserve">
|
<data name="TbSecurity" xml:space="preserve">
|
||||||
<value>Encryption method (security)</value>
|
<value>Encryption method (security)</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
@ -619,7 +616,7 @@
|
||||||
<value>TLS</value>
|
<value>TLS</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TipNetwork" xml:space="preserve">
|
<data name="TipNetwork" xml:space="preserve">
|
||||||
<value>*Default value tcp</value>
|
<value>*Default value raw</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbCoreType" xml:space="preserve">
|
<data name="TbCoreType" xml:space="preserve">
|
||||||
<value>Core Type</value>
|
<value>Core Type</value>
|
||||||
|
|
@ -937,7 +934,7 @@
|
||||||
<value>User-Agent</value>
|
<value>User-Agent</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||||
<value>This parameter is valid only for tcp/http, ws, gRPC and xhttp</value>
|
<value>This parameter is valid only for raw/http, ws, gRPC and xhttp</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||||
<value>Font family (requires restart)</value>
|
<value>Font family (requires restart)</value>
|
||||||
|
|
@ -1102,7 +1099,7 @@
|
||||||
<value>Test terminating...</value>
|
<value>Test terminating...</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||||
<value>*grpc Authority</value>
|
<value>gRPC Authority</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="menuAddHttpServer" xml:space="preserve">
|
<data name="menuAddHttpServer" xml:space="preserve">
|
||||||
<value>Add [HTTP]</value>
|
<value>Add [HTTP]</value>
|
||||||
|
|
@ -1329,11 +1326,11 @@
|
||||||
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
||||||
<value>Please fill in the correct IPv4 address for SendThrough.</value>
|
<value>Please fill in the correct IPv4 address for SendThrough.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
<data name="TransportHeaderType5" xml:space="preserve">
|
||||||
<value>*xhttp mode</value>
|
<value>xhttp mode</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportExtraTip" xml:space="preserve">
|
<data name="TransportExtraTip" xml:space="preserve">
|
||||||
<value>XHTTP Extra raw JSON, format: { XHTTP Object }</value>
|
<value>Raw JSON, format: { XHTTP Object }</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
||||||
<value>Hide to tray when closing the window</value>
|
<value>Hide to tray when closing the window</value>
|
||||||
|
|
@ -1716,4 +1713,19 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||||
<data name="TbLegacyProtect" xml:space="preserve">
|
<data name="TbLegacyProtect" xml:space="preserve">
|
||||||
<value>Legacy TUN Protect</value>
|
<value>Legacy TUN Protect</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="TbCamouflageDomain" xml:space="preserve">
|
||||||
|
<value>Camouflage domain</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbHost" xml:space="preserve">
|
||||||
|
<value>Host</value>
|
||||||
|
</data>
|
||||||
|
<data name="TransportExtra" xml:space="preserve">
|
||||||
|
<value>XHTTP Extra</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbAllowInsecureCertFetch" xml:space="preserve">
|
||||||
|
<value>Allow insecure cert fetch (self-signed)</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbAllowInsecureCertFetchTips" xml:space="preserve">
|
||||||
|
<value>Only for fetching self-signed certificates. This may expose you to MITM risks.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
@ -343,7 +343,7 @@
|
||||||
<value>*QUIC-ключ / KCP-seed</value>
|
<value>*QUIC-ключ / KCP-seed</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportPathTip4" xml:space="preserve">
|
<data name="TransportPathTip4" xml:space="preserve">
|
||||||
<value>Имя сервиса *gRPC</value>
|
<value>Имя сервиса gRPC</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportRequestHostTip1" xml:space="preserve">
|
<data name="TransportRequestHostTip1" xml:space="preserve">
|
||||||
<value>*http-хосты, разделённые запятыми (,)</value>
|
<value>*http-хосты, разделённые запятыми (,)</value>
|
||||||
|
|
@ -357,17 +357,17 @@
|
||||||
<data name="TransportRequestHostTip4" xml:space="preserve">
|
<data name="TransportRequestHostTip4" xml:space="preserve">
|
||||||
<value>Безопасность *QUIC</value>
|
<value>Безопасность *QUIC</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip1" xml:space="preserve">
|
<data name="TransportHeaderType1" xml:space="preserve">
|
||||||
<value>Тип *TCP-камуфляжа</value>
|
<value>Тип raw-камуфляжа</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip2" xml:space="preserve">
|
<data name="TransportHeaderType2" xml:space="preserve">
|
||||||
<value>Тип *KCP-камуфляжа</value>
|
<value>Тип KCP-камуфляжа</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip3" xml:space="preserve">
|
<data name="TransportHeaderType3" xml:space="preserve">
|
||||||
<value>Тип *QUIC-камуфляжа</value>
|
<value>Тип QUIC-камуфляжа</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip4" xml:space="preserve">
|
<data name="TransportHeaderType4" xml:space="preserve">
|
||||||
<value>Режим *gRPC</value>
|
<value>Режим gRPC</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="LvTLS" xml:space="preserve">
|
<data name="LvTLS" xml:space="preserve">
|
||||||
<value>TLS</value>
|
<value>TLS</value>
|
||||||
|
|
@ -606,9 +606,6 @@
|
||||||
<data name="TbRemarks" xml:space="preserve">
|
<data name="TbRemarks" xml:space="preserve">
|
||||||
<value>Псевдоним (remarks)</value>
|
<value>Псевдоним (remarks)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbRequestHost" xml:space="preserve">
|
|
||||||
<value>Камуфляжный домен (host)</value>
|
|
||||||
</data>
|
|
||||||
<data name="TbSecurity" xml:space="preserve">
|
<data name="TbSecurity" xml:space="preserve">
|
||||||
<value>Метод шифрования (security)</value>
|
<value>Метод шифрования (security)</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
@ -619,7 +616,7 @@
|
||||||
<value>TLS</value>
|
<value>TLS</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TipNetwork" xml:space="preserve">
|
<data name="TipNetwork" xml:space="preserve">
|
||||||
<value>*По умолчанию TCP</value>
|
<value>*По-умолчанию raw</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbCoreType" xml:space="preserve">
|
<data name="TbCoreType" xml:space="preserve">
|
||||||
<value>Ядро</value>
|
<value>Ядро</value>
|
||||||
|
|
@ -937,7 +934,7 @@
|
||||||
<value>User-Agent</value>
|
<value>User-Agent</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||||
<value>This parameter is valid only for tcp/http, ws, gRPC and xhttp</value>
|
<value>This parameter is valid only for raw/http, ws, gRPC and xhttp</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||||
<value>Шрифт (требуется перезапуск)</value>
|
<value>Шрифт (требуется перезапуск)</value>
|
||||||
|
|
@ -1102,7 +1099,7 @@
|
||||||
<value>Завершение тестирования...</value>
|
<value>Завершение тестирования...</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||||
<value>* gRPC Authority (HTTP/2 псевдозаголовок :authority)</value>
|
<value>gRPC Authority (HTTP/2 псевдозаголовок :authority)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="menuAddHttpServer" xml:space="preserve">
|
<data name="menuAddHttpServer" xml:space="preserve">
|
||||||
<value>Добавить сервер [HTTP]</value>
|
<value>Добавить сервер [HTTP]</value>
|
||||||
|
|
@ -1320,11 +1317,11 @@
|
||||||
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
||||||
<value>Пароль sudo будет проверен в терминале. Если из-за ошибки проверки приложение начнёт работать некорректно, перезапустите его. Пароль не сохраняется — его нужно вводить после каждого перезапуска.</value>
|
<value>Пароль sudo будет проверен в терминале. Если из-за ошибки проверки приложение начнёт работать некорректно, перезапустите его. Пароль не сохраняется — его нужно вводить после каждого перезапуска.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
<data name="TransportHeaderType5" xml:space="preserve">
|
||||||
<value>*XHTTP-режим</value>
|
<value>XHTTP-режим</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportExtraTip" xml:space="preserve">
|
<data name="TransportExtraTip" xml:space="preserve">
|
||||||
<value>Дополнительный сырой JSON для XHTTP, формат: { XHTTP Object }</value>
|
<value>Raw JSON, format: { XHTTP Object }</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
||||||
<value>Сворачивать в трей при закрытии окна</value>
|
<value>Сворачивать в трей при закрытии окна</value>
|
||||||
|
|
@ -1710,4 +1707,19 @@
|
||||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||||
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="TbCamouflageDomain" xml:space="preserve">
|
||||||
|
<value>Камуфляжный домен</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbHost" xml:space="preserve">
|
||||||
|
<value>Host</value>
|
||||||
|
</data>
|
||||||
|
<data name="TransportExtra" xml:space="preserve">
|
||||||
|
<value>XHTTP Extra</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbAllowInsecureCertFetch" xml:space="preserve">
|
||||||
|
<value>Allow insecure cert fetch (self-signed)</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbAllowInsecureCertFetchTips" xml:space="preserve">
|
||||||
|
<value>Only for fetching self-signed certificates. This may expose you to MITM risks.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
@ -343,7 +343,7 @@
|
||||||
<value>*QUIC 加密密钥</value>
|
<value>*QUIC 加密密钥</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportPathTip4" xml:space="preserve">
|
<data name="TransportPathTip4" xml:space="preserve">
|
||||||
<value>*grpc serviceName</value>
|
<value>gRPC serviceName</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportRequestHostTip1" xml:space="preserve">
|
<data name="TransportRequestHostTip1" xml:space="preserve">
|
||||||
<value>*http host 中间逗号 (,) 分隔</value>
|
<value>*http host 中间逗号 (,) 分隔</value>
|
||||||
|
|
@ -357,17 +357,17 @@
|
||||||
<data name="TransportRequestHostTip4" xml:space="preserve">
|
<data name="TransportRequestHostTip4" xml:space="preserve">
|
||||||
<value>*QUIC 加密方式</value>
|
<value>*QUIC 加密方式</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip1" xml:space="preserve">
|
<data name="TransportHeaderType1" xml:space="preserve">
|
||||||
<value>*tcp 伪装类型</value>
|
<value>raw 伪装类型</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip2" xml:space="preserve">
|
<data name="TransportHeaderType2" xml:space="preserve">
|
||||||
<value>*kcp 伪装类型</value>
|
<value>kcp 伪装类型</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip3" xml:space="preserve">
|
<data name="TransportHeaderType3" xml:space="preserve">
|
||||||
<value>*QUIC 伪装类型</value>
|
<value>QUIC 伪装类型</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip4" xml:space="preserve">
|
<data name="TransportHeaderType4" xml:space="preserve">
|
||||||
<value>*grpc 模式</value>
|
<value>gRPC 模式</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="LvTLS" xml:space="preserve">
|
<data name="LvTLS" xml:space="preserve">
|
||||||
<value>TLS</value>
|
<value>TLS</value>
|
||||||
|
|
@ -606,9 +606,6 @@
|
||||||
<data name="TbRemarks" xml:space="preserve">
|
<data name="TbRemarks" xml:space="preserve">
|
||||||
<value>别名 (remarks)</value>
|
<value>别名 (remarks)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbRequestHost" xml:space="preserve">
|
|
||||||
<value>伪装域名 (host)</value>
|
|
||||||
</data>
|
|
||||||
<data name="TbSecurity" xml:space="preserve">
|
<data name="TbSecurity" xml:space="preserve">
|
||||||
<value>加密方式 (security)</value>
|
<value>加密方式 (security)</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
@ -619,7 +616,7 @@
|
||||||
<value>传输层安全 (TLS)</value>
|
<value>传输层安全 (TLS)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TipNetwork" xml:space="preserve">
|
<data name="TipNetwork" xml:space="preserve">
|
||||||
<value>*默认 tcp,选错会无法连接</value>
|
<value>*默认 raw,选错会无法连接</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbCoreType" xml:space="preserve">
|
<data name="TbCoreType" xml:space="preserve">
|
||||||
<value>Core 类型</value>
|
<value>Core 类型</value>
|
||||||
|
|
@ -937,7 +934,7 @@
|
||||||
<value>用户代理 (User-Agent)</value>
|
<value>用户代理 (User-Agent)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||||
<value>仅对 tcp/http、ws、gRPC、xhttp 生效</value>
|
<value>仅对 raw/http、ws、gRPC、xhttp 生效</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||||
<value>当前字体 (需重启)</value>
|
<value>当前字体 (需重启)</value>
|
||||||
|
|
@ -1099,7 +1096,7 @@
|
||||||
<value>测试终止中...</value>
|
<value>测试终止中...</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||||
<value>*grpc Authority</value>
|
<value>gRPC Authority</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="menuAddHttpServer" xml:space="preserve">
|
<data name="menuAddHttpServer" xml:space="preserve">
|
||||||
<value>添加 [HTTP]</value>
|
<value>添加 [HTTP]</value>
|
||||||
|
|
@ -1326,11 +1323,11 @@
|
||||||
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
||||||
<value>请填写正确的 SendThrough IPv4 地址。</value>
|
<value>请填写正确的 SendThrough IPv4 地址。</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
<data name="TransportHeaderType5" xml:space="preserve">
|
||||||
<value>*XHTTP 模式</value>
|
<value>XHTTP 模式</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportExtraTip" xml:space="preserve">
|
<data name="TransportExtraTip" xml:space="preserve">
|
||||||
<value>XHTTP Extra 原始 JSON,格式: { XHTTPObject }</value>
|
<value>原始 JSON,格式: { XHTTPObject }</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
||||||
<value>关闭窗口时隐藏至托盘</value>
|
<value>关闭窗口时隐藏至托盘</value>
|
||||||
|
|
@ -1713,4 +1710,19 @@
|
||||||
<data name="TbLegacyProtect" xml:space="preserve">
|
<data name="TbLegacyProtect" xml:space="preserve">
|
||||||
<value>旧版 TUN 保护</value>
|
<value>旧版 TUN 保护</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="TbCamouflageDomain" xml:space="preserve">
|
||||||
|
<value>伪装域名</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbHost" xml:space="preserve">
|
||||||
|
<value>Host</value>
|
||||||
|
</data>
|
||||||
|
<data name="TransportExtra" xml:space="preserve">
|
||||||
|
<value>XHTTP Extra</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbAllowInsecureCertFetch" xml:space="preserve">
|
||||||
|
<value>允许不安全获取证书(自签名)</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbAllowInsecureCertFetchTips" xml:space="preserve">
|
||||||
|
<value>仅用于抓取自签证书,存在中间人风险。</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
@ -343,7 +343,7 @@
|
||||||
<value>*QUIC 加密金鑰</value>
|
<value>*QUIC 加密金鑰</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportPathTip4" xml:space="preserve">
|
<data name="TransportPathTip4" xml:space="preserve">
|
||||||
<value>*grpc serviceName</value>
|
<value>gRPC serviceName</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportRequestHostTip1" xml:space="preserve">
|
<data name="TransportRequestHostTip1" xml:space="preserve">
|
||||||
<value>*http host 中間逗號 (,) 分隔</value>
|
<value>*http host 中間逗號 (,) 分隔</value>
|
||||||
|
|
@ -357,17 +357,17 @@
|
||||||
<data name="TransportRequestHostTip4" xml:space="preserve">
|
<data name="TransportRequestHostTip4" xml:space="preserve">
|
||||||
<value>*QUIC 加密方式</value>
|
<value>*QUIC 加密方式</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip1" xml:space="preserve">
|
<data name="TransportHeaderType1" xml:space="preserve">
|
||||||
<value>*TCP 偽裝類型</value>
|
<value>raw 偽裝類型</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip2" xml:space="preserve">
|
<data name="TransportHeaderType2" xml:space="preserve">
|
||||||
<value>*KCP 偽裝類型</value>
|
<value>KCP 偽裝類型</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip3" xml:space="preserve">
|
<data name="TransportHeaderType3" xml:space="preserve">
|
||||||
<value>*QUIC 偽裝類型</value>
|
<value>QUIC 偽裝類型</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip4" xml:space="preserve">
|
<data name="TransportHeaderType4" xml:space="preserve">
|
||||||
<value>*GRPC 模式</value>
|
<value>gRPC 模式</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="LvTLS" xml:space="preserve">
|
<data name="LvTLS" xml:space="preserve">
|
||||||
<value>TLS</value>
|
<value>TLS</value>
|
||||||
|
|
@ -606,9 +606,6 @@
|
||||||
<data name="TbRemarks" xml:space="preserve">
|
<data name="TbRemarks" xml:space="preserve">
|
||||||
<value>別名 (remarks)</value>
|
<value>別名 (remarks)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbRequestHost" xml:space="preserve">
|
|
||||||
<value>偽裝域名 (host)</value>
|
|
||||||
</data>
|
|
||||||
<data name="TbSecurity" xml:space="preserve">
|
<data name="TbSecurity" xml:space="preserve">
|
||||||
<value>加密方式 (security)</value>
|
<value>加密方式 (security)</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
@ -619,7 +616,7 @@
|
||||||
<value>傳輸層安全性 (TLS)</value>
|
<value>傳輸層安全性 (TLS)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TipNetwork" xml:space="preserve">
|
<data name="TipNetwork" xml:space="preserve">
|
||||||
<value>*預設 TCP,選錯會無法連線</value>
|
<value>*預設 raw,選錯會無法連線</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbCoreType" xml:space="preserve">
|
<data name="TbCoreType" xml:space="preserve">
|
||||||
<value>Core 類型</value>
|
<value>Core 類型</value>
|
||||||
|
|
@ -937,7 +934,7 @@
|
||||||
<value>使用者代理 (User-Agent)</value>
|
<value>使用者代理 (User-Agent)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||||
<value>僅對 TCP/HTTP、WS、gRPC、XHTTP 生效</value>
|
<value>僅對 raw/HTTP、WS、gRPC、XHTTP 生效</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||||
<value>目前字型 (需重啟)</value>
|
<value>目前字型 (需重啟)</value>
|
||||||
|
|
@ -1099,7 +1096,7 @@
|
||||||
<value>測試終止中...</value>
|
<value>測試終止中...</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||||
<value>*grpc Authority</value>
|
<value>gRPC Authority</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="menuAddHttpServer" xml:space="preserve">
|
<data name="menuAddHttpServer" xml:space="preserve">
|
||||||
<value>新增 [HTTP] 節點</value>
|
<value>新增 [HTTP] 節點</value>
|
||||||
|
|
@ -1317,11 +1314,11 @@
|
||||||
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
||||||
<value>密碼將調用命令行校驗,如果因為校驗錯誤導致無法正常運行時,請重啟本應用。密碼不會存儲,每次重啟後都需要再次輸入。</value>
|
<value>密碼將調用命令行校驗,如果因為校驗錯誤導致無法正常運行時,請重啟本應用。密碼不會存儲,每次重啟後都需要再次輸入。</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
<data name="TransportHeaderType5" xml:space="preserve">
|
||||||
<value>*xhttp 模式</value>
|
<value>xhttp 模式</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TransportExtraTip" xml:space="preserve">
|
<data name="TransportExtraTip" xml:space="preserve">
|
||||||
<value>XHTTP Extra 原始 JSON,格式: { XHTTPObject }</value>
|
<value>原始 JSON,格式: { XHTTPObject }</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
||||||
<value>關閉視窗時隱藏至托盤</value>
|
<value>關閉視窗時隱藏至托盤</value>
|
||||||
|
|
@ -1707,4 +1704,19 @@
|
||||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||||
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="TbCamouflageDomain" xml:space="preserve">
|
||||||
|
<value>偽裝域名</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbHost" xml:space="preserve">
|
||||||
|
<value>Host</value>
|
||||||
|
</data>
|
||||||
|
<data name="TransportExtra" xml:space="preserve">
|
||||||
|
<value>XHTTP Extra</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbAllowInsecureCertFetch" xml:space="preserve">
|
||||||
|
<value>允許不安全獲取證書(自簽名)</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbAllowInsecureCertFetchTips" xml:space="preserve">
|
||||||
|
<value>僅用於抓取自簽證書,存在中間人風險。</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
24
v2rayN/ServiceLib/Sample/SampleTunInbound
Normal file
24
v2rayN/ServiceLib/Sample/SampleTunInbound
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"tag": "tun",
|
||||||
|
"protocol": "tun",
|
||||||
|
"settings": {
|
||||||
|
"name": "xray_tun",
|
||||||
|
"MTU": 9000,
|
||||||
|
"gateway": [
|
||||||
|
"172.18.0.1/30",
|
||||||
|
"fdfe:dcba:9876::1/126"
|
||||||
|
],
|
||||||
|
"autoSystemRoutingTable": [
|
||||||
|
"0.0.0.0/0",
|
||||||
|
"::/0"
|
||||||
|
],
|
||||||
|
"autoOutboundsInterface": "auto"
|
||||||
|
},
|
||||||
|
"sniffing": {
|
||||||
|
"enabled": true,
|
||||||
|
"destOverride": [
|
||||||
|
"http",
|
||||||
|
"tls"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
14
v2rayN/ServiceLib/Sample/SampleTunRules
Normal file
14
v2rayN/ServiceLib/Sample/SampleTunRules
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"network": "udp",
|
||||||
|
"port": "135,137-139,5353",
|
||||||
|
"outboundTag": "block"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ip": [
|
||||||
|
"224.0.0.0/3",
|
||||||
|
"ff00::/8"
|
||||||
|
],
|
||||||
|
"outboundTag": "block"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -38,6 +38,8 @@
|
||||||
<EmbeddedResource Include="Sample\SampleHttpResponse" />
|
<EmbeddedResource Include="Sample\SampleHttpResponse" />
|
||||||
<EmbeddedResource Include="Sample\SampleInbound" />
|
<EmbeddedResource Include="Sample\SampleInbound" />
|
||||||
<EmbeddedResource Include="Sample\SampleOutbound" />
|
<EmbeddedResource Include="Sample\SampleOutbound" />
|
||||||
|
<EmbeddedResource Include="Sample\SampleTunInbound" />
|
||||||
|
<EmbeddedResource Include="Sample\SampleTunRules" />
|
||||||
<EmbeddedResource Include="Sample\SingboxSampleClientConfig" />
|
<EmbeddedResource Include="Sample\SingboxSampleClientConfig" />
|
||||||
<EmbeddedResource Include="Sample\SingboxSampleOutbound" />
|
<EmbeddedResource Include="Sample\SingboxSampleOutbound" />
|
||||||
<EmbeddedResource Include="Sample\tun_singbox_dns" />
|
<EmbeddedResource Include="Sample\tun_singbox_dns" />
|
||||||
|
|
|
||||||
|
|
@ -63,59 +63,6 @@ public partial class CoreConfigSingboxService(CoreConfigContext context)
|
||||||
ret.Success = true;
|
ret.Success = true;
|
||||||
|
|
||||||
ret.Data = ApplyFullConfigTemplate();
|
ret.Data = ApplyFullConfigTemplate();
|
||||||
if (!context.AppConfig.TunModeItem.EnableLegacyProtect
|
|
||||||
&& context.TunProtectSocksPort is > 0 and <= 65535)
|
|
||||||
{
|
|
||||||
// Replace relay proxy outbound, avoid mux or other feature cause issue, and add a socks inbound for tun protect
|
|
||||||
var relayProxyIndex = _coreConfig.outbounds.FindIndex(o => o.tag == Global.ProxyTag);
|
|
||||||
_coreConfig.outbounds[relayProxyIndex] = new Outbound4Sbox()
|
|
||||||
{
|
|
||||||
type = Global.ProtocolTypes[EConfigType.SOCKS],
|
|
||||||
tag = Global.ProxyTag,
|
|
||||||
server = Global.Loopback,
|
|
||||||
server_port = context.ProxyRelaySocksPort,
|
|
||||||
};
|
|
||||||
var ssInbound = new
|
|
||||||
{
|
|
||||||
type = "socks",
|
|
||||||
tag = "tun-protect-socks",
|
|
||||||
listen = Global.Loopback,
|
|
||||||
listen_port = context.TunProtectSocksPort,
|
|
||||||
};
|
|
||||||
var directRule = new Rule4Sbox()
|
|
||||||
{
|
|
||||||
inbound = new List<string> { ssInbound.tag },
|
|
||||||
outbound = Global.DirectTag,
|
|
||||||
};
|
|
||||||
var singboxConfigNode = JsonUtils.ParseJson(ret.Data.ToString())!.AsObject();
|
|
||||||
var inboundsNode = singboxConfigNode["inbounds"]!.AsArray();
|
|
||||||
inboundsNode.Add(JsonUtils.SerializeToNode(ssInbound, new JsonSerializerOptions
|
|
||||||
{
|
|
||||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
|
|
||||||
}));
|
|
||||||
var routeNode = singboxConfigNode["route"]?.AsObject();
|
|
||||||
var rulesNode = routeNode?["rules"]?.AsArray();
|
|
||||||
var protectRuleNode = JsonUtils.SerializeToNode(directRule,
|
|
||||||
new JsonSerializerOptions { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull });
|
|
||||||
if (rulesNode != null)
|
|
||||||
{
|
|
||||||
rulesNode.Insert(0, protectRuleNode);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var newRulesNode = new JsonArray() { protectRuleNode };
|
|
||||||
if (routeNode is null)
|
|
||||||
{
|
|
||||||
var newRouteNode = new JsonObject() { ["rules"] = newRulesNode };
|
|
||||||
singboxConfigNode["route"] = newRouteNode;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
routeNode["rules"] = newRulesNode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ret.Data = JsonUtils.Serialize(singboxConfigNode);
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
||||||
|
|
@ -429,16 +429,8 @@ public partial class CoreConfigSingboxService
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_coreConfig.dns = dns4Sbox;
|
_coreConfig.dns = dns4Sbox;
|
||||||
if (dns4Sbox.servers?.Count > 0 &&
|
|
||||||
dns4Sbox.servers.First().address.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
GenDnsProtectCustom();
|
GenDnsProtectCustom();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
GenDnsProtectCustomLegacy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logging.SaveLog(_tag, ex);
|
Logging.SaveLog(_tag, ex);
|
||||||
|
|
@ -479,23 +471,6 @@ public partial class CoreConfigSingboxService
|
||||||
_coreConfig.dns = dns4Sbox;
|
_coreConfig.dns = dns4Sbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GenDnsProtectCustomLegacy()
|
|
||||||
{
|
|
||||||
GenDnsProtectCustom();
|
|
||||||
|
|
||||||
_coreConfig.dns?.servers?.RemoveAll(s => s.tag == Global.SingboxLocalDNSTag);
|
|
||||||
var dnsItem = context.RawDnsItem;
|
|
||||||
var localDnsServer = new Server4Sbox()
|
|
||||||
{
|
|
||||||
address = string.IsNullOrEmpty(dnsItem?.DomainDNSAddress)
|
|
||||||
? Global.DomainPureIPDNSAddress.FirstOrDefault()
|
|
||||||
: dnsItem?.DomainDNSAddress,
|
|
||||||
tag = Global.SingboxLocalDNSTag,
|
|
||||||
detour = Global.DirectTag,
|
|
||||||
};
|
|
||||||
_coreConfig.dns?.servers?.Add(localDnsServer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Rule4Sbox? BuildProtectDomainRule()
|
private Rule4Sbox? BuildProtectDomainRule()
|
||||||
{
|
{
|
||||||
if (context.ProtectDomainList.Count == 0)
|
if (context.ProtectDomainList.Count == 0)
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,8 @@ public partial class CoreConfigSingboxService
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var protocolExtra = _node.GetProtocolExtra();
|
var protocolExtra = _node.GetProtocolExtra();
|
||||||
|
var transportExtra = _node.GetTransportExtra();
|
||||||
|
var network = _node.GetNetwork();
|
||||||
outbound.server = _node.Address;
|
outbound.server = _node.Address;
|
||||||
outbound.server_port = _node.Port;
|
outbound.server_port = _node.Port;
|
||||||
outbound.type = Global.ProtocolTypes[_node.ConfigType];
|
outbound.type = Global.ProtocolTypes[_node.ConfigType];
|
||||||
|
|
@ -114,27 +116,23 @@ public partial class CoreConfigSingboxService
|
||||||
outbound.password = _node.Password;
|
outbound.password = _node.Password;
|
||||||
outbound.udp_over_tcp = protocolExtra.Uot == true ? true : null;
|
outbound.udp_over_tcp = protocolExtra.Uot == true ? true : null;
|
||||||
|
|
||||||
if (_node.Network == nameof(ETransport.tcp) && _node.HeaderType == Global.TcpHeaderHttp)
|
if (network == nameof(ETransport.raw) && transportExtra.RawHeaderType == Global.RawHeaderHttp)
|
||||||
{
|
{
|
||||||
outbound.plugin = "obfs-local";
|
outbound.plugin = "obfs-local";
|
||||||
outbound.plugin_opts = $"obfs=http;obfs-host={_node.RequestHost};";
|
outbound.plugin_opts = $"obfs=http;obfs-host={transportExtra.Host};";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var pluginArgs = string.Empty;
|
var pluginArgs = string.Empty;
|
||||||
if (_node.Network == nameof(ETransport.ws))
|
if (network == nameof(ETransport.ws))
|
||||||
{
|
{
|
||||||
pluginArgs += "mode=websocket;";
|
pluginArgs += "mode=websocket;";
|
||||||
pluginArgs += $"host={_node.RequestHost};";
|
pluginArgs += $"host={transportExtra.Host};";
|
||||||
// https://github.com/shadowsocks/v2ray-plugin/blob/e9af1cdd2549d528deb20a4ab8d61c5fbe51f306/args.go#L172
|
// https://github.com/shadowsocks/v2ray-plugin/blob/e9af1cdd2549d528deb20a4ab8d61c5fbe51f306/args.go#L172
|
||||||
// Equal signs and commas [and backslashes] must be escaped with a backslash.
|
// Equal signs and commas [and backslashes] must be escaped with a backslash.
|
||||||
var path = _node.Path.Replace("\\", "\\\\").Replace("=", "\\=").Replace(",", "\\,");
|
var path = (transportExtra.Path ?? string.Empty).Replace("\\", "\\\\").Replace("=", "\\=").Replace(",", "\\,");
|
||||||
pluginArgs += $"path={path};";
|
pluginArgs += $"path={path};";
|
||||||
}
|
}
|
||||||
else if (_node.Network == nameof(ETransport.quic))
|
|
||||||
{
|
|
||||||
pluginArgs += "mode=quic;";
|
|
||||||
}
|
|
||||||
if (_node.StreamSecurity == Global.StreamSecurity)
|
if (_node.StreamSecurity == Global.StreamSecurity)
|
||||||
{
|
{
|
||||||
pluginArgs += "tls;";
|
pluginArgs += "tls;";
|
||||||
|
|
@ -381,9 +379,18 @@ public partial class CoreConfigSingboxService
|
||||||
{
|
{
|
||||||
serverName = _node.Sni;
|
serverName = _node.Sni;
|
||||||
}
|
}
|
||||||
else if (_node.RequestHost.IsNotEmpty())
|
else
|
||||||
{
|
{
|
||||||
serverName = Utils.String2List(_node.RequestHost)?.First();
|
var host = _node.GetNetwork() switch
|
||||||
|
{
|
||||||
|
nameof(ETransport.raw) => _node.GetTransportExtra().Host,
|
||||||
|
nameof(ETransport.ws) => _node.GetTransportExtra().Host,
|
||||||
|
nameof(ETransport.httpupgrade) => _node.GetTransportExtra().Host,
|
||||||
|
nameof(ETransport.xhttp) => _node.GetTransportExtra().Host,
|
||||||
|
nameof(ETransport.grpc) => _node.GetTransportExtra().GrpcAuthority,
|
||||||
|
_ => null,
|
||||||
|
};
|
||||||
|
serverName = Utils.String2List(host)?.First();
|
||||||
}
|
}
|
||||||
var tls = new Tls4Sbox()
|
var tls = new Tls4Sbox()
|
||||||
{
|
{
|
||||||
|
|
@ -438,23 +445,20 @@ public partial class CoreConfigSingboxService
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var transport = new Transport4Sbox();
|
var transport = new Transport4Sbox();
|
||||||
|
var transportExtra = _node.GetTransportExtra();
|
||||||
var useragent = _config.CoreBasicItem.DefUserAgent ?? string.Empty;
|
var useragent = _config.CoreBasicItem.DefUserAgent ?? string.Empty;
|
||||||
var useragentValue = Global.TcpHttpUserAgentTexts.GetValueOrDefault(useragent, useragent);
|
var useragentValue = Global.RawHttpUserAgentTexts.GetValueOrDefault(useragent, useragent);
|
||||||
|
|
||||||
switch (_node.GetNetwork())
|
switch (_node.GetNetwork())
|
||||||
{
|
{
|
||||||
case nameof(ETransport.h2):
|
case nameof(ETransport.raw): //http
|
||||||
transport.type = nameof(ETransport.http);
|
if (transportExtra.RawHeaderType == Global.RawHeaderHttp)
|
||||||
transport.host = _node.RequestHost.IsNullOrEmpty() ? null : Utils.String2List(_node.RequestHost);
|
|
||||||
transport.path = _node.Path.NullIfEmpty();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case nameof(ETransport.tcp): //http
|
|
||||||
if (_node.HeaderType == Global.TcpHeaderHttp)
|
|
||||||
{
|
{
|
||||||
transport.type = nameof(ETransport.http);
|
transport.type = nameof(ETransport.http);
|
||||||
transport.host = _node.RequestHost.IsNullOrEmpty() ? null : Utils.String2List(_node.RequestHost);
|
transport.host = transportExtra.Host.IsNullOrEmpty()
|
||||||
transport.path = _node.Path.NullIfEmpty();
|
? null
|
||||||
|
: Utils.String2List(transportExtra.Host);
|
||||||
|
transport.path = transportExtra.Path.NullIfEmpty();
|
||||||
if (!useragentValue.IsNullOrEmpty())
|
if (!useragentValue.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
transport.headers ??= new();
|
transport.headers ??= new();
|
||||||
|
|
@ -465,7 +469,7 @@ public partial class CoreConfigSingboxService
|
||||||
|
|
||||||
case nameof(ETransport.ws):
|
case nameof(ETransport.ws):
|
||||||
transport.type = nameof(ETransport.ws);
|
transport.type = nameof(ETransport.ws);
|
||||||
var wsPath = _node.Path;
|
var wsPath = transportExtra.Path;
|
||||||
|
|
||||||
// Parse eh and ed parameters from path using regex
|
// Parse eh and ed parameters from path using regex
|
||||||
if (!wsPath.IsNullOrEmpty())
|
if (!wsPath.IsNullOrEmpty())
|
||||||
|
|
@ -494,11 +498,11 @@ public partial class CoreConfigSingboxService
|
||||||
}
|
}
|
||||||
|
|
||||||
transport.path = wsPath.NullIfEmpty();
|
transport.path = wsPath.NullIfEmpty();
|
||||||
if (_node.RequestHost.IsNotEmpty())
|
if (transportExtra.Host.IsNotEmpty())
|
||||||
{
|
{
|
||||||
transport.headers = new()
|
transport.headers = new()
|
||||||
{
|
{
|
||||||
Host = _node.RequestHost
|
Host = transportExtra.Host
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (!useragentValue.IsNullOrEmpty())
|
if (!useragentValue.IsNullOrEmpty())
|
||||||
|
|
@ -510,8 +514,8 @@ public partial class CoreConfigSingboxService
|
||||||
|
|
||||||
case nameof(ETransport.httpupgrade):
|
case nameof(ETransport.httpupgrade):
|
||||||
transport.type = nameof(ETransport.httpupgrade);
|
transport.type = nameof(ETransport.httpupgrade);
|
||||||
transport.path = _node.Path.NullIfEmpty();
|
transport.path = transportExtra.Path.NullIfEmpty();
|
||||||
transport.host = _node.RequestHost.NullIfEmpty();
|
transport.host = transportExtra.Host.NullIfEmpty();
|
||||||
if (!useragentValue.IsNullOrEmpty())
|
if (!useragentValue.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
transport.headers ??= new();
|
transport.headers ??= new();
|
||||||
|
|
@ -520,13 +524,9 @@ public partial class CoreConfigSingboxService
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.quic):
|
|
||||||
transport.type = nameof(ETransport.quic);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case nameof(ETransport.grpc):
|
case nameof(ETransport.grpc):
|
||||||
transport.type = nameof(ETransport.grpc);
|
transport.type = nameof(ETransport.grpc);
|
||||||
transport.service_name = _node.Path;
|
transport.service_name = transportExtra.GrpcServiceName;
|
||||||
transport.idle_timeout = _config.GrpcItem.IdleTimeout?.ToString("##s");
|
transport.idle_timeout = _config.GrpcItem.IdleTimeout?.ToString("##s");
|
||||||
transport.ping_timeout = _config.GrpcItem.HealthCheckTimeout?.ToString("##s");
|
transport.ping_timeout = _config.GrpcItem.HealthCheckTimeout?.ToString("##s");
|
||||||
transport.permit_without_stream = _config.GrpcItem.PermitWithoutStream;
|
transport.permit_without_stream = _config.GrpcItem.PermitWithoutStream;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public partial class CoreConfigSingboxService
|
||||||
strategy = directDnsStrategy
|
strategy = directDnsStrategy
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_config.TunModeItem.EnableTun)
|
if (context.IsTunEnabled)
|
||||||
{
|
{
|
||||||
_coreConfig.route.auto_detect_interface = true;
|
_coreConfig.route.auto_detect_interface = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,6 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
||||||
var ret = new RetResult();
|
var ret = new RetResult();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!context.AppConfig.TunModeItem.EnableLegacyProtect
|
|
||||||
&& context.IsTunEnabled
|
|
||||||
&& context.TunProtectSocksPort is > 0 and <= 65535
|
|
||||||
&& context.ProxyRelaySocksPort is > 0 and <= 65535)
|
|
||||||
{
|
|
||||||
return GenerateClientProxyRelayConfig();
|
|
||||||
}
|
|
||||||
if (_node == null
|
if (_node == null
|
||||||
|| !_node.IsValid())
|
|| !_node.IsValid())
|
||||||
{
|
{
|
||||||
|
|
@ -62,6 +55,11 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
||||||
GenDns();
|
GenDns();
|
||||||
|
|
||||||
GenStatistic();
|
GenStatistic();
|
||||||
|
|
||||||
|
if (_config.CoreBasicItem.EnableFragment)
|
||||||
|
{
|
||||||
|
ApplyOutboundFragment();
|
||||||
|
}
|
||||||
ApplyOutboundSendThrough();
|
ApplyOutboundSendThrough();
|
||||||
|
|
||||||
var finalRule = BuildFinalRule();
|
var finalRule = BuildFinalRule();
|
||||||
|
|
@ -196,6 +194,10 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
||||||
_coreConfig.routing.rules.Add(rule);
|
_coreConfig.routing.rules.Add(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_config.CoreBasicItem.EnableFragment)
|
||||||
|
{
|
||||||
|
ApplyOutboundFragment();
|
||||||
|
}
|
||||||
ApplyOutboundSendThrough();
|
ApplyOutboundSendThrough();
|
||||||
//ret.Msg =string.Format(ResUI.SuccessfulConfiguration"), node.getSummary());
|
//ret.Msg =string.Format(ResUI.SuccessfulConfiguration"), node.getSummary());
|
||||||
ret.Success = true;
|
ret.Success = true;
|
||||||
|
|
@ -257,6 +259,11 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
||||||
});
|
});
|
||||||
|
|
||||||
_coreConfig.routing.rules.Add(BuildFinalRule());
|
_coreConfig.routing.rules.Add(BuildFinalRule());
|
||||||
|
|
||||||
|
if (_config.CoreBasicItem.EnableFragment)
|
||||||
|
{
|
||||||
|
ApplyOutboundFragment();
|
||||||
|
}
|
||||||
ApplyOutboundSendThrough();
|
ApplyOutboundSendThrough();
|
||||||
|
|
||||||
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
||||||
|
|
@ -272,139 +279,5 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RetResult GenerateClientProxyRelayConfig()
|
|
||||||
{
|
|
||||||
var ret = new RetResult();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_node == null
|
|
||||||
|| !_node.IsValid())
|
|
||||||
{
|
|
||||||
ret.Msg = ResUI.CheckServerSettings;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_node.GetNetwork() is nameof(ETransport.quic))
|
|
||||||
{
|
|
||||||
ret.Msg = ResUI.Incorrectconfiguration + $" - {_node.GetNetwork()}";
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = EmbedUtils.GetEmbedText(Global.V2raySampleClient);
|
|
||||||
if (result.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
_coreConfig = JsonUtils.Deserialize<V2rayConfig>(result);
|
|
||||||
if (_coreConfig == null)
|
|
||||||
{
|
|
||||||
ret.Msg = ResUI.FailedGenDefaultConfiguration;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
GenLog();
|
|
||||||
_coreConfig.outbounds.Clear();
|
|
||||||
GenOutbounds();
|
|
||||||
GenStatistic();
|
|
||||||
|
|
||||||
var protectNode = new ProfileItem()
|
|
||||||
{
|
|
||||||
CoreType = ECoreType.Xray,
|
|
||||||
ConfigType = EConfigType.SOCKS,
|
|
||||||
Address = Global.Loopback,
|
|
||||||
Port = context.TunProtectSocksPort,
|
|
||||||
};
|
|
||||||
protectNode.SetProtocolExtra(protectNode.GetProtocolExtra() with
|
|
||||||
{
|
|
||||||
SsMethod = Global.None,
|
|
||||||
});
|
|
||||||
|
|
||||||
const string protectTag = "tun-protect-socks";
|
|
||||||
foreach (var outbound in _coreConfig.outbounds
|
|
||||||
.Where(o => o.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true))
|
|
||||||
{
|
|
||||||
outbound.streamSettings ??= new();
|
|
||||||
outbound.streamSettings.sockopt ??= new();
|
|
||||||
outbound.streamSettings.sockopt.dialerProxy = protectTag;
|
|
||||||
}
|
|
||||||
// ech protected
|
|
||||||
foreach (var outbound in _coreConfig.outbounds
|
|
||||||
.Where(outbound => outbound.streamSettings?.tlsSettings?.echConfigList?.IsNullOrEmpty() == false))
|
|
||||||
{
|
|
||||||
outbound.streamSettings!.tlsSettings!.echSockopt ??= new();
|
|
||||||
outbound.streamSettings.tlsSettings.echSockopt.dialerProxy = protectTag;
|
|
||||||
}
|
|
||||||
// xhttp download protected
|
|
||||||
foreach (var outbound in _coreConfig.outbounds
|
|
||||||
.Where(o => o.streamSettings?.xhttpSettings?.extra is not null))
|
|
||||||
{
|
|
||||||
var xhttpExtra = JsonUtils.ParseJson(JsonUtils.Serialize(outbound.streamSettings.xhttpSettings!.extra));
|
|
||||||
if (xhttpExtra is not JsonObject xhttpExtraObject
|
|
||||||
|| xhttpExtraObject["downloadSettings"] is not JsonObject downloadSettings)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// dialerProxy
|
|
||||||
var sockopt = downloadSettings["sockopt"] as JsonObject ?? new JsonObject();
|
|
||||||
sockopt["dialerProxy"] = protectTag;
|
|
||||||
downloadSettings["sockopt"] = sockopt;
|
|
||||||
// ech protected
|
|
||||||
if (downloadSettings["tlsSettings"] is JsonObject tlsSettings
|
|
||||||
&& tlsSettings["echConfigList"] is not null)
|
|
||||||
{
|
|
||||||
tlsSettings["echSockopt"] = new JsonObject
|
|
||||||
{
|
|
||||||
["dialerProxy"] = protectTag
|
|
||||||
};
|
|
||||||
}
|
|
||||||
outbound.streamSettings.xhttpSettings.extra = xhttpExtraObject;
|
|
||||||
}
|
|
||||||
_coreConfig.outbounds.Add(new CoreConfigV2rayService(context with
|
|
||||||
{
|
|
||||||
Node = protectNode,
|
|
||||||
}).BuildProxyOutbound(protectTag));
|
|
||||||
|
|
||||||
_coreConfig.routing.rules ??= [];
|
|
||||||
var hasBalancer = _coreConfig.routing.balancers is { Count: > 0 };
|
|
||||||
_coreConfig.routing.rules.Add(new()
|
|
||||||
{
|
|
||||||
inboundTag = ["proxy-relay-socks"],
|
|
||||||
outboundTag = hasBalancer ? null : Global.ProxyTag,
|
|
||||||
balancerTag = hasBalancer ? Global.ProxyTag + Global.BalancerTagSuffix : null,
|
|
||||||
type = "field"
|
|
||||||
});
|
|
||||||
|
|
||||||
//_coreConfig.inbounds.Clear();
|
|
||||||
|
|
||||||
ApplyOutboundSendThrough();
|
|
||||||
var configNode = JsonUtils.ParseJson(JsonUtils.Serialize(_coreConfig))!;
|
|
||||||
configNode["inbounds"]!.AsArray().Add(new
|
|
||||||
{
|
|
||||||
listen = Global.Loopback,
|
|
||||||
port = context.ProxyRelaySocksPort,
|
|
||||||
protocol = "socks",
|
|
||||||
settings = new
|
|
||||||
{
|
|
||||||
auth = "noauth",
|
|
||||||
udp = true,
|
|
||||||
},
|
|
||||||
tag = "proxy-relay-socks",
|
|
||||||
});
|
|
||||||
|
|
||||||
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
|
||||||
ret.Success = true;
|
|
||||||
ret.Data = JsonUtils.Serialize(configNode);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logging.SaveLog(_tag, ex);
|
|
||||||
ret.Msg = ResUI.FailedGenDefaultConfiguration;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion public gen function
|
#endregion public gen function
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,18 @@ public partial class CoreConfigV2rayService
|
||||||
private string ApplyFullConfigTemplate()
|
private string ApplyFullConfigTemplate()
|
||||||
{
|
{
|
||||||
var fullConfigTemplate = context.FullConfigTemplate;
|
var fullConfigTemplate = context.FullConfigTemplate;
|
||||||
if (fullConfigTemplate == null || !fullConfigTemplate.Enabled || fullConfigTemplate.Config.IsNullOrEmpty())
|
if (fullConfigTemplate is not { Enabled: true })
|
||||||
{
|
{
|
||||||
return JsonUtils.Serialize(_coreConfig);
|
return JsonUtils.Serialize(_coreConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fullConfigTemplateNode = JsonNode.Parse(fullConfigTemplate.Config);
|
var fullConfigTemplateItem = context.IsTunEnabled ? fullConfigTemplate.TunConfig : fullConfigTemplate.Config;
|
||||||
|
if (fullConfigTemplateItem.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
return JsonUtils.Serialize(_coreConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
var fullConfigTemplateNode = JsonNode.Parse(fullConfigTemplateItem);
|
||||||
if (fullConfigTemplateNode == null)
|
if (fullConfigTemplateNode == null)
|
||||||
{
|
{
|
||||||
return JsonUtils.Serialize(_coreConfig);
|
return JsonUtils.Serialize(_coreConfig);
|
||||||
|
|
|
||||||
|
|
@ -370,11 +370,11 @@ public partial class CoreConfigV2rayService
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var item = context.RawDnsItem;
|
var item = context.RawDnsItem;
|
||||||
var normalDNS = item?.NormalDNS;
|
var customDNS = context.IsTunEnabled ? item?.TunDNS : item?.NormalDNS;
|
||||||
var domainStrategy4Freedom = item?.DomainStrategy4Freedom;
|
var domainStrategy4Freedom = item?.DomainStrategy4Freedom;
|
||||||
if (normalDNS.IsNullOrEmpty())
|
if (customDNS.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
normalDNS = EmbedUtils.GetEmbedText(Global.DNSV2rayNormalFileName);
|
customDNS = EmbedUtils.GetEmbedText(Global.DNSV2rayNormalFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Outbound Freedom domainStrategy
|
//Outbound Freedom domainStrategy
|
||||||
|
|
@ -389,11 +389,11 @@ public partial class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var obj = JsonUtils.ParseJson(normalDNS);
|
var obj = JsonUtils.ParseJson(customDNS);
|
||||||
if (obj is null)
|
if (obj is null)
|
||||||
{
|
{
|
||||||
List<string> servers = [];
|
List<string> servers = [];
|
||||||
var arrDNS = normalDNS.Split(',');
|
var arrDNS = customDNS.Split(',');
|
||||||
foreach (var str in arrDNS)
|
foreach (var str in arrDNS)
|
||||||
{
|
{
|
||||||
servers.Add(str);
|
servers.Add(str);
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,13 @@ public partial class CoreConfigV2rayService
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var listen = "0.0.0.0";
|
var listen = "0.0.0.0";
|
||||||
|
var listenPort = AppManager.Instance.GetLocalPort(EInboundProtocol.socks);
|
||||||
_coreConfig.inbounds = [];
|
_coreConfig.inbounds = [];
|
||||||
|
|
||||||
var inbound = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks, true);
|
var inbound = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks, true);
|
||||||
|
|
||||||
|
if (!context.IsTunEnabled
|
||||||
|
|| (context.IsTunEnabled && _node.Address != Global.Loopback && _node.Port != listenPort))
|
||||||
|
{
|
||||||
_coreConfig.inbounds.Add(inbound);
|
_coreConfig.inbounds.Add(inbound);
|
||||||
|
|
||||||
if (_config.Inbound.First().SecondLocalPortEnabled)
|
if (_config.Inbound.First().SecondLocalPortEnabled)
|
||||||
|
|
@ -30,7 +34,10 @@ public partial class CoreConfigV2rayService
|
||||||
if (_config.Inbound.First().User.IsNotEmpty() && _config.Inbound.First().Pass.IsNotEmpty())
|
if (_config.Inbound.First().User.IsNotEmpty() && _config.Inbound.First().Pass.IsNotEmpty())
|
||||||
{
|
{
|
||||||
inbound3.settings.auth = "password";
|
inbound3.settings.auth = "password";
|
||||||
inbound3.settings.accounts = new List<AccountsItem4Ray> { new() { user = _config.Inbound.First().User, pass = _config.Inbound.First().Pass } };
|
inbound3.settings.accounts = new List<AccountsItem4Ray>
|
||||||
|
{
|
||||||
|
new() { user = _config.Inbound.First().User, pass = _config.Inbound.First().Pass }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -39,6 +46,24 @@ public partial class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context.IsTunEnabled)
|
||||||
|
{
|
||||||
|
if (_config.TunModeItem.Mtu <= 0)
|
||||||
|
{
|
||||||
|
_config.TunModeItem.Mtu = Global.TunMtus.First();
|
||||||
|
}
|
||||||
|
var tunInbound = JsonUtils.Deserialize<Inbounds4Ray>(EmbedUtils.GetEmbedText(Global.V2raySampleTunInbound)) ?? new Inbounds4Ray { };
|
||||||
|
tunInbound.settings.name = Utils.IsMacOS() ? $"utun{new Random().Next(99)}" : "xray_tun";
|
||||||
|
tunInbound.settings.MTU = _config.TunModeItem.Mtu;
|
||||||
|
if (_config.TunModeItem.EnableIPv6Address == false)
|
||||||
|
{
|
||||||
|
tunInbound.settings.gateway = ["172.18.0.1/30"];
|
||||||
|
}
|
||||||
|
tunInbound.sniffing = inbound.sniffing;
|
||||||
|
_coreConfig.inbounds.Add(tunInbound);
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logging.SaveLog(_tag, ex);
|
Logging.SaveLog(_tag, ex);
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,10 @@ public partial class CoreConfigV2rayService
|
||||||
GenObservatory(multipleLoad);
|
GenObservatory(multipleLoad);
|
||||||
GenBalancer(multipleLoad);
|
GenBalancer(multipleLoad);
|
||||||
}
|
}
|
||||||
|
if (context.IsTunEnabled)
|
||||||
|
{
|
||||||
|
_coreConfig.outbounds.Add(BuildDnsOutbound());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Outbounds4Ray> BuildAllProxyOutbounds(string baseTagName = Global.ProxyTag)
|
private List<Outbounds4Ray> BuildAllProxyOutbounds(string baseTagName = Global.ProxyTag)
|
||||||
|
|
@ -25,35 +29,6 @@ public partial class CoreConfigV2rayService
|
||||||
{
|
{
|
||||||
proxyOutboundList.Add(BuildProxyOutbound(baseTagName));
|
proxyOutboundList.Add(BuildProxyOutbound(baseTagName));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_config.CoreBasicItem.EnableFragment)
|
|
||||||
{
|
|
||||||
var fragmentOutbound = new Outbounds4Ray
|
|
||||||
{
|
|
||||||
protocol = "freedom",
|
|
||||||
tag = $"frag-{baseTagName}",
|
|
||||||
settings = new()
|
|
||||||
{
|
|
||||||
fragment = new()
|
|
||||||
{
|
|
||||||
packets = _config.Fragment4RayItem?.Packets,
|
|
||||||
length = _config.Fragment4RayItem?.Length,
|
|
||||||
interval = _config.Fragment4RayItem?.Interval
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var actOutboundWithTlsList =
|
|
||||||
proxyOutboundList.Where(n => n.streamSettings?.security.IsNullOrEmpty() == false
|
|
||||||
&& (n.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true)).ToList();
|
|
||||||
if (actOutboundWithTlsList.Count > 0)
|
|
||||||
{
|
|
||||||
proxyOutboundList.Add(fragmentOutbound);
|
|
||||||
}
|
|
||||||
foreach (var outbound in actOutboundWithTlsList)
|
|
||||||
{
|
|
||||||
FillDialerProxy(outbound, fragmentOutbound.tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return proxyOutboundList;
|
return proxyOutboundList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -349,8 +324,49 @@ public partial class CoreConfigV2rayService
|
||||||
network = "hysteria";
|
network = "hysteria";
|
||||||
}
|
}
|
||||||
streamSettings.network = network;
|
streamSettings.network = network;
|
||||||
var host = _node.RequestHost.TrimEx();
|
var transport = _node.GetTransportExtra();
|
||||||
var path = _node.Path.TrimEx();
|
var host = string.Empty;
|
||||||
|
var path = string.Empty;
|
||||||
|
var kcpSeed = string.Empty;
|
||||||
|
var headerType = string.Empty;
|
||||||
|
var xhttpExtra = string.Empty;
|
||||||
|
switch (network)
|
||||||
|
{
|
||||||
|
case nameof(ETransport.raw):
|
||||||
|
host = transport.Host?.TrimEx() ?? string.Empty;
|
||||||
|
path = transport.Path?.TrimEx() ?? string.Empty;
|
||||||
|
headerType = transport.RawHeaderType?.TrimEx() ?? string.Empty;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.kcp):
|
||||||
|
kcpSeed = transport.KcpSeed?.TrimEx() ?? string.Empty;
|
||||||
|
headerType = transport.KcpHeaderType?.TrimEx() ?? string.Empty;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.ws):
|
||||||
|
host = transport.Host?.TrimEx() ?? string.Empty;
|
||||||
|
path = transport.Path?.TrimEx() ?? string.Empty;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.httpupgrade):
|
||||||
|
host = transport.Host?.TrimEx() ?? string.Empty;
|
||||||
|
path = transport.Path?.TrimEx() ?? string.Empty;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.xhttp):
|
||||||
|
host = transport.Host?.TrimEx() ?? string.Empty;
|
||||||
|
path = transport.Path?.TrimEx() ?? string.Empty;
|
||||||
|
headerType = transport.XhttpMode?.TrimEx() ?? string.Empty;
|
||||||
|
xhttpExtra = transport.XhttpExtra?.TrimEx() ?? string.Empty;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.grpc):
|
||||||
|
host = transport.GrpcAuthority?.TrimEx() ?? string.Empty;
|
||||||
|
path = transport.GrpcServiceName?.TrimEx() ?? string.Empty;
|
||||||
|
headerType = transport.GrpcMode?.TrimEx() ?? string.Empty;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
var sni = _node.Sni.TrimEx();
|
var sni = _node.Sni.TrimEx();
|
||||||
var useragent = _config.CoreBasicItem.DefUserAgent ?? string.Empty;
|
var useragent = _config.CoreBasicItem.DefUserAgent ?? string.Empty;
|
||||||
|
|
||||||
|
|
@ -432,23 +448,22 @@ public partial class CoreConfigV2rayService
|
||||||
kcpSettings.uplinkCapacity = _config.KcpItem.UplinkCapacity;
|
kcpSettings.uplinkCapacity = _config.KcpItem.UplinkCapacity;
|
||||||
kcpSettings.downlinkCapacity = _config.KcpItem.DownlinkCapacity;
|
kcpSettings.downlinkCapacity = _config.KcpItem.DownlinkCapacity;
|
||||||
|
|
||||||
kcpSettings.congestion = _config.KcpItem.Congestion;
|
kcpSettings.cwndMultiplier = _config.KcpItem.CwndMultiplier;
|
||||||
kcpSettings.readBufferSize = _config.KcpItem.ReadBufferSize;
|
kcpSettings.maxSendingWindow = _config.KcpItem.MaxSendingWindow;
|
||||||
kcpSettings.writeBufferSize = _config.KcpItem.WriteBufferSize;
|
|
||||||
var kcpFinalmask = new Finalmask4Ray();
|
var kcpFinalmask = new Finalmask4Ray();
|
||||||
if (Global.KcpHeaderMaskMap.TryGetValue(_node.HeaderType, out var header))
|
if (Global.KcpHeaderMaskMap.TryGetValue(headerType, out var header))
|
||||||
{
|
{
|
||||||
kcpFinalmask.udp =
|
kcpFinalmask.udp =
|
||||||
[
|
[
|
||||||
new Mask4Ray
|
new Mask4Ray
|
||||||
{
|
{
|
||||||
type = header,
|
type = header,
|
||||||
settings = _node.HeaderType == "dns" && !host.IsNullOrEmpty() ? new MaskSettings4Ray { domain = host } : null
|
settings = null
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
kcpFinalmask.udp ??= [];
|
kcpFinalmask.udp ??= [];
|
||||||
if (path.IsNullOrEmpty())
|
if (kcpSeed.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
kcpFinalmask.udp.Add(new Mask4Ray
|
kcpFinalmask.udp.Add(new Mask4Ray
|
||||||
{
|
{
|
||||||
|
|
@ -460,7 +475,7 @@ public partial class CoreConfigV2rayService
|
||||||
kcpFinalmask.udp.Add(new Mask4Ray
|
kcpFinalmask.udp.Add(new Mask4Ray
|
||||||
{
|
{
|
||||||
type = "mkcp-aes128gcm",
|
type = "mkcp-aes128gcm",
|
||||||
settings = new MaskSettings4Ray { password = path }
|
settings = new MaskSettings4Ray { password = kcpSeed }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
streamSettings.kcpSettings = kcpSettings;
|
streamSettings.kcpSettings = kcpSettings;
|
||||||
|
|
@ -518,63 +533,25 @@ public partial class CoreConfigV2rayService
|
||||||
{
|
{
|
||||||
xhttpSettings.host = host;
|
xhttpSettings.host = host;
|
||||||
}
|
}
|
||||||
if (_node.HeaderType.IsNotEmpty() && Global.XhttpMode.Contains(_node.HeaderType))
|
if (headerType.IsNotEmpty() && Global.XhttpMode.Contains(headerType))
|
||||||
{
|
{
|
||||||
xhttpSettings.mode = _node.HeaderType;
|
xhttpSettings.mode = headerType;
|
||||||
}
|
}
|
||||||
if (_node.Extra.IsNotEmpty())
|
if (xhttpExtra.IsNotEmpty())
|
||||||
{
|
{
|
||||||
xhttpSettings.extra = JsonUtils.ParseJson(_node.Extra);
|
xhttpSettings.extra = JsonUtils.ParseJson(xhttpExtra);
|
||||||
}
|
}
|
||||||
|
|
||||||
streamSettings.xhttpSettings = xhttpSettings;
|
streamSettings.xhttpSettings = xhttpSettings;
|
||||||
FillOutboundMux(outbound);
|
FillOutboundMux(outbound);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
//h2
|
|
||||||
case nameof(ETransport.h2):
|
|
||||||
HttpSettings4Ray httpSettings = new();
|
|
||||||
|
|
||||||
if (host.IsNotEmpty())
|
|
||||||
{
|
|
||||||
httpSettings.host = Utils.String2List(host);
|
|
||||||
}
|
|
||||||
httpSettings.path = path;
|
|
||||||
|
|
||||||
streamSettings.httpSettings = httpSettings;
|
|
||||||
|
|
||||||
break;
|
|
||||||
//quic
|
|
||||||
case nameof(ETransport.quic):
|
|
||||||
QuicSettings4Ray quicsettings = new()
|
|
||||||
{
|
|
||||||
security = host,
|
|
||||||
key = path,
|
|
||||||
header = new Header4Ray
|
|
||||||
{
|
|
||||||
type = _node.HeaderType
|
|
||||||
}
|
|
||||||
};
|
|
||||||
streamSettings.quicSettings = quicsettings;
|
|
||||||
if (_node.StreamSecurity == Global.StreamSecurity)
|
|
||||||
{
|
|
||||||
if (sni.IsNotEmpty())
|
|
||||||
{
|
|
||||||
streamSettings.tlsSettings.serverName = sni;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
streamSettings.tlsSettings.serverName = _node.Address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case nameof(ETransport.grpc):
|
case nameof(ETransport.grpc):
|
||||||
GrpcSettings4Ray grpcSettings = new()
|
GrpcSettings4Ray grpcSettings = new()
|
||||||
{
|
{
|
||||||
authority = host.NullIfEmpty(),
|
authority = host.NullIfEmpty(),
|
||||||
serviceName = path,
|
serviceName = path,
|
||||||
multiMode = _node.HeaderType == Global.GrpcMultiMode,
|
multiMode = headerType == Global.GrpcMultiMode,
|
||||||
idle_timeout = _config.GrpcItem.IdleTimeout,
|
idle_timeout = _config.GrpcItem.IdleTimeout,
|
||||||
health_check_timeout = _config.GrpcItem.HealthCheckTimeout,
|
health_check_timeout = _config.GrpcItem.HealthCheckTimeout,
|
||||||
permit_without_stream = _config.GrpcItem.PermitWithoutStream,
|
permit_without_stream = _config.GrpcItem.PermitWithoutStream,
|
||||||
|
|
@ -641,20 +618,20 @@ public partial class CoreConfigV2rayService
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
//tcp
|
// raw
|
||||||
if (_node.HeaderType == Global.TcpHeaderHttp)
|
if (headerType == Global.RawHeaderHttp)
|
||||||
{
|
{
|
||||||
TcpSettings4Ray tcpSettings = new()
|
RawSettings4Ray rawSettings = new()
|
||||||
{
|
{
|
||||||
header = new Header4Ray
|
header = new Header4Ray
|
||||||
{
|
{
|
||||||
type = _node.HeaderType
|
type = headerType
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//request Host
|
//request Host
|
||||||
var request = EmbedUtils.GetEmbedText(Global.V2raySampleHttpRequestFileName);
|
var request = EmbedUtils.GetEmbedText(Global.V2raySampleHttpRequestFileName);
|
||||||
var useragentValue = Global.TcpHttpUserAgentTexts.GetValueOrDefault(useragent, useragent);
|
var useragentValue = Global.RawHttpUserAgentTexts.GetValueOrDefault(useragent, useragent);
|
||||||
var arrHost = host.Split(',');
|
var arrHost = host.Split(',');
|
||||||
var host2 = string.Join(",".AppendQuotes(), arrHost);
|
var host2 = string.Join(",".AppendQuotes(), arrHost);
|
||||||
request = request.Replace("$requestHost$", $"{host2.AppendQuotes()}");
|
request = request.Replace("$requestHost$", $"{host2.AppendQuotes()}");
|
||||||
|
|
@ -667,9 +644,9 @@ public partial class CoreConfigV2rayService
|
||||||
pathHttp = string.Join(",".AppendQuotes(), arrPath);
|
pathHttp = string.Join(",".AppendQuotes(), arrPath);
|
||||||
}
|
}
|
||||||
request = request.Replace("$requestPath$", $"{pathHttp.AppendQuotes()}");
|
request = request.Replace("$requestPath$", $"{pathHttp.AppendQuotes()}");
|
||||||
tcpSettings.header.request = JsonUtils.Deserialize<object>(request);
|
rawSettings.header.request = JsonUtils.Deserialize<object>(request);
|
||||||
|
|
||||||
streamSettings.tcpSettings = tcpSettings;
|
streamSettings.rawSettings = rawSettings;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -825,4 +802,74 @@ public partial class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Outbounds4Ray BuildDnsOutbound()
|
||||||
|
{
|
||||||
|
var outbound = new Outbounds4Ray { tag = Global.DnsOutboundTag, protocol = "dns", };
|
||||||
|
return outbound;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ApplyOutboundFragment()
|
||||||
|
{
|
||||||
|
var actOutboundWithTlsList =
|
||||||
|
_coreConfig.outbounds.Where(n => n.streamSettings?.security.IsNullOrEmpty() == false
|
||||||
|
&& (n.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var configPackets = _config.Fragment4RayItem?.Packets ?? "tlshello";
|
||||||
|
var configLength = _config.Fragment4RayItem?.Length ?? "50-100";
|
||||||
|
var configDelay = _config.Fragment4RayItem?.Interval ?? "10-20";
|
||||||
|
|
||||||
|
var fragmentMask = new Mask4Ray
|
||||||
|
{
|
||||||
|
type = "fragment",
|
||||||
|
settings = new MaskSettings4Ray
|
||||||
|
{
|
||||||
|
packets = configPackets,
|
||||||
|
length = configLength,
|
||||||
|
delay = configDelay,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var noiseMask = new Mask4Ray
|
||||||
|
{
|
||||||
|
type = "noise",
|
||||||
|
settings = new MaskSettings4Ray
|
||||||
|
{
|
||||||
|
length = "10-20",
|
||||||
|
delay = "10-16",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var outbound in actOutboundWithTlsList)
|
||||||
|
{
|
||||||
|
//var packets = configPackets;
|
||||||
|
//if (outbound.streamSettings.security == Global.StreamSecurityReality
|
||||||
|
// && packets == "tlshello")
|
||||||
|
//{
|
||||||
|
// packets = "1-3";
|
||||||
|
//}
|
||||||
|
//else if (outbound.streamSettings.security == Global.StreamSecurity
|
||||||
|
// && packets != "tlshello")
|
||||||
|
//{
|
||||||
|
// packets = "tlshello";
|
||||||
|
//}
|
||||||
|
var finalMaskJsonObj = JsonUtils.ParseJson(JsonUtils.Serialize(outbound.streamSettings?.finalmask)) as JsonObject ?? new JsonObject();
|
||||||
|
// tcp fragment
|
||||||
|
var tcpFinalmaskList = finalMaskJsonObj["tcp"] as JsonArray ?? [];
|
||||||
|
if (tcpFinalmaskList.Count == 0)
|
||||||
|
{
|
||||||
|
tcpFinalmaskList.Add(JsonUtils.SerializeToNode(fragmentMask));
|
||||||
|
finalMaskJsonObj["tcp"] = tcpFinalmaskList;
|
||||||
|
}
|
||||||
|
// udp noise
|
||||||
|
var udpFinalmaskList = finalMaskJsonObj["udp"] as JsonArray ?? [];
|
||||||
|
if (udpFinalmaskList.Count == 0)
|
||||||
|
{
|
||||||
|
udpFinalmaskList.Add(JsonUtils.SerializeToNode(noiseMask));
|
||||||
|
finalMaskJsonObj["udp"] = udpFinalmaskList;
|
||||||
|
}
|
||||||
|
// write back
|
||||||
|
outbound.streamSettings.finalmask = finalMaskJsonObj;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,31 @@ public partial class CoreConfigV2rayService
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (context.IsTunEnabled)
|
||||||
|
{
|
||||||
|
var tunRules = JsonUtils.Deserialize<List<RulesItem4Ray>>(EmbedUtils.GetEmbedText(Global.V2raySampleTunRules));
|
||||||
|
if (tunRules != null)
|
||||||
|
{
|
||||||
|
_coreConfig.routing.rules.AddRange(tunRules);
|
||||||
|
}
|
||||||
|
var (lstDnsExe, lstDirectExe) = BuildRoutingDirectExe();
|
||||||
|
_coreConfig.routing.rules.Add(new()
|
||||||
|
{
|
||||||
|
port = "53",
|
||||||
|
process = lstDnsExe,
|
||||||
|
outboundTag = Global.DnsOutboundTag,
|
||||||
|
});
|
||||||
|
_coreConfig.routing.rules.Add(new()
|
||||||
|
{
|
||||||
|
process = lstDirectExe,
|
||||||
|
outboundTag = Global.DirectTag,
|
||||||
|
});
|
||||||
|
_coreConfig.routing.rules.Add(new()
|
||||||
|
{
|
||||||
|
port = "53",
|
||||||
|
outboundTag = Global.DnsOutboundTag,
|
||||||
|
});
|
||||||
|
}
|
||||||
if (_coreConfig.routing?.rules != null)
|
if (_coreConfig.routing?.rules != null)
|
||||||
{
|
{
|
||||||
_coreConfig.routing.domainStrategy = _config.RoutingBasicItem.DomainStrategy;
|
_coreConfig.routing.domainStrategy = _config.RoutingBasicItem.DomainStrategy;
|
||||||
|
|
@ -205,4 +230,37 @@ public partial class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
return finalRule;
|
return finalRule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static (List<string> lstDnsExe, List<string> lstDirectExe) BuildRoutingDirectExe()
|
||||||
|
{
|
||||||
|
var dnsExeSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
var directExeSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
var coreInfoResult = CoreInfoManager.Instance.GetCoreInfo();
|
||||||
|
|
||||||
|
foreach (var coreConfig in coreInfoResult)
|
||||||
|
{
|
||||||
|
if (coreConfig.CoreType == ECoreType.v2rayN)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var baseExeName in coreConfig.CoreExes)
|
||||||
|
{
|
||||||
|
if (coreConfig.CoreType != ECoreType.Xray)
|
||||||
|
{
|
||||||
|
dnsExeSet.Add(Utils.GetExeName(baseExeName));
|
||||||
|
}
|
||||||
|
directExeSet.Add(Utils.GetExeName(baseExeName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
directExeSet.Add("xray/");
|
||||||
|
directExeSet.Add("self/");
|
||||||
|
|
||||||
|
var lstDnsExe = new List<string>(dnsExeSet);
|
||||||
|
var lstDirectExe = new List<string>(directExeSet);
|
||||||
|
|
||||||
|
return (lstDnsExe, lstDirectExe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,9 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string CertSha { get; set; }
|
public string CertSha { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public bool AllowInsecureCertFetch { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string SalamanderPass { get; set; }
|
public string SalamanderPass { get; set; }
|
||||||
|
|
||||||
|
|
@ -73,6 +76,163 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public bool NaiveQuic { get; set; }
|
public bool NaiveQuic { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public string RawHeaderType { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public string Host { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public string Path { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public string XhttpMode { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public string XhttpExtra { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public string GrpcAuthority { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public string GrpcServiceName { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public string GrpcMode { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public string KcpHeaderType { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public string KcpSeed { get; set; }
|
||||||
|
|
||||||
|
public string TransportHeaderType
|
||||||
|
{
|
||||||
|
get => SelectedSource.GetNetwork() switch
|
||||||
|
{
|
||||||
|
nameof(ETransport.raw) => RawHeaderType,
|
||||||
|
nameof(ETransport.kcp) => KcpHeaderType,
|
||||||
|
nameof(ETransport.xhttp) => XhttpMode,
|
||||||
|
nameof(ETransport.grpc) => GrpcMode,
|
||||||
|
_ => string.Empty,
|
||||||
|
};
|
||||||
|
set
|
||||||
|
{
|
||||||
|
switch (SelectedSource.GetNetwork())
|
||||||
|
{
|
||||||
|
case nameof(ETransport.raw):
|
||||||
|
RawHeaderType = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.kcp):
|
||||||
|
KcpHeaderType = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.xhttp):
|
||||||
|
XhttpMode = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.grpc):
|
||||||
|
GrpcMode = value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.RaisePropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string TransportHost
|
||||||
|
{
|
||||||
|
get => SelectedSource.GetNetwork() switch
|
||||||
|
{
|
||||||
|
nameof(ETransport.raw) => Host,
|
||||||
|
nameof(ETransport.ws) => Host,
|
||||||
|
nameof(ETransport.httpupgrade) => Host,
|
||||||
|
nameof(ETransport.xhttp) => Host,
|
||||||
|
nameof(ETransport.grpc) => GrpcAuthority,
|
||||||
|
_ => string.Empty,
|
||||||
|
};
|
||||||
|
set
|
||||||
|
{
|
||||||
|
switch (SelectedSource.GetNetwork())
|
||||||
|
{
|
||||||
|
case nameof(ETransport.raw):
|
||||||
|
Host = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.ws):
|
||||||
|
Host = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.httpupgrade):
|
||||||
|
Host = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.xhttp):
|
||||||
|
Host = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.grpc):
|
||||||
|
GrpcAuthority = value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.RaisePropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string TransportPath
|
||||||
|
{
|
||||||
|
get => SelectedSource.GetNetwork() switch
|
||||||
|
{
|
||||||
|
nameof(ETransport.kcp) => KcpSeed,
|
||||||
|
nameof(ETransport.ws) => Path,
|
||||||
|
nameof(ETransport.httpupgrade) => Path,
|
||||||
|
nameof(ETransport.xhttp) => Path,
|
||||||
|
nameof(ETransport.grpc) => GrpcServiceName,
|
||||||
|
_ => string.Empty,
|
||||||
|
};
|
||||||
|
set
|
||||||
|
{
|
||||||
|
switch (SelectedSource.GetNetwork())
|
||||||
|
{
|
||||||
|
case nameof(ETransport.kcp):
|
||||||
|
KcpSeed = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.ws):
|
||||||
|
Path = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.httpupgrade):
|
||||||
|
Path = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.xhttp):
|
||||||
|
Path = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nameof(ETransport.grpc):
|
||||||
|
GrpcServiceName = value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.RaisePropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string TransportExtraText
|
||||||
|
{
|
||||||
|
get => SelectedSource.GetNetwork() == nameof(ETransport.xhttp)
|
||||||
|
? XhttpExtra
|
||||||
|
: string.Empty;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (SelectedSource.GetNetwork() == nameof(ETransport.xhttp))
|
||||||
|
{
|
||||||
|
XhttpExtra = value;
|
||||||
|
}
|
||||||
|
this.RaisePropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> FetchCertCmd { get; }
|
public ReactiveCommand<Unit, Unit> FetchCertCmd { get; }
|
||||||
public ReactiveCommand<Unit, Unit> FetchCertChainCmd { get; }
|
public ReactiveCommand<Unit, Unit> FetchCertChainCmd { get; }
|
||||||
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
||||||
|
|
@ -101,14 +261,21 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
this.WhenAnyValue(x => x.CertSha)
|
this.WhenAnyValue(x => x.CertSha)
|
||||||
.Subscribe(_ => UpdateCertTip());
|
.Subscribe(_ => UpdateCertTip());
|
||||||
|
|
||||||
|
this.WhenAnyValue(x => x.SelectedSource.Network)
|
||||||
|
.Subscribe(_ =>
|
||||||
|
{
|
||||||
|
this.RaisePropertyChanged(nameof(TransportHeaderType));
|
||||||
|
this.RaisePropertyChanged(nameof(TransportHost));
|
||||||
|
this.RaisePropertyChanged(nameof(TransportPath));
|
||||||
|
this.RaisePropertyChanged(nameof(TransportExtraText));
|
||||||
|
});
|
||||||
|
|
||||||
this.WhenAnyValue(x => x.Cert)
|
this.WhenAnyValue(x => x.Cert)
|
||||||
.Subscribe(_ => UpdateCertSha());
|
.Subscribe(_ => UpdateCertSha());
|
||||||
|
|
||||||
if (profileItem.IndexId.IsNullOrEmpty())
|
if (profileItem.IndexId.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
profileItem.Network = Global.DefaultNetwork;
|
profileItem.Network = Global.DefaultNetwork;
|
||||||
profileItem.HeaderType = Global.None;
|
|
||||||
profileItem.RequestHost = "";
|
|
||||||
profileItem.StreamSecurity = "";
|
profileItem.StreamSecurity = "";
|
||||||
SelectedSource = profileItem;
|
SelectedSource = profileItem;
|
||||||
}
|
}
|
||||||
|
|
@ -121,13 +288,14 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
CertSha = SelectedSource?.CertSha?.ToString() ?? string.Empty;
|
CertSha = SelectedSource?.CertSha?.ToString() ?? string.Empty;
|
||||||
|
|
||||||
var protocolExtra = SelectedSource?.GetProtocolExtra();
|
var protocolExtra = SelectedSource?.GetProtocolExtra();
|
||||||
|
var transport = SelectedSource?.GetTransportExtra();
|
||||||
Ports = protocolExtra?.Ports ?? string.Empty;
|
Ports = protocolExtra?.Ports ?? string.Empty;
|
||||||
AlterId = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0;
|
AlterId = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0;
|
||||||
Flow = protocolExtra?.Flow ?? string.Empty;
|
Flow = protocolExtra?.Flow ?? string.Empty;
|
||||||
SalamanderPass = protocolExtra?.SalamanderPass ?? string.Empty;
|
SalamanderPass = protocolExtra?.SalamanderPass ?? string.Empty;
|
||||||
UpMbps = protocolExtra?.UpMbps;
|
UpMbps = protocolExtra?.UpMbps;
|
||||||
DownMbps = protocolExtra?.DownMbps;
|
DownMbps = protocolExtra?.DownMbps;
|
||||||
HopInterval = protocolExtra?.HopInterval.IsNullOrEmpty() ?? true ? Global.Hysteria2DefaultHopInt.ToString() : protocolExtra.HopInterval;
|
HopInterval = protocolExtra?.HopInterval ?? string.Empty;
|
||||||
VmessSecurity = protocolExtra?.VmessSecurity?.IsNullOrEmpty() == false ? protocolExtra.VmessSecurity : Global.DefaultSecurity;
|
VmessSecurity = protocolExtra?.VmessSecurity?.IsNullOrEmpty() == false ? protocolExtra.VmessSecurity : Global.DefaultSecurity;
|
||||||
VlessEncryption = protocolExtra?.VlessEncryption.IsNullOrEmpty() == false ? protocolExtra.VlessEncryption : Global.None;
|
VlessEncryption = protocolExtra?.VlessEncryption.IsNullOrEmpty() == false ? protocolExtra.VlessEncryption : Global.None;
|
||||||
SsMethod = protocolExtra?.SsMethod ?? string.Empty;
|
SsMethod = protocolExtra?.SsMethod ?? string.Empty;
|
||||||
|
|
@ -139,6 +307,17 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
CongestionControl = protocolExtra?.CongestionControl ?? string.Empty;
|
CongestionControl = protocolExtra?.CongestionControl ?? string.Empty;
|
||||||
InsecureConcurrency = protocolExtra?.InsecureConcurrency > 0 ? protocolExtra.InsecureConcurrency : null;
|
InsecureConcurrency = protocolExtra?.InsecureConcurrency > 0 ? protocolExtra.InsecureConcurrency : null;
|
||||||
NaiveQuic = protocolExtra?.NaiveQuic ?? false;
|
NaiveQuic = protocolExtra?.NaiveQuic ?? false;
|
||||||
|
|
||||||
|
RawHeaderType = transport.RawHeaderType ?? Global.None;
|
||||||
|
Host = transport.Host ?? string.Empty;
|
||||||
|
Path = transport.Path ?? string.Empty;
|
||||||
|
XhttpMode = transport.XhttpMode ?? Global.DefaultXhttpMode;
|
||||||
|
XhttpExtra = transport.XhttpExtra ?? string.Empty;
|
||||||
|
GrpcAuthority = transport.GrpcAuthority ?? string.Empty;
|
||||||
|
GrpcServiceName = transport.GrpcServiceName ?? string.Empty;
|
||||||
|
GrpcMode = transport.GrpcMode.IsNullOrEmpty() ? Global.GrpcGunMode : transport.GrpcMode;
|
||||||
|
KcpHeaderType = transport.KcpHeaderType.IsNullOrEmpty() ? Global.None : transport.KcpHeaderType;
|
||||||
|
KcpSeed = transport.KcpSeed ?? string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SaveServerAsync()
|
private async Task SaveServerAsync()
|
||||||
|
|
@ -185,6 +364,25 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
SelectedSource.CoreType = CoreType.IsNullOrEmpty() ? null : (ECoreType)Enum.Parse(typeof(ECoreType), CoreType);
|
SelectedSource.CoreType = CoreType.IsNullOrEmpty() ? null : (ECoreType)Enum.Parse(typeof(ECoreType), CoreType);
|
||||||
SelectedSource.Cert = Cert.IsNullOrEmpty() ? string.Empty : Cert;
|
SelectedSource.Cert = Cert.IsNullOrEmpty() ? string.Empty : Cert;
|
||||||
SelectedSource.CertSha = CertSha.IsNullOrEmpty() ? string.Empty : CertSha;
|
SelectedSource.CertSha = CertSha.IsNullOrEmpty() ? string.Empty : CertSha;
|
||||||
|
if (!Global.Networks.Contains(SelectedSource.Network))
|
||||||
|
{
|
||||||
|
SelectedSource.Network = Global.DefaultNetwork;
|
||||||
|
}
|
||||||
|
|
||||||
|
var transport = new TransportExtraItem
|
||||||
|
{
|
||||||
|
RawHeaderType = RawHeaderType.NullIfEmpty(),
|
||||||
|
Host = Host.NullIfEmpty(),
|
||||||
|
Path = Path.NullIfEmpty(),
|
||||||
|
XhttpMode = XhttpMode.NullIfEmpty(),
|
||||||
|
XhttpExtra = XhttpExtra.NullIfEmpty(),
|
||||||
|
GrpcAuthority = GrpcAuthority.NullIfEmpty(),
|
||||||
|
GrpcServiceName = GrpcServiceName.NullIfEmpty(),
|
||||||
|
GrpcMode = GrpcMode.NullIfEmpty(),
|
||||||
|
KcpHeaderType = KcpHeaderType.NullIfEmpty(),
|
||||||
|
KcpSeed = KcpSeed.NullIfEmpty(),
|
||||||
|
};
|
||||||
|
|
||||||
SelectedSource.SetProtocolExtra(SelectedSource.GetProtocolExtra() with
|
SelectedSource.SetProtocolExtra(SelectedSource.GetProtocolExtra() with
|
||||||
{
|
{
|
||||||
Ports = Ports.NullIfEmpty(),
|
Ports = Ports.NullIfEmpty(),
|
||||||
|
|
@ -206,6 +404,7 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
InsecureConcurrency = InsecureConcurrency > 0 ? InsecureConcurrency : null,
|
InsecureConcurrency = InsecureConcurrency > 0 ? InsecureConcurrency : null,
|
||||||
NaiveQuic = NaiveQuic ? true : null,
|
NaiveQuic = NaiveQuic ? true : null,
|
||||||
});
|
});
|
||||||
|
SelectedSource.SetTransportExtra(transport);
|
||||||
|
|
||||||
if (await ConfigHandler.AddServer(_config, SelectedSource) == 0)
|
if (await ConfigHandler.AddServer(_config, SelectedSource) == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -261,7 +460,7 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
var serverName = SelectedSource.Sni;
|
var serverName = SelectedSource.Sni;
|
||||||
if (serverName.IsNullOrEmpty())
|
if (serverName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
serverName = SelectedSource.RequestHost;
|
serverName = GetCurrentTransportHost();
|
||||||
}
|
}
|
||||||
if (serverName.IsNullOrEmpty())
|
if (serverName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
|
|
@ -272,7 +471,7 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
domain += $":{SelectedSource.Port}";
|
domain += $":{SelectedSource.Port}";
|
||||||
}
|
}
|
||||||
|
|
||||||
(Cert, var certError) = await CertPemManager.Instance.GetCertPemAsync(domain, serverName);
|
(Cert, var certError) = await CertPemManager.Instance.GetCertPemAsync(domain, serverName, allowInsecure: AllowInsecureCertFetch);
|
||||||
UpdateCertTip(certError);
|
UpdateCertTip(certError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -286,7 +485,7 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
var serverName = SelectedSource.Sni;
|
var serverName = SelectedSource.Sni;
|
||||||
if (serverName.IsNullOrEmpty())
|
if (serverName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
serverName = SelectedSource.RequestHost;
|
serverName = GetCurrentTransportHost();
|
||||||
}
|
}
|
||||||
if (serverName.IsNullOrEmpty())
|
if (serverName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
|
|
@ -297,8 +496,21 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
domain += $":{SelectedSource.Port}";
|
domain += $":{SelectedSource.Port}";
|
||||||
}
|
}
|
||||||
|
|
||||||
var (certs, certError) = await CertPemManager.Instance.GetCertChainPemAsync(domain, serverName);
|
var (certs, certError) = await CertPemManager.Instance.GetCertChainPemAsync(domain, serverName, allowInsecure: AllowInsecureCertFetch);
|
||||||
Cert = CertPemManager.ConcatenatePemChain(certs);
|
Cert = CertPemManager.ConcatenatePemChain(certs);
|
||||||
UpdateCertTip(certError);
|
UpdateCertTip(certError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetCurrentTransportHost()
|
||||||
|
{
|
||||||
|
return SelectedSource.GetNetwork() switch
|
||||||
|
{
|
||||||
|
nameof(ETransport.raw) => Host,
|
||||||
|
nameof(ETransport.ws) => Host,
|
||||||
|
nameof(ETransport.httpupgrade) => Host,
|
||||||
|
nameof(ETransport.xhttp) => Host,
|
||||||
|
nameof(ETransport.grpc) => GrpcAuthority,
|
||||||
|
_ => string.Empty,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||||
[Reactive] public string DomainStrategy4FreedomCompatible { get; set; }
|
[Reactive] public string DomainStrategy4FreedomCompatible { get; set; }
|
||||||
[Reactive] public string DomainDNSAddressCompatible { get; set; }
|
[Reactive] public string DomainDNSAddressCompatible { get; set; }
|
||||||
[Reactive] public string NormalDNSCompatible { get; set; }
|
[Reactive] public string NormalDNSCompatible { get; set; }
|
||||||
|
[Reactive] public string TunDNSCompatible { get; set; }
|
||||||
|
|
||||||
[Reactive] public string DomainStrategy4Freedom2Compatible { get; set; }
|
[Reactive] public string DomainStrategy4Freedom2Compatible { get; set; }
|
||||||
[Reactive] public string DomainDNSAddress2Compatible { get; set; }
|
[Reactive] public string DomainDNSAddress2Compatible { get; set; }
|
||||||
|
|
@ -43,6 +44,7 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||||
ImportDefConfig4V2rayCompatibleCmd = ReactiveCommand.CreateFromTask(async () =>
|
ImportDefConfig4V2rayCompatibleCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
NormalDNSCompatible = EmbedUtils.GetEmbedText(Global.DNSV2rayNormalFileName);
|
NormalDNSCompatible = EmbedUtils.GetEmbedText(Global.DNSV2rayNormalFileName);
|
||||||
|
TunDNSCompatible = EmbedUtils.GetEmbedText(Global.DNSV2rayNormalFileName);
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -84,6 +86,7 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||||
DomainStrategy4FreedomCompatible = item1?.DomainStrategy4Freedom ?? string.Empty;
|
DomainStrategy4FreedomCompatible = item1?.DomainStrategy4Freedom ?? string.Empty;
|
||||||
DomainDNSAddressCompatible = item1?.DomainDNSAddress ?? string.Empty;
|
DomainDNSAddressCompatible = item1?.DomainDNSAddress ?? string.Empty;
|
||||||
NormalDNSCompatible = item1?.NormalDNS ?? string.Empty;
|
NormalDNSCompatible = item1?.NormalDNS ?? string.Empty;
|
||||||
|
TunDNSCompatible = item1?.TunDNS ?? string.Empty;
|
||||||
|
|
||||||
var item2 = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
|
var item2 = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
|
||||||
SBCustomDNSEnableCompatible = item2.Enabled;
|
SBCustomDNSEnableCompatible = item2.Enabled;
|
||||||
|
|
@ -124,10 +127,27 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (TunDNSCompatible.IsNotEmpty())
|
||||||
|
{
|
||||||
|
var obj = JsonUtils.ParseJson(TunDNSCompatible);
|
||||||
|
if (obj != null && obj["servers"] != null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (TunDNSCompatible.Contains('{') || TunDNSCompatible.Contains('}'))
|
||||||
|
{
|
||||||
|
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (NormalDNS2Compatible.IsNotEmpty())
|
if (NormalDNS2Compatible.IsNotEmpty())
|
||||||
{
|
{
|
||||||
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(NormalDNS2Compatible);
|
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(NormalDNS2Compatible);
|
||||||
if (obj2 == null)
|
if (obj2 == null
|
||||||
|
|| obj2.servers.Count == 0
|
||||||
|
|| obj2.servers.Any(s => s.type.IsNullOrEmpty()))
|
||||||
{
|
{
|
||||||
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
||||||
return;
|
return;
|
||||||
|
|
@ -136,7 +156,9 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||||
if (TunDNS2Compatible.IsNotEmpty())
|
if (TunDNS2Compatible.IsNotEmpty())
|
||||||
{
|
{
|
||||||
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(TunDNS2Compatible);
|
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(TunDNS2Compatible);
|
||||||
if (obj2 == null)
|
if (obj2 == null
|
||||||
|
|| obj2.servers.Count == 0
|
||||||
|
|| obj2.servers.Any(s => s.type.IsNullOrEmpty()))
|
||||||
{
|
{
|
||||||
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
||||||
return;
|
return;
|
||||||
|
|
@ -149,14 +171,15 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||||
item1.DomainDNSAddress = DomainDNSAddressCompatible;
|
item1.DomainDNSAddress = DomainDNSAddressCompatible;
|
||||||
item1.UseSystemHosts = UseSystemHostsCompatible;
|
item1.UseSystemHosts = UseSystemHostsCompatible;
|
||||||
item1.NormalDNS = NormalDNSCompatible;
|
item1.NormalDNS = NormalDNSCompatible;
|
||||||
|
item1.TunDNS = TunDNSCompatible;
|
||||||
await ConfigHandler.SaveDNSItems(_config, item1);
|
await ConfigHandler.SaveDNSItems(_config, item1);
|
||||||
|
|
||||||
var item2 = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
|
var item2 = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
|
||||||
item2.Enabled = SBCustomDNSEnableCompatible;
|
item2.Enabled = SBCustomDNSEnableCompatible;
|
||||||
item2.DomainStrategy4Freedom = DomainStrategy4Freedom2Compatible;
|
item2.DomainStrategy4Freedom = DomainStrategy4Freedom2Compatible;
|
||||||
item2.DomainDNSAddress = DomainDNSAddress2Compatible;
|
item2.DomainDNSAddress = DomainDNSAddress2Compatible;
|
||||||
item2.NormalDNS = JsonUtils.Serialize(JsonUtils.ParseJson(NormalDNS2Compatible));
|
item2.NormalDNS = JsonUtils.Serialize(JsonUtils.Deserialize<Dns4Sbox>(NormalDNS2Compatible));
|
||||||
item2.TunDNS = JsonUtils.Serialize(JsonUtils.ParseJson(TunDNS2Compatible));
|
item2.TunDNS = JsonUtils.Serialize(JsonUtils.Deserialize<Dns4Sbox>(TunDNS2Compatible));
|
||||||
await ConfigHandler.SaveDNSItems(_config, item2);
|
await ConfigHandler.SaveDNSItems(_config, item2);
|
||||||
|
|
||||||
await ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ public class FullConfigTemplateViewModel : MyReactiveObject
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string FullConfigTemplate4Ray { get; set; }
|
public string FullConfigTemplate4Ray { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public string FullTunConfigTemplate4Ray { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string FullConfigTemplate4Singbox { get; set; }
|
public string FullConfigTemplate4Singbox { get; set; }
|
||||||
|
|
||||||
|
|
@ -50,10 +53,15 @@ public class FullConfigTemplateViewModel : MyReactiveObject
|
||||||
private async Task Init()
|
private async Task Init()
|
||||||
{
|
{
|
||||||
var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
|
var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
|
||||||
EnableFullConfigTemplate4Ray = item?.Enabled ?? false;
|
if (item == null)
|
||||||
FullConfigTemplate4Ray = item?.Config ?? string.Empty;
|
{
|
||||||
AddProxyOnly4Ray = item?.AddProxyOnly ?? false;
|
return;
|
||||||
ProxyDetour4Ray = item?.ProxyDetour ?? string.Empty;
|
}
|
||||||
|
EnableFullConfigTemplate4Ray = item.Enabled;
|
||||||
|
FullConfigTemplate4Ray = item.Config ?? string.Empty;
|
||||||
|
FullTunConfigTemplate4Ray = item.TunConfig ?? string.Empty;
|
||||||
|
AddProxyOnly4Ray = item.AddProxyOnly ?? false;
|
||||||
|
ProxyDetour4Ray = item.ProxyDetour ?? string.Empty;
|
||||||
|
|
||||||
var item2 = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
|
var item2 = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
|
||||||
EnableFullConfigTemplate4Singbox = item2?.Enabled ?? false;
|
EnableFullConfigTemplate4Singbox = item2?.Enabled ?? false;
|
||||||
|
|
@ -82,10 +90,13 @@ public class FullConfigTemplateViewModel : MyReactiveObject
|
||||||
private async Task<bool> SaveXrayConfigAsync()
|
private async Task<bool> SaveXrayConfigAsync()
|
||||||
{
|
{
|
||||||
var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
|
var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
item.Enabled = EnableFullConfigTemplate4Ray;
|
item.Enabled = EnableFullConfigTemplate4Ray;
|
||||||
item.Config = null;
|
|
||||||
|
|
||||||
item.Config = FullConfigTemplate4Ray;
|
item.Config = FullConfigTemplate4Ray;
|
||||||
|
item.TunConfig = FullTunConfigTemplate4Ray;
|
||||||
|
|
||||||
item.AddProxyOnly = AddProxyOnly4Ray;
|
item.AddProxyOnly = AddProxyOnly4Ray;
|
||||||
item.ProxyDetour = ProxyDetour4Ray;
|
item.ProxyDetour = ProxyDetour4Ray;
|
||||||
|
|
@ -97,10 +108,11 @@ public class FullConfigTemplateViewModel : MyReactiveObject
|
||||||
private async Task<bool> SaveSingboxConfigAsync()
|
private async Task<bool> SaveSingboxConfigAsync()
|
||||||
{
|
{
|
||||||
var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
|
var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
item.Enabled = EnableFullConfigTemplate4Singbox;
|
item.Enabled = EnableFullConfigTemplate4Singbox;
|
||||||
item.Config = null;
|
|
||||||
item.TunConfig = null;
|
|
||||||
|
|
||||||
item.Config = FullConfigTemplate4Singbox;
|
item.Config = FullConfigTemplate4Singbox;
|
||||||
item.TunConfig = FullTunConfigTemplate4Singbox;
|
item.TunConfig = FullTunConfigTemplate4Singbox;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -559,7 +559,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
|
|
||||||
await Task.Run(async () =>
|
await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await LoadCore(allResult.ResolvedMainContext, allResult.PreSocksResult?.Context);
|
await LoadCore(allResult.MainResult.Context, allResult.PreSocksResult?.Context);
|
||||||
await SysProxyHandler.UpdateSysProxy(_config, false);
|
await SysProxyHandler.UpdateSysProxy(_config, false);
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ public class ProfilesSelectViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
SelectedSub = (_config.SubIndexId.IsNotEmpty()
|
SelectedSub = (_config.SubIndexId.IsNotEmpty()
|
||||||
? SubItems.FirstOrDefault(t => t.Id == _config.SubIndexId)
|
? SubItems.FirstOrDefault(t => t.Id == _config.SubIndexId)
|
||||||
: null) ?? SubItems.LastOrDefault();
|
: null) ?? SubItems.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<List<ProfileItemModel>?> GetProfileItemsEx(string subid, string filter)
|
private async Task<List<ProfileItemModel>?> GetProfileItemsEx(string subid, string filter)
|
||||||
|
|
|
||||||
|
|
@ -393,7 +393,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
SelectedSub = (_config.SubIndexId.IsNotEmpty()
|
SelectedSub = (_config.SubIndexId.IsNotEmpty()
|
||||||
? SubItems.FirstOrDefault(t => t.Id == _config.SubIndexId)
|
? SubItems.FirstOrDefault(t => t.Id == _config.SubIndexId)
|
||||||
: null) ?? SubItems.LastOrDefault();
|
: null) ?? SubItems.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<List<ProfileItemModel>?> GetProfileItemsEx(string subid, string filter)
|
private async Task<List<ProfileItemModel>?> GetProfileItemsEx(string subid, string filter)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ public class RoutingSettingViewModel : MyReactiveObject
|
||||||
public ReactiveCommand<Unit, Unit> RoutingAdvancedSetDefaultCmd { get; }
|
public ReactiveCommand<Unit, Unit> RoutingAdvancedSetDefaultCmd { get; }
|
||||||
public ReactiveCommand<Unit, Unit> RoutingAdvancedImportRulesCmd { get; }
|
public ReactiveCommand<Unit, Unit> RoutingAdvancedImportRulesCmd { get; }
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
|
||||||
public bool IsModified { get; set; }
|
public bool IsModified { get; set; }
|
||||||
|
|
||||||
#endregion Reactive
|
#endregion Reactive
|
||||||
|
|
@ -53,12 +52,19 @@ public class RoutingSettingViewModel : MyReactiveObject
|
||||||
await RoutingAdvancedImportRules();
|
await RoutingAdvancedImportRules();
|
||||||
});
|
});
|
||||||
|
|
||||||
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
|
|
||||||
{
|
|
||||||
await SaveRoutingAsync();
|
|
||||||
});
|
|
||||||
|
|
||||||
_ = Init();
|
_ = Init();
|
||||||
|
|
||||||
|
// Auto-save DomainStrategy when changed
|
||||||
|
this.WhenAnyValue(
|
||||||
|
x => x.DomainStrategy,
|
||||||
|
x => x.DomainStrategy4Singbox)
|
||||||
|
.Skip(1)
|
||||||
|
.DistinctUntilChanged()
|
||||||
|
.Subscribe(x =>
|
||||||
|
{
|
||||||
|
IsModified = true;
|
||||||
|
_ = SaveSettingsAsync();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Init()
|
private async Task Init()
|
||||||
|
|
@ -96,20 +102,14 @@ public class RoutingSettingViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SaveRoutingAsync()
|
/// <summary>
|
||||||
|
/// Save DomainStrategy settings
|
||||||
|
/// </summary>
|
||||||
|
public async Task SaveSettingsAsync()
|
||||||
{
|
{
|
||||||
_config.RoutingBasicItem.DomainStrategy = DomainStrategy;
|
_config.RoutingBasicItem.DomainStrategy = DomainStrategy;
|
||||||
_config.RoutingBasicItem.DomainStrategy4Singbox = DomainStrategy4Singbox;
|
_config.RoutingBasicItem.DomainStrategy4Singbox = DomainStrategy4Singbox;
|
||||||
|
await ConfigHandler.SaveConfig(_config);
|
||||||
if (await ConfigHandler.SaveConfig(_config) == 0)
|
|
||||||
{
|
|
||||||
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
|
||||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Refresh Save
|
#endregion Refresh Save
|
||||||
|
|
|
||||||
8
v2rayN/v2rayN.Desktop/Common/ButtonResult.cs
Normal file
8
v2rayN/v2rayN.Desktop/Common/ButtonResult.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
namespace v2rayN.Desktop.Common;
|
||||||
|
|
||||||
|
public enum ButtonResult
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Yes = 1,
|
||||||
|
No = 2
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
using MsBox.Avalonia;
|
using v2rayN.Desktop.Views;
|
||||||
|
|
||||||
namespace v2rayN.Desktop.Common;
|
namespace v2rayN.Desktop.Common;
|
||||||
|
|
||||||
|
|
@ -9,8 +9,9 @@ internal class UI
|
||||||
|
|
||||||
public static async Task<ButtonResult> ShowYesNo(Window owner, string msg)
|
public static async Task<ButtonResult> ShowYesNo(Window owner, string msg)
|
||||||
{
|
{
|
||||||
var box = MessageBoxManager.GetMessageBoxStandard(caption, msg, ButtonEnum.YesNo);
|
var box = new MessageBoxDialog(caption, msg);
|
||||||
return await box.ShowWindowDialogAsync(owner);
|
var result = await box.ShowDialog<ButtonResult>(owner);
|
||||||
|
return result == ButtonResult.Yes ? ButtonResult.Yes : ButtonResult.No;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<string?> OpenFileDialog(Window owner, FilePickerFileType? filter)
|
public static async Task<string?> OpenFileDialog(Window owner, FilePickerFileType? filter)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ global using Avalonia.Platform;
|
||||||
global using Avalonia.Styling;
|
global using Avalonia.Styling;
|
||||||
global using Avalonia.Threading;
|
global using Avalonia.Threading;
|
||||||
global using DynamicData;
|
global using DynamicData;
|
||||||
global using MsBox.Avalonia.Enums;
|
|
||||||
global using ReactiveUI;
|
global using ReactiveUI;
|
||||||
global using ReactiveUI.Avalonia;
|
global using ReactiveUI.Avalonia;
|
||||||
global using ReactiveUI.Fody.Helpers;
|
global using ReactiveUI.Fody.Helpers;
|
||||||
|
|
|
||||||
|
|
@ -690,128 +690,279 @@
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="gridTransport"
|
x:Name="gridTransport"
|
||||||
Grid.Row="4"
|
Grid.Row="4"
|
||||||
ColumnDefinitions="300,Auto,Auto"
|
RowDefinitions="Auto,Auto,Auto">
|
||||||
RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto">
|
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.ColumnSpan="2"
|
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
Text="{x:Static resx:ResUI.GbTransport}" />
|
Text="{x:Static resx:ResUI.GbTransport}" />
|
||||||
|
|
||||||
|
<Grid Grid.Row="1" ColumnDefinitions="300,Auto,Auto">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="1"
|
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{x:Static resx:ResUI.TbNetwork}" />
|
Text="{x:Static resx:ResUI.TbNetwork}" />
|
||||||
<ComboBox
|
<ComboBox
|
||||||
x:Name="cmbNetwork"
|
x:Name="cmbNetwork"
|
||||||
Grid.Row="1"
|
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Width="200"
|
Width="200"
|
||||||
Margin="{StaticResource Margin4}" />
|
Margin="{StaticResource Margin4}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="1"
|
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{x:Static resx:ResUI.TipNetwork}" />
|
Text="{x:Static resx:ResUI.TipNetwork}" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid Grid.Row="2">
|
||||||
|
<Grid
|
||||||
|
x:Name="gridTransportRaw"
|
||||||
|
IsVisible="False"
|
||||||
|
RowDefinitions="Auto,Auto">
|
||||||
|
<Grid Grid.Row="0" ColumnDefinitions="300,Auto">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="labHeaderType"
|
Grid.Row="0"
|
||||||
Grid.Row="2"
|
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{x:Static resx:ResUI.TbHeaderType}" />
|
Text="{x:Static resx:ResUI.TransportHeaderType1}" />
|
||||||
<StackPanel
|
|
||||||
Grid.Row="2"
|
|
||||||
Grid.Column="1"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Orientation="Horizontal">
|
|
||||||
<ComboBox
|
<ComboBox
|
||||||
x:Name="cmbHeaderType"
|
x:Name="cmbHeaderTypeRaw"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
Width="200"
|
Width="200"
|
||||||
Margin="{StaticResource Margin4}" />
|
Margin="{StaticResource Margin4}" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<Button
|
<Grid
|
||||||
x:Name="btnExtra"
|
x:Name="gridTransportRawHttp"
|
||||||
Margin="{StaticResource MarginLr8}"
|
Grid.Row="1"
|
||||||
Classes="IconButton">
|
ColumnDefinitions="300,Auto"
|
||||||
<Button.Content>
|
IsVisible="False"
|
||||||
<PathIcon Data="{StaticResource SemiIconMore}">
|
RowDefinitions="Auto,Auto">
|
||||||
<PathIcon.RenderTransform>
|
|
||||||
<RotateTransform Angle="90" />
|
|
||||||
</PathIcon.RenderTransform>
|
|
||||||
</PathIcon>
|
|
||||||
</Button.Content>
|
|
||||||
<Button.Flyout>
|
|
||||||
<Flyout>
|
|
||||||
<StackPanel>
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{x:Static resx:ResUI.TransportExtraTip}" />
|
Text="{x:Static resx:ResUI.TbCamouflageDomain}" />
|
||||||
<views:JsonEditor
|
<TextBox
|
||||||
x:Name="txtExtra"
|
x:Name="txtRequestHostRaw"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
Width="400"
|
Width="400"
|
||||||
MinHeight="100"
|
Margin="{StaticResource Margin4}" />
|
||||||
Margin="{StaticResource Margin4}"
|
<TextBlock
|
||||||
HorizontalAlignment="Stretch"
|
Grid.Row="1"
|
||||||
VerticalAlignment="Center" />
|
Grid.Column="0"
|
||||||
</StackPanel>
|
Margin="{StaticResource Margin4}"
|
||||||
</Flyout>
|
VerticalAlignment="Center"
|
||||||
</Button.Flyout>
|
Text="{x:Static resx:ResUI.TbPath}" />
|
||||||
</Button>
|
<TextBox
|
||||||
</StackPanel>
|
x:Name="txtPathRaw"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}" />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid
|
||||||
|
x:Name="gridTransportXhttp"
|
||||||
|
ColumnDefinitions="300,Auto"
|
||||||
|
IsVisible="False"
|
||||||
|
RowDefinitions="Auto,Auto,Auto,Auto">
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{x:Static resx:ResUI.TransportHeaderType5}" />
|
||||||
|
<ComboBox
|
||||||
|
x:Name="cmbHeaderTypeXhttp"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="200"
|
||||||
|
Margin="{StaticResource Margin4}" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{x:Static resx:ResUI.TbHost}" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtRequestHostXhttp"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="tipHeaderType"
|
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Grid.Column="2"
|
|
||||||
Margin="{StaticResource Margin4}"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{x:Static resx:ResUI.TbHeaderType}" />
|
|
||||||
|
|
||||||
<TextBlock
|
|
||||||
Grid.Row="3"
|
|
||||||
Grid.Column="0"
|
|
||||||
Margin="{StaticResource Margin4}"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{x:Static resx:ResUI.TbRequestHost}" />
|
|
||||||
<TextBox
|
|
||||||
x:Name="txtRequestHost"
|
|
||||||
Grid.Row="3"
|
|
||||||
Grid.Column="1"
|
|
||||||
Width="400"
|
|
||||||
Margin="{StaticResource Margin4}" />
|
|
||||||
<TextBlock
|
|
||||||
x:Name="tipRequestHost"
|
|
||||||
Grid.Row="3"
|
|
||||||
Grid.Column="2"
|
|
||||||
Margin="{StaticResource Margin4}"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{x:Static resx:ResUI.TbRequestHost}" />
|
|
||||||
|
|
||||||
<TextBlock
|
|
||||||
Grid.Row="4"
|
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{x:Static resx:ResUI.TbPath}" />
|
Text="{x:Static resx:ResUI.TbPath}" />
|
||||||
<TextBox
|
<TextBox
|
||||||
x:Name="txtPath"
|
x:Name="txtPathXhttp"
|
||||||
Grid.Row="4"
|
Grid.Row="2"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Width="400"
|
Width="400"
|
||||||
Margin="{StaticResource Margin4}" />
|
Margin="{StaticResource Margin4}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="tipPath"
|
Grid.Row="3"
|
||||||
Grid.Row="4"
|
Grid.Column="0"
|
||||||
Grid.Column="2"
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Text="{x:Static resx:ResUI.TransportExtra}"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
|
<Expander
|
||||||
|
Grid.Row="3"
|
||||||
|
Grid.Column="1"
|
||||||
|
IsExpanded="True">
|
||||||
|
<Expander.Header>
|
||||||
|
<TextBlock FontWeight="Normal" Text="{x:Static resx:ResUI.TransportExtraTip}" />
|
||||||
|
</Expander.Header>
|
||||||
|
<views:JsonEditor x:Name="txtExtraXhttp" HorizontalAlignment="Stretch" />
|
||||||
|
</Expander>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid
|
||||||
|
x:Name="gridTransportKcp"
|
||||||
|
ColumnDefinitions="300,Auto"
|
||||||
|
IsVisible="False"
|
||||||
|
RowDefinitions="Auto,Auto">
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{x:Static resx:ResUI.TransportHeaderType2}" />
|
||||||
|
<ComboBox
|
||||||
|
x:Name="cmbHeaderTypeKcp"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="200"
|
||||||
|
Margin="{StaticResource Margin4}" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="Seed" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtKcpSeed"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid
|
||||||
|
x:Name="gridTransportGrpc"
|
||||||
|
ColumnDefinitions="300,Auto"
|
||||||
|
IsVisible="False"
|
||||||
|
RowDefinitions="Auto,Auto,Auto">
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{x:Static resx:ResUI.TransportHeaderType4}" />
|
||||||
|
<ComboBox
|
||||||
|
x:Name="cmbHeaderTypeGrpc"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="200"
|
||||||
|
Margin="{StaticResource Margin4}" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{x:Static resx:ResUI.TransportRequestHostTip5}" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtRequestHostGrpc"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="2"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{x:Static resx:ResUI.TransportPathTip4}" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtPathGrpc"
|
||||||
|
Grid.Row="2"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid
|
||||||
|
x:Name="gridTransportWs"
|
||||||
|
ColumnDefinitions="300,Auto"
|
||||||
|
IsVisible="False"
|
||||||
|
RowDefinitions="Auto,Auto">
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{x:Static resx:ResUI.TbHost}" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtRequestHostWs"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{x:Static resx:ResUI.TbPath}" />
|
Text="{x:Static resx:ResUI.TbPath}" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtPathWs"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid
|
||||||
|
x:Name="gridTransportHttpupgrade"
|
||||||
|
ColumnDefinitions="300,Auto"
|
||||||
|
IsVisible="False"
|
||||||
|
RowDefinitions="Auto,Auto">
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{x:Static resx:ResUI.TbHost}" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtRequestHostHttpupgrade"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{x:Static resx:ResUI.TbPath}" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtPathHttpupgrade"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}" />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid
|
<Grid
|
||||||
|
|
@ -1008,6 +1159,25 @@
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
Content="{x:Static resx:ResUI.TbFetchCertChain}" />
|
Content="{x:Static resx:ResUI.TbFetchCertChain}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
|
||||||
|
<TextBlock
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{x:Static resx:ResUI.TbAllowInsecureCertFetch}" />
|
||||||
|
<ToggleSwitch
|
||||||
|
x:Name="togAllowInsecureCertFetch"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
HorizontalAlignment="Left" />
|
||||||
|
</StackPanel>
|
||||||
|
<TextBlock
|
||||||
|
x:Name="txtAllowInsecureCertFetchTips"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Foreground="#FFD32F2F"
|
||||||
|
IsVisible="False"
|
||||||
|
Text="{x:Static resx:ResUI.TbAllowInsecureCertFetchTips}"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Width="400"
|
Width="400"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
|
||||||
Loaded += Window_Loaded;
|
Loaded += Window_Loaded;
|
||||||
btnCancel.Click += (s, e) => Close();
|
btnCancel.Click += (s, e) => Close();
|
||||||
cmbNetwork.SelectionChanged += CmbNetwork_SelectionChanged;
|
cmbNetwork.SelectionChanged += CmbNetwork_SelectionChanged;
|
||||||
|
cmbHeaderTypeRaw.SelectionChanged += CmbHeaderTypeRaw_SelectionChanged;
|
||||||
cmbStreamSecurity.SelectionChanged += CmbStreamSecurity_SelectionChanged;
|
cmbStreamSecurity.SelectionChanged += CmbStreamSecurity_SelectionChanged;
|
||||||
btnGUID.Click += btnGUID_Click;
|
btnGUID.Click += btnGUID_Click;
|
||||||
btnGUID5.Click += btnGUID_Click;
|
btnGUID5.Click += btnGUID_Click;
|
||||||
|
|
@ -24,6 +25,16 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
|
||||||
|
|
||||||
cmbCoreType.ItemsSource = Global.CoreTypes.AppendEmpty();
|
cmbCoreType.ItemsSource = Global.CoreTypes.AppendEmpty();
|
||||||
cmbNetwork.ItemsSource = Global.Networks;
|
cmbNetwork.ItemsSource = Global.Networks;
|
||||||
|
|
||||||
|
cmbHeaderTypeRaw.ItemsSource = new List<string> { Global.None, Global.RawHeaderHttp };
|
||||||
|
|
||||||
|
var kcpHeaderTypes = new List<string> { Global.None };
|
||||||
|
kcpHeaderTypes.AddRange(Global.KcpHeaderTypes);
|
||||||
|
cmbHeaderTypeKcp.ItemsSource = kcpHeaderTypes;
|
||||||
|
|
||||||
|
cmbHeaderTypeXhttp.ItemsSource = Global.XhttpMode;
|
||||||
|
cmbHeaderTypeGrpc.ItemsSource = new List<string> { Global.GrpcGunMode, Global.GrpcMultiMode };
|
||||||
|
|
||||||
cmbFingerprint.ItemsSource = Global.Fingerprints;
|
cmbFingerprint.ItemsSource = Global.Fingerprints;
|
||||||
cmbFingerprint2.ItemsSource = Global.Fingerprints;
|
cmbFingerprint2.ItemsSource = Global.Fingerprints;
|
||||||
cmbAllowInsecure.ItemsSource = Global.AllowInsecure;
|
cmbAllowInsecure.ItemsSource = Global.AllowInsecure;
|
||||||
|
|
@ -201,10 +212,27 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.Network, v => v.cmbNetwork.SelectedValue).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.Network, v => v.cmbNetwork.SelectedValue).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType.SelectedValue).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.RawHeaderType, v => v.cmbHeaderTypeRaw.SelectedValue).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.RequestHost, v => v.txtRequestHost.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.Host, v => v.txtRequestHostRaw.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.Path, v => v.txtPathRaw.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.Extra, v => v.txtExtra.Text).DisposeWith(disposables);
|
|
||||||
|
this.Bind(ViewModel, vm => vm.KcpHeaderType, v => v.cmbHeaderTypeKcp.SelectedValue).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.KcpSeed, v => v.txtKcpSeed.Text).DisposeWith(disposables);
|
||||||
|
|
||||||
|
this.Bind(ViewModel, vm => vm.Host, v => v.txtRequestHostWs.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.Path, v => v.txtPathWs.Text).DisposeWith(disposables);
|
||||||
|
|
||||||
|
this.Bind(ViewModel, vm => vm.Host, v => v.txtRequestHostHttpupgrade.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.Path, v => v.txtPathHttpupgrade.Text).DisposeWith(disposables);
|
||||||
|
|
||||||
|
this.Bind(ViewModel, vm => vm.XhttpMode, v => v.cmbHeaderTypeXhttp.SelectedValue).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.Host, v => v.txtRequestHostXhttp.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.Path, v => v.txtPathXhttp.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.XhttpExtra, v => v.txtExtraXhttp.Text).DisposeWith(disposables);
|
||||||
|
|
||||||
|
this.Bind(ViewModel, vm => vm.GrpcMode, v => v.cmbHeaderTypeGrpc.SelectedValue).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.GrpcAuthority, v => v.txtRequestHostGrpc.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.GrpcServiceName, v => v.txtPathGrpc.Text).DisposeWith(disposables);
|
||||||
|
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.StreamSecurity, v => v.cmbStreamSecurity.SelectedValue).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.StreamSecurity, v => v.cmbStreamSecurity.SelectedValue).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI.Text).DisposeWith(disposables);
|
||||||
|
|
@ -214,6 +242,8 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
|
||||||
this.Bind(ViewModel, vm => vm.CertSha, v => v.txtCertSha256Pinning.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.CertSha, v => v.txtCertSha256Pinning.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.CertTip, v => v.labCertPinning.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.CertTip, v => v.labCertPinning.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.Cert, v => v.txtCert.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.Cert, v => v.txtCert.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.AllowInsecureCertFetch, v => v.togAllowInsecureCertFetch.IsChecked).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.AllowInsecureCertFetch, v => v.txtAllowInsecureCertFetchTips.IsVisible).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.EchConfigList, v => v.txtEchConfigList.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.EchConfigList, v => v.txtEchConfigList.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.EchForceQuery, v => v.cmbEchForceQuery.SelectedValue).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.EchForceQuery, v => v.cmbEchForceQuery.SelectedValue).DisposeWith(disposables);
|
||||||
|
|
||||||
|
|
@ -253,8 +283,12 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
|
||||||
|
|
||||||
private void CmbNetwork_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
private void CmbNetwork_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
SetHeaderType();
|
SetTransportGridVisibility();
|
||||||
SetTips();
|
}
|
||||||
|
|
||||||
|
private void CmbHeaderTypeRaw_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
SetRawHttpFieldsVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CmbStreamSecurity_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
private void CmbStreamSecurity_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||||
|
|
@ -283,102 +317,60 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
|
||||||
txtId5.Text = Utils.GetGuid();
|
txtId5.Text = Utils.GetGuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetHeaderType()
|
private void SetTransportGridVisibility()
|
||||||
{
|
{
|
||||||
var lstHeaderType = new List<string>();
|
var network = cmbNetwork.SelectedItem?.ToString();
|
||||||
|
|
||||||
var network = cmbNetwork.SelectedItem.ToString();
|
|
||||||
if (network.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
lstHeaderType.Add(Global.None);
|
|
||||||
cmbHeaderType.ItemsSource = lstHeaderType;
|
|
||||||
cmbHeaderType.SelectedIndex = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (network == nameof(ETransport.tcp))
|
|
||||||
{
|
|
||||||
lstHeaderType.Add(Global.None);
|
|
||||||
lstHeaderType.Add(Global.TcpHeaderHttp);
|
|
||||||
}
|
|
||||||
else if (network is nameof(ETransport.kcp) or nameof(ETransport.quic))
|
|
||||||
{
|
|
||||||
lstHeaderType.Add(Global.None);
|
|
||||||
lstHeaderType.AddRange(Global.KcpHeaderTypes);
|
|
||||||
}
|
|
||||||
else if (network is nameof(ETransport.xhttp))
|
|
||||||
{
|
|
||||||
lstHeaderType.AddRange(Global.XhttpMode);
|
|
||||||
}
|
|
||||||
else if (network == nameof(ETransport.grpc))
|
|
||||||
{
|
|
||||||
lstHeaderType.Add(Global.GrpcGunMode);
|
|
||||||
lstHeaderType.Add(Global.GrpcMultiMode);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lstHeaderType.Add(Global.None);
|
|
||||||
}
|
|
||||||
cmbHeaderType.ItemsSource = lstHeaderType;
|
|
||||||
cmbHeaderType.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetTips()
|
|
||||||
{
|
|
||||||
var network = cmbNetwork.SelectedItem.ToString();
|
|
||||||
if (network.IsNullOrEmpty())
|
if (network.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
network = Global.DefaultNetwork;
|
network = Global.DefaultNetwork;
|
||||||
}
|
}
|
||||||
labHeaderType.IsVisible = true;
|
|
||||||
btnExtra.IsVisible = false;
|
gridTransportRaw.IsVisible = false;
|
||||||
tipRequestHost.Text =
|
gridTransportKcp.IsVisible = false;
|
||||||
tipPath.Text =
|
gridTransportWs.IsVisible = false;
|
||||||
tipHeaderType.Text = string.Empty;
|
gridTransportHttpupgrade.IsVisible = false;
|
||||||
|
gridTransportXhttp.IsVisible = false;
|
||||||
|
gridTransportGrpc.IsVisible = false;
|
||||||
|
|
||||||
switch (network)
|
switch (network)
|
||||||
{
|
{
|
||||||
case nameof(ETransport.tcp):
|
case nameof(ETransport.raw):
|
||||||
tipRequestHost.Text = ResUI.TransportRequestHostTip1;
|
gridTransportRaw.IsVisible = true;
|
||||||
tipHeaderType.Text = ResUI.TransportHeaderTypeTip1;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.kcp):
|
case nameof(ETransport.kcp):
|
||||||
tipHeaderType.Text = ResUI.TransportHeaderTypeTip2;
|
gridTransportKcp.IsVisible = true;
|
||||||
tipPath.Text = ResUI.TransportPathTip5;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.ws):
|
case nameof(ETransport.ws):
|
||||||
|
gridTransportWs.IsVisible = true;
|
||||||
|
break;
|
||||||
case nameof(ETransport.httpupgrade):
|
case nameof(ETransport.httpupgrade):
|
||||||
tipRequestHost.Text = ResUI.TransportRequestHostTip2;
|
gridTransportHttpupgrade.IsVisible = true;
|
||||||
tipPath.Text = ResUI.TransportPathTip1;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.xhttp):
|
case nameof(ETransport.xhttp):
|
||||||
tipRequestHost.Text = ResUI.TransportRequestHostTip2;
|
gridTransportXhttp.IsVisible = true;
|
||||||
tipPath.Text = ResUI.TransportPathTip1;
|
|
||||||
tipHeaderType.Text = ResUI.TransportHeaderTypeTip5;
|
|
||||||
labHeaderType.IsVisible = false;
|
|
||||||
btnExtra.IsVisible = true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.h2):
|
|
||||||
tipRequestHost.Text = ResUI.TransportRequestHostTip3;
|
|
||||||
tipPath.Text = ResUI.TransportPathTip2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case nameof(ETransport.quic):
|
|
||||||
tipRequestHost.Text = ResUI.TransportRequestHostTip4;
|
|
||||||
tipPath.Text = ResUI.TransportPathTip3;
|
|
||||||
tipHeaderType.Text = ResUI.TransportHeaderTypeTip3;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case nameof(ETransport.grpc):
|
case nameof(ETransport.grpc):
|
||||||
tipRequestHost.Text = ResUI.TransportRequestHostTip5;
|
gridTransportGrpc.IsVisible = true;
|
||||||
tipPath.Text = ResUI.TransportPathTip4;
|
break;
|
||||||
tipHeaderType.Text = ResUI.TransportHeaderTypeTip4;
|
default:
|
||||||
labHeaderType.IsVisible = false;
|
gridTransportRaw.IsVisible = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetRawHttpFieldsVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetRawHttpFieldsVisibility()
|
||||||
|
{
|
||||||
|
var network = cmbNetwork.SelectedItem?.ToString();
|
||||||
|
if (network.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
network = Global.DefaultNetwork;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rawHeaderType = cmbHeaderTypeRaw.SelectedItem?.ToString();
|
||||||
|
var showRawHttpFields = network == nameof(ETransport.raw)
|
||||||
|
&& rawHeaderType == Global.RawHeaderHttp;
|
||||||
|
gridTransportRawHttp.IsVisible = showRawHttpFields;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -395,13 +395,26 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
|
|
||||||
|
<Grid Margin="{StaticResource Margin4}" ColumnDefinitions="*,10,*">
|
||||||
|
|
||||||
<HeaderedContentControl
|
<HeaderedContentControl
|
||||||
Margin="{StaticResource Margin4}"
|
Grid.Column="0"
|
||||||
BorderBrush="Gray"
|
BorderBrush="Gray"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
Header="HTTP/SOCKS">
|
Header="HTTP/SOCKS">
|
||||||
<local:JsonEditor Name="txtnormalDNSCompatible" VerticalAlignment="Stretch" />
|
<local:JsonEditor Name="txtnormalDNSCompatible" VerticalAlignment="Stretch" />
|
||||||
</HeaderedContentControl>
|
</HeaderedContentControl>
|
||||||
|
|
||||||
|
<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
|
||||||
|
|
||||||
|
<HeaderedContentControl
|
||||||
|
Grid.Column="2"
|
||||||
|
BorderBrush="Gray"
|
||||||
|
BorderThickness="1"
|
||||||
|
Header="{x:Static resx:ResUI.TbSettingsTunMode}">
|
||||||
|
<local:JsonEditor Name="txttunDNSCompatible" VerticalAlignment="Stretch" />
|
||||||
|
</HeaderedContentControl>
|
||||||
|
</Grid>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ public partial class DNSSettingWindow : WindowBase<DNSSettingViewModel>
|
||||||
this.Bind(ViewModel, vm => vm.DomainStrategy4FreedomCompatible, v => v.cmbdomainStrategy4FreedomCompatible.SelectedItem).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.DomainStrategy4FreedomCompatible, v => v.cmbdomainStrategy4FreedomCompatible.SelectedItem).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.DomainDNSAddressCompatible, v => v.cmbdomainDNSAddressCompatible.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.DomainDNSAddressCompatible, v => v.cmbdomainDNSAddressCompatible.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.NormalDNSCompatible, v => v.txtnormalDNSCompatible.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.NormalDNSCompatible, v => v.txtnormalDNSCompatible.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.TunDNSCompatible, v => v.txttunDNSCompatible.Text).DisposeWith(disposables);
|
||||||
|
|
||||||
this.Bind(ViewModel, vm => vm.DomainStrategy4Freedom2Compatible, v => v.cmbdomainStrategy4OutCompatible.SelectedItem).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.DomainStrategy4Freedom2Compatible, v => v.cmbdomainStrategy4OutCompatible.SelectedItem).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.DomainDNSAddress2Compatible, v => v.cmbdomainDNSAddress2Compatible.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.DomainDNSAddress2Compatible, v => v.cmbdomainDNSAddress2Compatible.Text).DisposeWith(disposables);
|
||||||
|
|
|
||||||
|
|
@ -90,13 +90,26 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
|
|
||||||
|
<Grid Margin="{StaticResource Margin4}" ColumnDefinitions="*,10,*">
|
||||||
|
|
||||||
<HeaderedContentControl
|
<HeaderedContentControl
|
||||||
Margin="{StaticResource Margin4}"
|
Grid.Column="0"
|
||||||
BorderBrush="Gray"
|
BorderBrush="Gray"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
Header="xray config template json">
|
Header="xray config template json">
|
||||||
<views:JsonEditor x:Name="rayFullConfigTemplate" VerticalAlignment="Stretch" />
|
<views:JsonEditor x:Name="rayFullConfigTemplate" VerticalAlignment="Stretch" />
|
||||||
</HeaderedContentControl>
|
</HeaderedContentControl>
|
||||||
|
|
||||||
|
<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
|
||||||
|
|
||||||
|
<HeaderedContentControl
|
||||||
|
Grid.Column="2"
|
||||||
|
BorderBrush="Gray"
|
||||||
|
BorderThickness="1"
|
||||||
|
Header="xray tun config template json">
|
||||||
|
<views:JsonEditor x:Name="rayFullTunConfigTemplate" VerticalAlignment="Stretch" />
|
||||||
|
</HeaderedContentControl>
|
||||||
|
</Grid>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem HorizontalAlignment="Left" Header="{x:Static resx:ResUI.TbSBFullConfigTemplate}">
|
<TabItem HorizontalAlignment="Left" Header="{x:Static resx:ResUI.TbSBFullConfigTemplate}">
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,14 @@ public partial class FullConfigTemplateWindow : WindowBase<FullConfigTemplateVie
|
||||||
|
|
||||||
_config = AppManager.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
Loaded += Window_Loaded;
|
Loaded += Window_Loaded;
|
||||||
btnCancel.Click += (s, e) => Close();
|
btnCancel.Click += (_, _) => Close();
|
||||||
ViewModel = new FullConfigTemplateViewModel(UpdateViewHandler);
|
ViewModel = new FullConfigTemplateViewModel(UpdateViewHandler);
|
||||||
|
|
||||||
this.WhenActivated(disposables =>
|
this.WhenActivated(disposables =>
|
||||||
{
|
{
|
||||||
this.Bind(ViewModel, vm => vm.EnableFullConfigTemplate4Ray, v => v.rayFullConfigTemplateEnable.IsChecked).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.EnableFullConfigTemplate4Ray, v => v.rayFullConfigTemplateEnable.IsChecked).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.FullConfigTemplate4Ray, v => v.rayFullConfigTemplate.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.FullConfigTemplate4Ray, v => v.rayFullConfigTemplate.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.FullTunConfigTemplate4Ray, v => v.rayFullTunConfigTemplate.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.AddProxyOnly4Ray, v => v.togAddProxyProtocolOutboundOnly4Ray.IsChecked).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.AddProxyOnly4Ray, v => v.togAddProxyProtocolOutboundOnly4Ray.IsChecked).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.ProxyDetour4Ray, v => v.txtProxyDetour4Ray.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.ProxyDetour4Ray, v => v.txtProxyDetour4Ray.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.EnableFullConfigTemplate4Singbox, v => v.sbFullConfigTemplateEnable.IsChecked).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.EnableFullConfigTemplate4Singbox, v => v.sbFullConfigTemplateEnable.IsChecked).DisposeWith(disposables);
|
||||||
|
|
|
||||||
53
v2rayN/v2rayN.Desktop/Views/MessageBoxDialog.axaml
Normal file
53
v2rayN/v2rayN.Desktop/Views/MessageBoxDialog.axaml
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
<Window
|
||||||
|
x:Class="v2rayN.Desktop.Views.MessageBoxDialog"
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
|
||||||
|
Width="420"
|
||||||
|
MinWidth="350"
|
||||||
|
MaxWidth="600"
|
||||||
|
CanResize="False"
|
||||||
|
ShowInTaskbar="False"
|
||||||
|
SizeToContent="Height"
|
||||||
|
SystemDecorations="Full"
|
||||||
|
WindowStartupLocation="CenterOwner"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
|
||||||
|
<Grid Margin="24" RowDefinitions="*,Auto">
|
||||||
|
<ScrollViewer
|
||||||
|
Grid.Row="0"
|
||||||
|
MinHeight="60"
|
||||||
|
MaxHeight="300"
|
||||||
|
Margin="0,0,0,24"
|
||||||
|
HorizontalScrollBarVisibility="Disabled"
|
||||||
|
VerticalScrollBarVisibility="Auto">
|
||||||
|
<TextBlock
|
||||||
|
x:Name="txtMessage"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
FontSize="14"
|
||||||
|
LineHeight="22"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
|
</ScrollViewer>
|
||||||
|
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="1"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Spacing="12">
|
||||||
|
<Button
|
||||||
|
x:Name="btnYes"
|
||||||
|
MinWidth="90"
|
||||||
|
HorizontalContentAlignment="Center"
|
||||||
|
Content="{x:Static resx:ResUI.TbConfirm}"
|
||||||
|
IsDefault="True" />
|
||||||
|
<Button
|
||||||
|
x:Name="btnNo"
|
||||||
|
MinWidth="90"
|
||||||
|
HorizontalContentAlignment="Center"
|
||||||
|
Content="{x:Static resx:ResUI.TbCancel}"
|
||||||
|
IsCancel="True" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
27
v2rayN/v2rayN.Desktop/Views/MessageBoxDialog.axaml.cs
Normal file
27
v2rayN/v2rayN.Desktop/Views/MessageBoxDialog.axaml.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
using v2rayN.Desktop.Common;
|
||||||
|
|
||||||
|
namespace v2rayN.Desktop.Views;
|
||||||
|
|
||||||
|
public partial class MessageBoxDialog : Window
|
||||||
|
{
|
||||||
|
public MessageBoxDialog(string caption, string message)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
Title = caption;
|
||||||
|
txtMessage.Text = message;
|
||||||
|
|
||||||
|
btnYes.Click += BtnYes_Click;
|
||||||
|
btnNo.Click += BtnNo_Click;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BtnYes_Click(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Close(ButtonResult.Yes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BtnNo_Click(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Close(ButtonResult.No);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -104,7 +104,8 @@ public partial class OptionSettingWindow : WindowBase<OptionSettingViewModel>
|
||||||
this.Bind(ViewModel, vm => vm.SpeedPingTestUrl, v => v.cmbSpeedPingTestUrl.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SpeedPingTestUrl, v => v.cmbSpeedPingTestUrl.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.MixedConcurrencyCount, v => v.cmbMixedConcurrencyCount.SelectedValue).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.MixedConcurrencyCount, v => v.cmbMixedConcurrencyCount.SelectedValue).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SubConvertUrl, v => v.cmbSubConvertUrl.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SubConvertUrl, v => v.cmbSubConvertUrl.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.MainGirdOrientation, v => v.cmbMainGirdOrientation.SelectedIndex).DisposeWith(disposables);
|
this.Bind<OptionSettingViewModel, OptionSettingWindow, int, int>(ViewModel,
|
||||||
|
vm => vm.MainGirdOrientation, view => view.cmbMainGirdOrientation.SelectedIndex).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.GeoFileSourceUrl, v => v.cmbGetFilesSourceUrl.SelectedValue).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.GeoFileSourceUrl, v => v.cmbGetFilesSourceUrl.SelectedValue).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SrsFileSourceUrl, v => v.cmbSrsFilesSourceUrl.SelectedValue).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SrsFileSourceUrl, v => v.cmbSrsFilesSourceUrl.SelectedValue).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.RoutingRulesSourceUrl, v => v.cmbRoutingRulesSourceUrl.SelectedValue).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.RoutingRulesSourceUrl, v => v.cmbRoutingRulesSourceUrl.SelectedValue).DisposeWith(disposables);
|
||||||
|
|
|
||||||
|
|
@ -20,24 +20,6 @@
|
||||||
<MenuItem x:Name="menuRoutingAdvancedImportRules2" Header="{x:Static resx:ResUI.menuRoutingAdvancedImportRules}" />
|
<MenuItem x:Name="menuRoutingAdvancedImportRules2" Header="{x:Static resx:ResUI.menuRoutingAdvancedImportRules}" />
|
||||||
</Menu>
|
</Menu>
|
||||||
|
|
||||||
<StackPanel
|
|
||||||
Margin="{StaticResource Margin4}"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
DockPanel.Dock="Bottom"
|
|
||||||
Orientation="Horizontal">
|
|
||||||
<Button
|
|
||||||
x:Name="btnSave"
|
|
||||||
Width="100"
|
|
||||||
Content="{x:Static resx:ResUI.TbConfirm}"
|
|
||||||
IsDefault="True" />
|
|
||||||
<Button
|
|
||||||
x:Name="btnCancel"
|
|
||||||
Width="100"
|
|
||||||
Margin="{StaticResource MarginLr8}"
|
|
||||||
Content="{x:Static resx:ResUI.TbCancel}"
|
|
||||||
IsCancel="True" />
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<Grid
|
<Grid
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
ColumnDefinitions="Auto,Auto"
|
ColumnDefinitions="Auto,Auto"
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,12 @@ namespace v2rayN.Desktop.Views;
|
||||||
|
|
||||||
public partial class RoutingSettingWindow : WindowBase<RoutingSettingViewModel>
|
public partial class RoutingSettingWindow : WindowBase<RoutingSettingViewModel>
|
||||||
{
|
{
|
||||||
private bool _manualClose = false;
|
|
||||||
|
|
||||||
public RoutingSettingWindow()
|
public RoutingSettingWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Loaded += Window_Loaded;
|
Loaded += Window_Loaded;
|
||||||
Closing += RoutingSettingWindow_Closing;
|
Closing += RoutingSettingWindow_Closing;
|
||||||
btnCancel.Click += (s, e) => Close();
|
|
||||||
KeyDown += RoutingSettingWindow_KeyDown;
|
KeyDown += RoutingSettingWindow_KeyDown;
|
||||||
lstRoutings.SelectionChanged += lstRoutings_SelectionChanged;
|
lstRoutings.SelectionChanged += lstRoutings_SelectionChanged;
|
||||||
lstRoutings.DoubleTapped += LstRoutings_DoubleTapped;
|
lstRoutings.DoubleTapped += LstRoutings_DoubleTapped;
|
||||||
|
|
@ -38,8 +35,6 @@ public partial class RoutingSettingWindow : WindowBase<RoutingSettingViewModel>
|
||||||
this.BindCommand(ViewModel, vm => vm.RoutingAdvancedSetDefaultCmd, v => v.menuRoutingAdvancedSetDefault).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.RoutingAdvancedSetDefaultCmd, v => v.menuRoutingAdvancedSetDefault).DisposeWith(disposables);
|
||||||
this.BindCommand(ViewModel, vm => vm.RoutingAdvancedImportRulesCmd, v => v.menuRoutingAdvancedImportRules).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.RoutingAdvancedImportRulesCmd, v => v.menuRoutingAdvancedImportRules).DisposeWith(disposables);
|
||||||
this.BindCommand(ViewModel, vm => vm.RoutingAdvancedImportRulesCmd, v => v.menuRoutingAdvancedImportRules2).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.RoutingAdvancedImportRulesCmd, v => v.menuRoutingAdvancedImportRules2).DisposeWith(disposables);
|
||||||
|
|
||||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,10 +42,6 @@ public partial class RoutingSettingWindow : WindowBase<RoutingSettingViewModel>
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case EViewAction.CloseWindow:
|
|
||||||
Close(true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EViewAction.ShowYesNo:
|
case EViewAction.ShowYesNo:
|
||||||
if (await UI.ShowYesNo(this, ResUI.RemoveRules) != ButtonResult.Yes)
|
if (await UI.ShowYesNo(this, ResUI.RemoveRules) != ButtonResult.Yes)
|
||||||
{
|
{
|
||||||
|
|
@ -69,6 +60,21 @@ public partial class RoutingSettingWindow : WindowBase<RoutingSettingViewModel>
|
||||||
return await Task.FromResult(true);
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _closed = false;
|
||||||
|
|
||||||
|
private void RoutingSettingWindow_Closing(object? sender, WindowClosingEventArgs e)
|
||||||
|
{
|
||||||
|
if (_closed) return;
|
||||||
|
|
||||||
|
// DomainStrategy is auto-saved reactively; just ensure the caller knows changes were made
|
||||||
|
if (ViewModel?.IsModified == true)
|
||||||
|
{
|
||||||
|
e.Cancel = true;
|
||||||
|
_closed = true;
|
||||||
|
Close(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void RoutingSettingWindow_KeyDown(object? sender, KeyEventArgs e)
|
private void RoutingSettingWindow_KeyDown(object? sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.KeyModifiers is KeyModifiers.Control or KeyModifiers.Meta)
|
if (e.KeyModifiers is KeyModifiers.Control or KeyModifiers.Meta)
|
||||||
|
|
@ -125,25 +131,7 @@ public partial class RoutingSettingWindow : WindowBase<RoutingSettingViewModel>
|
||||||
ProcUtils.ProcessStart("https://sing-box.sagernet.org/zh/configuration/route/rule_action/#strategy");
|
ProcUtils.ProcessStart("https://sing-box.sagernet.org/zh/configuration/route/rule_action/#strategy");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCancel_Click(object? sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
_manualClose = true;
|
|
||||||
Close(ViewModel?.IsModified);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RoutingSettingWindow_Closing(object? sender, WindowClosingEventArgs e)
|
|
||||||
{
|
|
||||||
if (ViewModel?.IsModified == true)
|
|
||||||
{
|
|
||||||
if (!_manualClose)
|
|
||||||
{
|
|
||||||
btnCancel_Click(null, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
btnCancel.Focus();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Avalonia.Desktop" />
|
<PackageReference Include="Avalonia.Desktop" />
|
||||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" />
|
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" />
|
||||||
|
<PackageReference Include="DialogHost.Avalonia" />
|
||||||
<PackageReference Include="ReactiveUI.Avalonia" />
|
<PackageReference Include="ReactiveUI.Avalonia" />
|
||||||
<PackageReference Include="MessageBox.Avalonia" />
|
|
||||||
<PackageReference Include="Semi.Avalonia" />
|
<PackageReference Include="Semi.Avalonia" />
|
||||||
<PackageReference Include="Semi.Avalonia.AvaloniaEdit" />
|
<PackageReference Include="Semi.Avalonia.AvaloniaEdit" />
|
||||||
<PackageReference Include="Semi.Avalonia.DataGrid">
|
<PackageReference Include="Semi.Avalonia.DataGrid">
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 18
|
||||||
VisualStudioVersion = 17.3.32811.315
|
VisualStudioVersion = 18.4.11620.152 stable
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "v2rayN", "v2rayN\v2rayN.csproj", "{6DE127CA-1763-4236-B297-D2EF9CB2EC9B}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "v2rayN", "v2rayN\v2rayN.csproj", "{6DE127CA-1763-4236-B297-D2EF9CB2EC9B}"
|
||||||
EndProject
|
EndProject
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="gridVMess"
|
x:Name="gridVMess"
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Visibility="Hidden">
|
Visibility="Collapsed">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
|
@ -234,7 +234,7 @@
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="gridSs"
|
x:Name="gridSs"
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Visibility="Hidden">
|
Visibility="Collapsed">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
|
@ -308,7 +308,7 @@
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="gridSocks"
|
x:Name="gridSocks"
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Visibility="Hidden">
|
Visibility="Collapsed">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
|
@ -353,7 +353,7 @@
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="gridVLESS"
|
x:Name="gridVLESS"
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Visibility="Hidden">
|
Visibility="Collapsed">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
|
@ -437,7 +437,7 @@
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="gridTrojan"
|
x:Name="gridTrojan"
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Visibility="Hidden">
|
Visibility="Collapsed">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
|
@ -497,7 +497,7 @@
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="gridHysteria2"
|
x:Name="gridHysteria2"
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Visibility="Hidden">
|
Visibility="Collapsed">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
|
@ -610,7 +610,7 @@
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="gridTuic"
|
x:Name="gridTuic"
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Visibility="Hidden">
|
Visibility="Collapsed">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
|
@ -670,7 +670,7 @@
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="gridWireguard"
|
x:Name="gridWireguard"
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Visibility="Hidden">
|
Visibility="Collapsed">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
|
@ -767,7 +767,7 @@
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="gridAnytls"
|
x:Name="gridAnytls"
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Visibility="Hidden">
|
Visibility="Collapsed">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
|
@ -796,7 +796,7 @@
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="gridNaive"
|
x:Name="gridNaive"
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Visibility="Hidden">
|
Visibility="Collapsed">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
|
@ -907,27 +907,21 @@
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
Style="{StaticResource ModuleTitle}"
|
||||||
|
Text="{x:Static resx:ResUI.GbTransport}" />
|
||||||
|
|
||||||
|
<Grid Grid.Row="1">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="300" />
|
<ColumnDefinition Width="300" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="0"
|
|
||||||
Grid.ColumnSpan="2"
|
|
||||||
Margin="{StaticResource Margin4}"
|
|
||||||
Style="{StaticResource ModuleTitle}"
|
|
||||||
Text="{x:Static resx:ResUI.GbTransport}" />
|
|
||||||
|
|
||||||
<TextBlock
|
|
||||||
Grid.Row="1"
|
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
|
|
@ -935,115 +929,336 @@
|
||||||
Text="{x:Static resx:ResUI.TbNetwork}" />
|
Text="{x:Static resx:ResUI.TbNetwork}" />
|
||||||
<ComboBox
|
<ComboBox
|
||||||
x:Name="cmbNetwork"
|
x:Name="cmbNetwork"
|
||||||
Grid.Row="1"
|
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Width="200"
|
Width="200"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
Style="{StaticResource DefComboBox}" />
|
Style="{StaticResource DefComboBox}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="1"
|
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Style="{StaticResource ToolbarTextBlock}"
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
Text="{x:Static resx:ResUI.TipNetwork}" />
|
Text="{x:Static resx:ResUI.TipNetwork}" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid Grid.Row="2">
|
||||||
|
<Grid x:Name="gridTransportRaw" Visibility="Collapsed">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<Grid Grid.Row="0">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="300" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="labHeaderType"
|
Grid.Row="0"
|
||||||
Grid.Row="2"
|
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Style="{StaticResource ToolbarTextBlock}"
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
Text="{x:Static resx:ResUI.TbHeaderType}" />
|
Text="{x:Static resx:ResUI.TransportHeaderType1}" />
|
||||||
<StackPanel
|
|
||||||
Grid.Row="2"
|
|
||||||
Grid.Column="1"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Orientation="Horizontal">
|
|
||||||
<ComboBox
|
<ComboBox
|
||||||
x:Name="cmbHeaderType"
|
x:Name="cmbHeaderTypeRaw"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
Width="200"
|
Width="200"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
Style="{StaticResource DefComboBox}" />
|
Style="{StaticResource DefComboBox}" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<materialDesign:PopupBox
|
<Grid
|
||||||
x:Name="popExtra"
|
x:Name="gridTransportRawHttp"
|
||||||
HorizontalAlignment="Right"
|
Grid.Row="1"
|
||||||
StaysOpen="True"
|
Visibility="Collapsed">
|
||||||
Style="{StaticResource MaterialDesignToolForegroundPopupBox}">
|
<Grid.ColumnDefinitions>
|
||||||
<StackPanel>
|
<ColumnDefinition Width="300" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Style="{StaticResource ToolbarTextBlock}"
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
Text="{x:Static resx:ResUI.TransportExtraTip}" />
|
Text="{x:Static resx:ResUI.TbCamouflageDomain}" />
|
||||||
<TextBox
|
<TextBox
|
||||||
x:Name="txtExtra"
|
x:Name="txtRequestHostRaw"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
Style="{StaticResource DefTextBox}" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
|
Text="{x:Static resx:ResUI.TbPath}" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtPathRaw"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
Style="{StaticResource DefTextBox}" />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid x:Name="gridTransportXhttp" Visibility="Collapsed">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="300" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
|
Text="{x:Static resx:ResUI.TransportHeaderType5}" />
|
||||||
|
<ComboBox
|
||||||
|
x:Name="cmbHeaderTypeXhttp"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="200"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
Style="{StaticResource DefComboBox}" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
|
Text="{x:Static resx:ResUI.TbHost}" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtRequestHostXhttp"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
Style="{StaticResource DefTextBox}" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="2"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
|
Text="{x:Static resx:ResUI.TbPath}" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtPathXhttp"
|
||||||
|
Grid.Row="2"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
Style="{StaticResource DefTextBox}" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="3"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
|
Text="{x:Static resx:ResUI.TransportExtra}"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtExtraXhttp"
|
||||||
|
Grid.Row="3"
|
||||||
|
Grid.Column="1"
|
||||||
Width="400"
|
Width="400"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
|
materialDesign:HintAssist.Hint="{x:Static resx:ResUI.TransportExtraTip}"
|
||||||
AcceptsReturn="True"
|
AcceptsReturn="True"
|
||||||
MinLines="6"
|
MaxLines="12"
|
||||||
|
MinLines="3"
|
||||||
Style="{StaticResource MyOutlinedTextBox}"
|
Style="{StaticResource MyOutlinedTextBox}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
</StackPanel>
|
</Grid>
|
||||||
</materialDesign:PopupBox>
|
|
||||||
</StackPanel>
|
<Grid x:Name="gridTransportKcp" Visibility="Collapsed">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="300" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
|
Text="{x:Static resx:ResUI.TransportHeaderType2}" />
|
||||||
|
<ComboBox
|
||||||
|
x:Name="cmbHeaderTypeKcp"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="200"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
Style="{StaticResource DefComboBox}" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
|
Text="Seed" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtKcpSeed"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
Style="{StaticResource DefTextBox}" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid x:Name="gridTransportGrpc" Visibility="Collapsed">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="300" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
|
Text="{x:Static resx:ResUI.TransportHeaderType4}" />
|
||||||
|
<ComboBox
|
||||||
|
x:Name="cmbHeaderTypeGrpc"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="200"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
Style="{StaticResource DefComboBox}" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
|
Text="{x:Static resx:ResUI.TransportRequestHostTip5}" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtRequestHostGrpc"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
Style="{StaticResource DefTextBox}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="tipHeaderType"
|
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Grid.Column="2"
|
|
||||||
Margin="{StaticResource Margin4}"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Style="{StaticResource ToolbarTextBlock}"
|
|
||||||
Text="{x:Static resx:ResUI.TbHeaderType}" />
|
|
||||||
|
|
||||||
<TextBlock
|
|
||||||
Grid.Row="3"
|
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Style="{StaticResource ToolbarTextBlock}"
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
Text="{x:Static resx:ResUI.TbRequestHost}" />
|
Text="{x:Static resx:ResUI.TransportPathTip4}" />
|
||||||
<TextBox
|
<TextBox
|
||||||
x:Name="txtRequestHost"
|
x:Name="txtPathGrpc"
|
||||||
Grid.Row="3"
|
Grid.Row="2"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
Style="{StaticResource DefTextBox}" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid x:Name="gridTransportWs" Visibility="Collapsed">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="300" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
|
Text="{x:Static resx:ResUI.TbHost}" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtRequestHostWs"
|
||||||
|
Grid.Row="0"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Width="400"
|
Width="400"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
Style="{StaticResource DefTextBox}" />
|
Style="{StaticResource DefTextBox}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="tipRequestHost"
|
Grid.Row="1"
|
||||||
Grid.Row="3"
|
|
||||||
Grid.Column="2"
|
|
||||||
Margin="{StaticResource Margin4}"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Style="{StaticResource ToolbarTextBlock}"
|
|
||||||
Text="{x:Static resx:ResUI.TbRequestHost}" />
|
|
||||||
|
|
||||||
<TextBlock
|
|
||||||
Grid.Row="4"
|
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Style="{StaticResource ToolbarTextBlock}"
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
Text="{x:Static resx:ResUI.TbPath}" />
|
Text="{x:Static resx:ResUI.TbPath}" />
|
||||||
<TextBox
|
<TextBox
|
||||||
x:Name="txtPath"
|
x:Name="txtPathWs"
|
||||||
Grid.Row="4"
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
Style="{StaticResource DefTextBox}" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid x:Name="gridTransportHttpupgrade" Visibility="Collapsed">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="300" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
|
Text="{x:Static resx:ResUI.TbHost}" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtRequestHostHttpupgrade"
|
||||||
|
Grid.Row="0"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Width="400"
|
Width="400"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
Style="{StaticResource DefTextBox}" />
|
Style="{StaticResource DefTextBox}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="tipPath"
|
Grid.Row="1"
|
||||||
Grid.Row="4"
|
Grid.Column="0"
|
||||||
Grid.Column="2"
|
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Style="{StaticResource ToolbarTextBlock}"
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
Text="{x:Static resx:ResUI.TbPath}" />
|
Text="{x:Static resx:ResUI.TbPath}" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtPathHttpupgrade"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
Style="{StaticResource DefTextBox}" />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid x:Name="gridFinalmask" Grid.Row="5">
|
<Grid x:Name="gridFinalmask" Grid.Row="5">
|
||||||
|
|
@ -1117,7 +1332,7 @@
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="gridTlsMore"
|
x:Name="gridTlsMore"
|
||||||
Grid.Row="8"
|
Grid.Row="8"
|
||||||
Visibility="Hidden">
|
Visibility="Collapsed">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
|
@ -1268,6 +1483,27 @@
|
||||||
Content="{x:Static resx:ResUI.TbFetchCertChain}"
|
Content="{x:Static resx:ResUI.TbFetchCertChain}"
|
||||||
Style="{StaticResource DefButton}" />
|
Style="{StaticResource DefButton}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
|
||||||
|
<TextBlock
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
|
Text="{x:Static resx:ResUI.TbAllowInsecureCertFetch}" />
|
||||||
|
<ToggleButton
|
||||||
|
x:Name="togAllowInsecureCertFetch"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
HorizontalAlignment="Left" />
|
||||||
|
</StackPanel>
|
||||||
|
<TextBlock
|
||||||
|
x:Name="txtAllowInsecureCertFetchTips"
|
||||||
|
Width="400"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Foreground="#FFD32F2F"
|
||||||
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
|
Text="{x:Static resx:ResUI.TbAllowInsecureCertFetchTips}"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Visibility="Collapsed" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Width="400"
|
Width="400"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
|
|
@ -1306,7 +1542,7 @@
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="gridRealityMore"
|
x:Name="gridRealityMore"
|
||||||
Grid.Row="8"
|
Grid.Row="8"
|
||||||
Visibility="Hidden">
|
Visibility="Collapsed">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ public partial class AddServerWindow
|
||||||
Owner = Application.Current.MainWindow;
|
Owner = Application.Current.MainWindow;
|
||||||
Loaded += Window_Loaded;
|
Loaded += Window_Loaded;
|
||||||
cmbNetwork.SelectionChanged += CmbNetwork_SelectionChanged;
|
cmbNetwork.SelectionChanged += CmbNetwork_SelectionChanged;
|
||||||
|
cmbHeaderTypeRaw.SelectionChanged += CmbHeaderTypeRaw_SelectionChanged;
|
||||||
cmbStreamSecurity.SelectionChanged += CmbStreamSecurity_SelectionChanged;
|
cmbStreamSecurity.SelectionChanged += CmbStreamSecurity_SelectionChanged;
|
||||||
btnGUID.Click += btnGUID_Click;
|
btnGUID.Click += btnGUID_Click;
|
||||||
btnGUID5.Click += btnGUID_Click;
|
btnGUID5.Click += btnGUID_Click;
|
||||||
|
|
@ -19,6 +20,20 @@ public partial class AddServerWindow
|
||||||
|
|
||||||
cmbCoreType.ItemsSource = Global.CoreTypes.AppendEmpty();
|
cmbCoreType.ItemsSource = Global.CoreTypes.AppendEmpty();
|
||||||
cmbNetwork.ItemsSource = Global.Networks;
|
cmbNetwork.ItemsSource = Global.Networks;
|
||||||
|
if (ViewModel.SelectedSource.Network.IsNullOrEmpty() || !Global.Networks.Contains(ViewModel.SelectedSource.Network))
|
||||||
|
{
|
||||||
|
ViewModel.SelectedSource.Network = Global.DefaultNetwork;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmbHeaderTypeRaw.ItemsSource = new List<string> { Global.None, Global.RawHeaderHttp };
|
||||||
|
|
||||||
|
var kcpHeaderTypes = new List<string> { Global.None };
|
||||||
|
kcpHeaderTypes.AddRange(Global.KcpHeaderTypes);
|
||||||
|
cmbHeaderTypeKcp.ItemsSource = kcpHeaderTypes;
|
||||||
|
|
||||||
|
cmbHeaderTypeXhttp.ItemsSource = Global.XhttpMode;
|
||||||
|
cmbHeaderTypeGrpc.ItemsSource = new List<string> { Global.GrpcGunMode, Global.GrpcMultiMode };
|
||||||
|
|
||||||
cmbFingerprint.ItemsSource = Global.Fingerprints;
|
cmbFingerprint.ItemsSource = Global.Fingerprints;
|
||||||
cmbFingerprint2.ItemsSource = Global.Fingerprints;
|
cmbFingerprint2.ItemsSource = Global.Fingerprints;
|
||||||
cmbAllowInsecure.ItemsSource = Global.AllowInsecure;
|
cmbAllowInsecure.ItemsSource = Global.AllowInsecure;
|
||||||
|
|
@ -114,7 +129,7 @@ public partial class AddServerWindow
|
||||||
}
|
}
|
||||||
cmbStreamSecurity.ItemsSource = lstStreamSecurity;
|
cmbStreamSecurity.ItemsSource = lstStreamSecurity;
|
||||||
|
|
||||||
gridTlsMore.Visibility = Visibility.Hidden;
|
gridTlsMore.Visibility = Visibility.Collapsed;
|
||||||
|
|
||||||
this.WhenActivated(disposables =>
|
this.WhenActivated(disposables =>
|
||||||
{
|
{
|
||||||
|
|
@ -195,10 +210,27 @@ public partial class AddServerWindow
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.Network, v => v.cmbNetwork.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.Network, v => v.cmbNetwork.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.RawHeaderType, v => v.cmbHeaderTypeRaw.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.RequestHost, v => v.txtRequestHost.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.Host, v => v.txtRequestHostRaw.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.Path, v => v.txtPathRaw.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.Extra, v => v.txtExtra.Text).DisposeWith(disposables);
|
|
||||||
|
this.Bind(ViewModel, vm => vm.KcpHeaderType, v => v.cmbHeaderTypeKcp.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.KcpSeed, v => v.txtKcpSeed.Text).DisposeWith(disposables);
|
||||||
|
|
||||||
|
this.Bind(ViewModel, vm => vm.Host, v => v.txtRequestHostWs.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.Path, v => v.txtPathWs.Text).DisposeWith(disposables);
|
||||||
|
|
||||||
|
this.Bind(ViewModel, vm => vm.Host, v => v.txtRequestHostHttpupgrade.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.Path, v => v.txtPathHttpupgrade.Text).DisposeWith(disposables);
|
||||||
|
|
||||||
|
this.Bind(ViewModel, vm => vm.XhttpMode, v => v.cmbHeaderTypeXhttp.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.Host, v => v.txtRequestHostXhttp.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.Path, v => v.txtPathXhttp.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.XhttpExtra, v => v.txtExtraXhttp.Text).DisposeWith(disposables);
|
||||||
|
|
||||||
|
this.Bind(ViewModel, vm => vm.GrpcMode, v => v.cmbHeaderTypeGrpc.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.GrpcAuthority, v => v.txtRequestHostGrpc.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.GrpcServiceName, v => v.txtPathGrpc.Text).DisposeWith(disposables);
|
||||||
|
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.StreamSecurity, v => v.cmbStreamSecurity.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.StreamSecurity, v => v.cmbStreamSecurity.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI.Text).DisposeWith(disposables);
|
||||||
|
|
@ -208,6 +240,10 @@ public partial class AddServerWindow
|
||||||
this.Bind(ViewModel, vm => vm.CertSha, v => v.txtCertSha256Pinning.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.CertSha, v => v.txtCertSha256Pinning.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.CertTip, v => v.labCertPinning.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.CertTip, v => v.labCertPinning.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.Cert, v => v.txtCert.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.Cert, v => v.txtCert.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.AllowInsecureCertFetch, v => v.togAllowInsecureCertFetch.IsChecked).DisposeWith(disposables);
|
||||||
|
this.WhenAnyValue(x => x.ViewModel.AllowInsecureCertFetch)
|
||||||
|
.Select(b => b ? Visibility.Visible : Visibility.Collapsed)
|
||||||
|
.BindTo(this, v => v.txtAllowInsecureCertFetchTips.Visibility);
|
||||||
this.Bind(ViewModel, vm => vm.Cert, v => v.txtCert.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.Cert, v => v.txtCert.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.EchConfigList, v => v.txtEchConfigList.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.EchConfigList, v => v.txtEchConfigList.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.EchForceQuery, v => v.cmbEchForceQuery.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.EchForceQuery, v => v.cmbEchForceQuery.Text).DisposeWith(disposables);
|
||||||
|
|
@ -249,8 +285,12 @@ public partial class AddServerWindow
|
||||||
|
|
||||||
private void CmbNetwork_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void CmbNetwork_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
SetHeaderType();
|
SetTransportGridVisibility();
|
||||||
SetTips();
|
}
|
||||||
|
|
||||||
|
private void CmbHeaderTypeRaw_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
SetRawHttpFieldsVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CmbStreamSecurity_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void CmbStreamSecurity_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
|
@ -259,17 +299,17 @@ public partial class AddServerWindow
|
||||||
if (security == Global.StreamSecurityReality)
|
if (security == Global.StreamSecurityReality)
|
||||||
{
|
{
|
||||||
gridRealityMore.Visibility = Visibility.Visible;
|
gridRealityMore.Visibility = Visibility.Visible;
|
||||||
gridTlsMore.Visibility = Visibility.Hidden;
|
gridTlsMore.Visibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
else if (security == Global.StreamSecurity)
|
else if (security == Global.StreamSecurity)
|
||||||
{
|
{
|
||||||
gridRealityMore.Visibility = Visibility.Hidden;
|
gridRealityMore.Visibility = Visibility.Collapsed;
|
||||||
gridTlsMore.Visibility = Visibility.Visible;
|
gridTlsMore.Visibility = Visibility.Visible;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gridRealityMore.Visibility = Visibility.Hidden;
|
gridRealityMore.Visibility = Visibility.Collapsed;
|
||||||
gridTlsMore.Visibility = Visibility.Hidden;
|
gridTlsMore.Visibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -279,102 +319,62 @@ public partial class AddServerWindow
|
||||||
txtId5.Text = Utils.GetGuid();
|
txtId5.Text = Utils.GetGuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetHeaderType()
|
private void SetTransportGridVisibility()
|
||||||
{
|
{
|
||||||
var lstHeaderType = new List<string>();
|
var network = cmbNetwork.SelectedItem?.ToString();
|
||||||
|
|
||||||
var network = cmbNetwork.SelectedItem.ToString();
|
|
||||||
if (network.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
lstHeaderType.Add(Global.None);
|
|
||||||
cmbHeaderType.ItemsSource = lstHeaderType;
|
|
||||||
cmbHeaderType.SelectedIndex = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (network == nameof(ETransport.tcp))
|
|
||||||
{
|
|
||||||
lstHeaderType.Add(Global.None);
|
|
||||||
lstHeaderType.Add(Global.TcpHeaderHttp);
|
|
||||||
}
|
|
||||||
else if (network is nameof(ETransport.kcp) or nameof(ETransport.quic))
|
|
||||||
{
|
|
||||||
lstHeaderType.Add(Global.None);
|
|
||||||
lstHeaderType.AddRange(Global.KcpHeaderTypes);
|
|
||||||
}
|
|
||||||
else if (network is nameof(ETransport.xhttp))
|
|
||||||
{
|
|
||||||
lstHeaderType.AddRange(Global.XhttpMode);
|
|
||||||
}
|
|
||||||
else if (network == nameof(ETransport.grpc))
|
|
||||||
{
|
|
||||||
lstHeaderType.Add(Global.GrpcGunMode);
|
|
||||||
lstHeaderType.Add(Global.GrpcMultiMode);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lstHeaderType.Add(Global.None);
|
|
||||||
}
|
|
||||||
cmbHeaderType.ItemsSource = lstHeaderType;
|
|
||||||
cmbHeaderType.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetTips()
|
|
||||||
{
|
|
||||||
var network = cmbNetwork.SelectedItem.ToString();
|
|
||||||
if (network.IsNullOrEmpty())
|
if (network.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
network = Global.DefaultNetwork;
|
network = Global.DefaultNetwork;
|
||||||
}
|
}
|
||||||
labHeaderType.Visibility = Visibility.Visible;
|
|
||||||
popExtra.Visibility = Visibility.Hidden;
|
gridTransportRaw.Visibility = Visibility.Collapsed;
|
||||||
tipRequestHost.Text =
|
gridTransportKcp.Visibility = Visibility.Collapsed;
|
||||||
tipPath.Text =
|
gridTransportWs.Visibility = Visibility.Collapsed;
|
||||||
tipHeaderType.Text = string.Empty;
|
gridTransportHttpupgrade.Visibility = Visibility.Collapsed;
|
||||||
|
gridTransportXhttp.Visibility = Visibility.Collapsed;
|
||||||
|
gridTransportGrpc.Visibility = Visibility.Collapsed;
|
||||||
|
|
||||||
switch (network)
|
switch (network)
|
||||||
{
|
{
|
||||||
case nameof(ETransport.tcp):
|
case nameof(ETransport.raw):
|
||||||
tipRequestHost.Text = ResUI.TransportRequestHostTip1;
|
gridTransportRaw.Visibility = Visibility.Visible;
|
||||||
tipHeaderType.Text = ResUI.TransportHeaderTypeTip1;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.kcp):
|
case nameof(ETransport.kcp):
|
||||||
tipHeaderType.Text = ResUI.TransportHeaderTypeTip2;
|
gridTransportKcp.Visibility = Visibility.Visible;
|
||||||
tipPath.Text = ResUI.TransportPathTip5;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.ws):
|
case nameof(ETransport.ws):
|
||||||
|
gridTransportWs.Visibility = Visibility.Visible;
|
||||||
|
break;
|
||||||
case nameof(ETransport.httpupgrade):
|
case nameof(ETransport.httpupgrade):
|
||||||
tipRequestHost.Text = ResUI.TransportRequestHostTip2;
|
gridTransportHttpupgrade.Visibility = Visibility.Visible;
|
||||||
tipPath.Text = ResUI.TransportPathTip1;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.xhttp):
|
case nameof(ETransport.xhttp):
|
||||||
tipRequestHost.Text = ResUI.TransportRequestHostTip2;
|
gridTransportXhttp.Visibility = Visibility.Visible;
|
||||||
tipPath.Text = ResUI.TransportPathTip1;
|
|
||||||
tipHeaderType.Text = ResUI.TransportHeaderTypeTip5;
|
|
||||||
labHeaderType.Visibility = Visibility.Hidden;
|
|
||||||
popExtra.Visibility = Visibility.Visible;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.h2):
|
|
||||||
tipRequestHost.Text = ResUI.TransportRequestHostTip3;
|
|
||||||
tipPath.Text = ResUI.TransportPathTip2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case nameof(ETransport.quic):
|
|
||||||
tipRequestHost.Text = ResUI.TransportRequestHostTip4;
|
|
||||||
tipPath.Text = ResUI.TransportPathTip3;
|
|
||||||
tipHeaderType.Text = ResUI.TransportHeaderTypeTip3;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case nameof(ETransport.grpc):
|
case nameof(ETransport.grpc):
|
||||||
tipRequestHost.Text = ResUI.TransportRequestHostTip5;
|
gridTransportGrpc.Visibility = Visibility.Visible;
|
||||||
tipPath.Text = ResUI.TransportPathTip4;
|
break;
|
||||||
tipHeaderType.Text = ResUI.TransportHeaderTypeTip4;
|
default:
|
||||||
labHeaderType.Visibility = Visibility.Hidden;
|
gridTransportRaw.Visibility = Visibility.Visible;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetRawHttpFieldsVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetRawHttpFieldsVisibility()
|
||||||
|
{
|
||||||
|
var network = cmbNetwork.SelectedItem?.ToString();
|
||||||
|
if (network.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
network = Global.DefaultNetwork;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rawHeaderType = cmbHeaderTypeRaw.SelectedItem?.ToString();
|
||||||
|
var showRawHttpFields = network == nameof(ETransport.raw)
|
||||||
|
&& rawHeaderType == Global.RawHeaderHttp;
|
||||||
|
gridTransportRawHttp.Visibility = showRawHttpFields
|
||||||
|
? Visibility.Visible
|
||||||
|
: Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -453,9 +453,16 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
|
|
||||||
|
<Grid Margin="{StaticResource Margin8}">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="1*" />
|
||||||
|
<ColumnDefinition Width="10" />
|
||||||
|
<ColumnDefinition Width="1*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<TextBox
|
<TextBox
|
||||||
x:Name="txtnormalDNSCompatible"
|
x:Name="txtnormalDNSCompatible"
|
||||||
Margin="{StaticResource Margin8}"
|
Grid.Column="0"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
materialDesign:HintAssist.Hint="HTTP/SOCKS"
|
materialDesign:HintAssist.Hint="HTTP/SOCKS"
|
||||||
AcceptsReturn="True"
|
AcceptsReturn="True"
|
||||||
|
|
@ -463,6 +470,20 @@
|
||||||
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
VerticalScrollBarVisibility="Auto" />
|
VerticalScrollBarVisibility="Auto" />
|
||||||
|
|
||||||
|
<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
|
||||||
|
|
||||||
|
<TextBox
|
||||||
|
x:Name="txttunDNSCompatible"
|
||||||
|
Grid.Column="2"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
materialDesign:HintAssist.Hint="{x:Static resx:ResUI.TbSettingsTunMode}"
|
||||||
|
AcceptsReturn="True"
|
||||||
|
BorderThickness="1"
|
||||||
|
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
VerticalScrollBarVisibility="Auto" />
|
||||||
|
</Grid>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ public partial class DNSSettingWindow
|
||||||
this.Bind(ViewModel, vm => vm.DomainStrategy4FreedomCompatible, v => v.cmbdomainStrategy4FreedomCompatible.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.DomainStrategy4FreedomCompatible, v => v.cmbdomainStrategy4FreedomCompatible.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.DomainDNSAddressCompatible, v => v.cmbdomainDNSAddressCompatible.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.DomainDNSAddressCompatible, v => v.cmbdomainDNSAddressCompatible.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.NormalDNSCompatible, v => v.txtnormalDNSCompatible.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.NormalDNSCompatible, v => v.txtnormalDNSCompatible.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.TunDNSCompatible, v => v.txttunDNSCompatible.Text).DisposeWith(disposables);
|
||||||
|
|
||||||
this.Bind(ViewModel, vm => vm.DomainStrategy4Freedom2Compatible, v => v.cmbdomainStrategy4OutCompatible.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.DomainStrategy4Freedom2Compatible, v => v.cmbdomainStrategy4OutCompatible.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.DomainDNSAddress2Compatible, v => v.cmbdomainDNSAddress2Compatible.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.DomainDNSAddress2Compatible, v => v.cmbdomainDNSAddress2Compatible.Text).DisposeWith(disposables);
|
||||||
|
|
|
||||||
|
|
@ -107,9 +107,16 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
|
|
||||||
|
<Grid Margin="{StaticResource Margin8}">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="1*" />
|
||||||
|
<ColumnDefinition Width="10" />
|
||||||
|
<ColumnDefinition Width="1*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<TextBox
|
<TextBox
|
||||||
x:Name="rayFullConfigTemplate"
|
x:Name="rayFullConfigTemplate"
|
||||||
Margin="{StaticResource Margin8}"
|
Grid.Column="0"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
materialDesign:HintAssist.Hint="xray config template json"
|
materialDesign:HintAssist.Hint="xray config template json"
|
||||||
AcceptsReturn="True"
|
AcceptsReturn="True"
|
||||||
|
|
@ -117,6 +124,20 @@
|
||||||
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
VerticalScrollBarVisibility="Auto" />
|
VerticalScrollBarVisibility="Auto" />
|
||||||
|
|
||||||
|
<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
|
||||||
|
|
||||||
|
<TextBox
|
||||||
|
x:Name="rayFullTunConfigTemplate"
|
||||||
|
Grid.Column="2"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
materialDesign:HintAssist.Hint="xray tun config template json"
|
||||||
|
AcceptsReturn="True"
|
||||||
|
BorderThickness="1"
|
||||||
|
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
VerticalScrollBarVisibility="Auto" />
|
||||||
|
</Grid>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem HorizontalAlignment="Left" Header="{x:Static resx:ResUI.TbSBFullConfigTemplate}">
|
<TabItem HorizontalAlignment="Left" Header="{x:Static resx:ResUI.TbSBFullConfigTemplate}">
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ public partial class FullConfigTemplateWindow
|
||||||
{
|
{
|
||||||
this.Bind(ViewModel, vm => vm.EnableFullConfigTemplate4Ray, v => v.rayFullConfigTemplateEnable.IsChecked).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.EnableFullConfigTemplate4Ray, v => v.rayFullConfigTemplateEnable.IsChecked).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.FullConfigTemplate4Ray, v => v.rayFullConfigTemplate.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.FullConfigTemplate4Ray, v => v.rayFullConfigTemplate.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.FullTunConfigTemplate4Ray, v => v.rayFullTunConfigTemplate.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.AddProxyOnly4Ray, v => v.togAddProxyProtocolOutboundOnly4Ray.IsChecked).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.AddProxyOnly4Ray, v => v.togAddProxyProtocolOutboundOnly4Ray.IsChecked).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.ProxyDetour4Ray, v => v.txtProxyDetour4Ray.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.ProxyDetour4Ray, v => v.txtProxyDetour4Ray.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.EnableFullConfigTemplate4Singbox, v => v.sbFullConfigTemplateEnable.IsChecked).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.EnableFullConfigTemplate4Singbox, v => v.sbFullConfigTemplateEnable.IsChecked).DisposeWith(disposables);
|
||||||
|
|
|
||||||
|
|
@ -52,26 +52,6 @@
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
</ToolBarTray>
|
</ToolBarTray>
|
||||||
|
|
||||||
<StackPanel
|
|
||||||
Margin="{StaticResource Margin8}"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
DockPanel.Dock="Bottom"
|
|
||||||
Orientation="Horizontal">
|
|
||||||
<Button
|
|
||||||
x:Name="btnSave"
|
|
||||||
Width="100"
|
|
||||||
Content="{x:Static resx:ResUI.TbConfirm}"
|
|
||||||
IsDefault="True"
|
|
||||||
Style="{StaticResource DefButton}" />
|
|
||||||
<Button
|
|
||||||
x:Name="btnCancel"
|
|
||||||
Width="100"
|
|
||||||
Margin="{StaticResource MarginLeftRight8}"
|
|
||||||
Content="{x:Static resx:ResUI.TbCancel}"
|
|
||||||
IsCancel="true"
|
|
||||||
Style="{StaticResource DefButton}" />
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<Grid Margin="{StaticResource Margin8}" DockPanel.Dock="Top">
|
<Grid Margin="{StaticResource Margin8}" DockPanel.Dock="Top">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ public partial class RoutingSettingWindow
|
||||||
lstRoutings.SelectionChanged += lstRoutings_SelectionChanged;
|
lstRoutings.SelectionChanged += lstRoutings_SelectionChanged;
|
||||||
lstRoutings.MouseDoubleClick += LstRoutings_MouseDoubleClick;
|
lstRoutings.MouseDoubleClick += LstRoutings_MouseDoubleClick;
|
||||||
menuRoutingAdvancedSelectAll.Click += menuRoutingAdvancedSelectAll_Click;
|
menuRoutingAdvancedSelectAll.Click += menuRoutingAdvancedSelectAll_Click;
|
||||||
btnCancel.Click += btnCancel_Click;
|
|
||||||
|
|
||||||
ViewModel = new RoutingSettingViewModel(UpdateViewHandler);
|
ViewModel = new RoutingSettingViewModel(UpdateViewHandler);
|
||||||
|
|
||||||
|
|
@ -33,8 +32,6 @@ public partial class RoutingSettingWindow
|
||||||
this.BindCommand(ViewModel, vm => vm.RoutingAdvancedSetDefaultCmd, v => v.menuRoutingAdvancedSetDefault).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.RoutingAdvancedSetDefaultCmd, v => v.menuRoutingAdvancedSetDefault).DisposeWith(disposables);
|
||||||
this.BindCommand(ViewModel, vm => vm.RoutingAdvancedImportRulesCmd, v => v.menuRoutingAdvancedImportRules).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.RoutingAdvancedImportRulesCmd, v => v.menuRoutingAdvancedImportRules).DisposeWith(disposables);
|
||||||
this.BindCommand(ViewModel, vm => vm.RoutingAdvancedImportRulesCmd, v => v.menuRoutingAdvancedImportRules2).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.RoutingAdvancedImportRulesCmd, v => v.menuRoutingAdvancedImportRules2).DisposeWith(disposables);
|
||||||
|
|
||||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
|
||||||
});
|
});
|
||||||
WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme);
|
WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme);
|
||||||
}
|
}
|
||||||
|
|
@ -43,10 +40,6 @@ public partial class RoutingSettingWindow
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case EViewAction.CloseWindow:
|
|
||||||
DialogResult = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EViewAction.ShowYesNo:
|
case EViewAction.ShowYesNo:
|
||||||
if (UI.ShowYesNo(ResUI.RemoveRules) == MessageBoxResult.No)
|
if (UI.ShowYesNo(ResUI.RemoveRules) == MessageBoxResult.No)
|
||||||
{
|
{
|
||||||
|
|
@ -68,6 +61,7 @@ public partial class RoutingSettingWindow
|
||||||
|
|
||||||
private void RoutingSettingWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e)
|
private void RoutingSettingWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||||
{
|
{
|
||||||
|
// DomainStrategy is auto-saved reactively; just ensure the caller knows changes were made
|
||||||
if (ViewModel?.IsModified == true)
|
if (ViewModel?.IsModified == true)
|
||||||
{
|
{
|
||||||
DialogResult = true;
|
DialogResult = true;
|
||||||
|
|
@ -129,16 +123,4 @@ public partial class RoutingSettingWindow
|
||||||
{
|
{
|
||||||
ProcUtils.ProcessStart("https://sing-box.sagernet.org/zh/configuration/route/rule_action/#strategy");
|
ProcUtils.ProcessStart("https://sing-box.sagernet.org/zh/configuration/route/rule_action/#strategy");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCancel_Click(object sender, System.Windows.RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
if (ViewModel?.IsModified == true)
|
|
||||||
{
|
|
||||||
DialogResult = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue