mirror of
https://github.com/netchx/netch.git
synced 2026-05-11 23:45:06 +08:00
Compare commits
76 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d8bbe3518 | ||
|
|
e9f0a5b2f8 | ||
|
|
9d086336ea | ||
|
|
b31bedbc82 | ||
|
|
7f15042c03 | ||
|
|
2c4728f13c | ||
|
|
a2f5c9ab27 | ||
|
|
583bf31c92 | ||
|
|
0275b7718f | ||
|
|
0a226fab22 | ||
|
|
77680e2c02 | ||
|
|
2afc5ff21a | ||
|
|
4f4882d7f7 | ||
|
|
41fdf94a16 | ||
|
|
a3e8826105 | ||
|
|
b7bcb46c78 | ||
|
|
5e27b6a1eb | ||
|
|
a5903f5f57 | ||
|
|
39eb1b4eef | ||
|
|
23bcac0d5d | ||
|
|
38480776f0 | ||
|
|
bcccb80ece | ||
|
|
513d0b01a7 | ||
|
|
a3d309113c | ||
|
|
e77a40966c | ||
|
|
670cb06e4a | ||
|
|
59b4ba578b | ||
|
|
5ed25de9ee | ||
|
|
464abef28a | ||
|
|
79a7273af2 | ||
|
|
7d44821e57 | ||
|
|
ca3502a284 | ||
|
|
415fc5fa8f | ||
|
|
cfd458ffbd | ||
|
|
3be5f10ed8 | ||
|
|
41479275da | ||
|
|
639fcf9575 | ||
|
|
1eebb61d04 | ||
|
|
a2a66675c2 | ||
|
|
850393ab71 | ||
|
|
ea0dd3cd4a | ||
|
|
c2afc1b014 | ||
|
|
7b9d9a6d57 | ||
|
|
860482402a | ||
|
|
a58f7c7b98 | ||
|
|
6afc5e5e4d | ||
|
|
98a5e91dd2 | ||
|
|
9581a41007 | ||
|
|
d85b478868 | ||
|
|
628dd6963a | ||
|
|
5ae6f73062 | ||
|
|
50b07ebabb | ||
|
|
21f2f8da5e | ||
|
|
cfc070b1ef | ||
|
|
a4f024df69 | ||
|
|
6754268714 | ||
|
|
642cd57b71 | ||
|
|
39ea679298 | ||
|
|
1091486877 | ||
|
|
d805a4fccd | ||
|
|
902f78b563 | ||
|
|
159fbdd58d | ||
|
|
0c5464f833 | ||
|
|
b019362f5f | ||
|
|
241371c6f7 | ||
|
|
9b3f5f456f | ||
|
|
c04b8f6ffd | ||
|
|
9d6b6d15d7 | ||
|
|
39081c0a6f | ||
|
|
812fab6322 | ||
|
|
bfadb181c4 | ||
|
|
52ac05ee17 | ||
|
|
c774122fdb | ||
|
|
8e223faa71 | ||
|
|
7b0f0f35cc | ||
|
|
89ce721d4c |
@@ -6,4 +6,54 @@ root = true
|
||||
# all files
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
indent_size = 4
|
||||
tab_width = 4
|
||||
|
||||
# Microsoft .NET properties
|
||||
csharp_new_line_before_members_in_object_initializers = false
|
||||
csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion
|
||||
csharp_style_var_elsewhere = true:suggestion
|
||||
csharp_style_var_for_built_in_types = true:suggestion
|
||||
csharp_style_var_when_type_is_apparent = true:suggestion
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none
|
||||
dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:none
|
||||
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
|
||||
dotnet_style_predefined_type_for_member_access = true:suggestion
|
||||
dotnet_style_qualification_for_event = false:suggestion
|
||||
dotnet_style_qualification_for_field = false:suggestion
|
||||
dotnet_style_qualification_for_method = false:suggestion
|
||||
dotnet_style_qualification_for_property = false:suggestion
|
||||
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
|
||||
|
||||
# ReSharper properties
|
||||
resharper_blank_lines_after_block_statements = 0
|
||||
resharper_csharp_blank_lines_around_field = 0
|
||||
resharper_csharp_blank_lines_around_invocable = 0
|
||||
resharper_csharp_blank_lines_around_type = 0
|
||||
resharper_csharp_int_align_comments = true
|
||||
resharper_csharp_max_line_length = 368
|
||||
resharper_csharp_wrap_lines = false
|
||||
resharper_place_expr_accessor_on_single_line = true
|
||||
resharper_place_expr_method_on_single_line = true
|
||||
resharper_place_field_attribute_on_same_line = false
|
||||
resharper_place_simple_embedded_statement_on_same_line = false
|
||||
resharper_place_simple_initializer_on_single_line = false
|
||||
resharper_use_indent_from_vs = false
|
||||
resharper_wrap_array_initializer_style = chop_if_long
|
||||
resharper_wrap_object_and_collection_initializer_style = chop_always
|
||||
|
||||
# ReSharper inspection severities
|
||||
resharper_arrange_redundant_parentheses_highlighting = hint
|
||||
resharper_arrange_this_qualifier_highlighting = hint
|
||||
resharper_arrange_type_member_modifiers_highlighting = hint
|
||||
resharper_arrange_type_modifiers_highlighting = hint
|
||||
resharper_built_in_type_reference_style_for_member_access_highlighting = hint
|
||||
resharper_built_in_type_reference_style_highlighting = hint
|
||||
resharper_redundant_base_qualifier_highlighting = warning
|
||||
resharper_suggest_var_or_type_built_in_types_highlighting = hint
|
||||
resharper_suggest_var_or_type_elsewhere_highlighting = hint
|
||||
resharper_suggest_var_or_type_simple_types_highlighting = hint
|
||||
resharper_web_config_module_not_resolved_highlighting = warning
|
||||
resharper_web_config_type_not_resolved_highlighting = warning
|
||||
resharper_web_config_wrong_module_highlighting = warning
|
||||
|
||||
4
.github/ISSUE_TEMPLATE/bug_report.md
vendored
4
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -2,15 +2,13 @@
|
||||
name: 'Bug report'
|
||||
about: 'Create a report to help us improve'
|
||||
title: ''
|
||||
labels: 'Status: Review Needed'
|
||||
labels: '需要核实'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Make sure you have read the readme, searched and read the issues related to yours. Otherwise it will be considered as a duplicate which will be closed immediately.**
|
||||
|
||||
**All issues about `bin/Redirector.exe` should be discussed at [issue #152](https://github.com/NetchX/Netch/issues/152).**
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
|
||||
4
.github/ISSUE_TEMPLATE/bug_report.zh-CN.md
vendored
4
.github/ISSUE_TEMPLATE/bug_report.zh-CN.md
vendored
@@ -2,15 +2,13 @@
|
||||
name: '错误报告'
|
||||
about: '创建错误报告以帮助我们改进'
|
||||
title: ''
|
||||
labels: 'Status: Review Needed'
|
||||
labels: '需要核实'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**确保你已经看过 readme,也搜索并阅读过和你遇到的情况相关的问题。否则会被认为是重复的并被立刻关闭。**
|
||||
|
||||
**所有关于 `bin/Redirector.exe` 的问题,请在 [issue #152](https://github.com/NetchX/Netch/issues/152) 中讨论**
|
||||
|
||||
**错误描述**
|
||||
对错误的清晰简洁描述
|
||||
|
||||
|
||||
43
.github/workflows/build.yml
vendored
43
.github/workflows/build.yml
vendored
@@ -14,26 +14,32 @@ jobs:
|
||||
submodules: true
|
||||
|
||||
- name: Build Solution
|
||||
shell: pwsh
|
||||
run: .\BUILD.ps1
|
||||
|
||||
- name: Upload Artifact
|
||||
continue-on-error: true
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Netch
|
||||
path: Netch\bin\x64\Release
|
||||
|
||||
- name: Package
|
||||
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
.\BUILD.ps1
|
||||
New-Item -ItemType Directory -Path C:\builtfiles -Force > $null
|
||||
7z a -mx9 C:\builtfiles\Netch.7z .\Netch\bin\x64\Release\
|
||||
7z rn C:\builtfiles\Netch.7z Release Netch
|
||||
echo "Netch_SHA256=$(.\GetSHA256.ps1 C:\builtfiles\Netch.7z)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "Netch_EXE_SHA256=$(.\GetSHA256.ps1 Netch\bin\x64\Release\Netch.exe)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Netch
|
||||
path: Netch\bin\x64\Release
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
|
||||
with:
|
||||
name: ${{ env.GITHUB_TAG_NAME }}
|
||||
prerelease: true
|
||||
@@ -49,23 +55,4 @@ jobs:
|
||||
## 校验和
|
||||
| 文件名 | SHA256 |
|
||||
| :- | :- |
|
||||
| Netch.7z | ${{ env.Netch_SHA256 }} |
|
||||
|
||||
# Deploy:
|
||||
# needs: [build]
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - name: Download Artifacts
|
||||
# uses: actions/download-artifact@v1
|
||||
# with:
|
||||
# name: Netch
|
||||
|
||||
# - name: Pushes to another repository
|
||||
# uses: peaceiris/actions-gh-pages@v3
|
||||
# with:
|
||||
# personal_token: ${{ secrets.ACCESS_TOKEN }}
|
||||
# publish_branch: repo
|
||||
# publish_dir: ./Netch
|
||||
# external_repository: ${{ github.repository_owner }}/NetchReleases
|
||||
# user_name: 'github-actions[bot]'
|
||||
# user_email: 'github-actions[bot]@users.noreply.github.com'
|
||||
| Netch.7z | ${{ env.Netch_SHA256 }} |
|
||||
13
Netch.sln
13
Netch.sln
@@ -5,11 +5,11 @@ VisualStudioVersion = 16.0.29009.5
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Netch", "Netch\Netch.csproj", "{4B041B91-5790-4571-8C58-C63FFE4BC9F8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetchLib", "NetchLib\NetchLib.csproj", "{A8715AF4-ACC6-43F9-9381-4294C5360623}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetchLib", "NetchLib\NetchLib.csproj", "{A8715AF4-ACC6-43F9-9381-4294C5360623}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetchUpdater", "NetchUpdater\NetchUpdater.csproj", "{828318A8-9B90-4A5F-BD6B-E632CC9D8933}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetchUpdater", "NetchUpdater\NetchUpdater.csproj", "{828318A8-9B90-4A5F-BD6B-E632CC9D8933}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{53397641-35CA-4336-8E22-2CE12EF476AC}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "Test\Test.csproj", "{53397641-35CA-4336-8E22-2CE12EF476AC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -29,10 +29,9 @@ Global
|
||||
{828318A8-9B90-4A5F-BD6B-E632CC9D8933}.Debug|x64.Build.0 = Debug|x64
|
||||
{828318A8-9B90-4A5F-BD6B-E632CC9D8933}.Release|x64.ActiveCfg = Release|x64
|
||||
{828318A8-9B90-4A5F-BD6B-E632CC9D8933}.Release|x64.Build.0 = Release|x64
|
||||
{53397641-35CA-4336-8E22-2CE12EF476AC}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{53397641-35CA-4336-8E22-2CE12EF476AC}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{53397641-35CA-4336-8E22-2CE12EF476AC}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{53397641-35CA-4336-8E22-2CE12EF476AC}.Release|x64.Build.0 = Release|Any CPU
|
||||
{53397641-35CA-4336-8E22-2CE12EF476AC}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{53397641-35CA-4336-8E22-2CE12EF476AC}.Debug|x64.Build.0 = Debug|x64
|
||||
{53397641-35CA-4336-8E22-2CE12EF476AC}.Release|x64.ActiveCfg = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
@@ -31,7 +31,10 @@ namespace Netch.Controllers
|
||||
|
||||
try
|
||||
{
|
||||
pPrivoxyController.Start(MainController.ServerController.Server, mode);
|
||||
if (pPrivoxyController.Start(MainController.Server, mode))
|
||||
{
|
||||
Global.Job.AddProcess(pPrivoxyController.Instance);
|
||||
}
|
||||
|
||||
if (mode.Type == 3) NativeMethods.SetGlobal($"127.0.0.1:{Global.Settings.HTTPLocalPort}", IEProxyExceptions);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ namespace Netch.Controllers
|
||||
{
|
||||
public interface IServerController : IController
|
||||
{
|
||||
public Server Server { get; set; }
|
||||
|
||||
public ushort? Socks5LocalPort { get; set; }
|
||||
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
@@ -18,6 +18,8 @@ namespace Netch.Controllers
|
||||
private set => _serverController = value;
|
||||
}
|
||||
|
||||
/// TCP or Both Server
|
||||
public static Server Server;
|
||||
public static IModeController ModeController { get; private set; }
|
||||
|
||||
public static bool NttTested;
|
||||
@@ -34,6 +36,7 @@ namespace Netch.Controllers
|
||||
public static async Task<bool> Start(Server server, Mode mode)
|
||||
{
|
||||
Logging.Info($"启动主控制器: {server.Type} [{mode.Type}]{mode.Remark}");
|
||||
Server = server;
|
||||
|
||||
if (server is Socks5 && mode.Type == 4)
|
||||
{
|
||||
@@ -64,17 +67,22 @@ namespace Netch.Controllers
|
||||
|
||||
try
|
||||
{
|
||||
if (!await Task.Run(() => StartServer(server, mode, ref _serverController)))
|
||||
if (!ModeHelper.SkipServerController(server, mode))
|
||||
{
|
||||
if (!await Task.Run(() => StartServer(server, mode, ref _serverController)))
|
||||
{
|
||||
throw new StartFailedException();
|
||||
}
|
||||
|
||||
StatusPortInfoText.UpdateShareLan();
|
||||
}
|
||||
|
||||
if (!await StartMode(mode))
|
||||
{
|
||||
throw new StartFailedException();
|
||||
}
|
||||
|
||||
if (!await StartMode(server, mode))
|
||||
{
|
||||
throw new StartFailedException();
|
||||
}
|
||||
|
||||
if (mode.TestNatRequired)
|
||||
if (mode.TestNatRequired())
|
||||
NatTest();
|
||||
|
||||
return true;
|
||||
@@ -122,8 +130,23 @@ namespace Netch.Controllers
|
||||
Global.MainForm.StatusText(i18N.TranslateFormat("Starting {0}", controller.Name));
|
||||
if (controller.Start(in server, mode))
|
||||
{
|
||||
UsingPorts.Add(StatusPortInfoText.Socks5Port = controller.Socks5LocalPort());
|
||||
StatusPortInfoText.ShareLan = controller.LocalAddress == "0.0.0.0";
|
||||
if (controller is Guard guard)
|
||||
{
|
||||
if (guard.Instance != null)
|
||||
{
|
||||
Global.Job.AddProcess(guard.Instance);
|
||||
}
|
||||
}
|
||||
|
||||
if (server is Socks5 socks5)
|
||||
{
|
||||
if (socks5.Auth())
|
||||
UsingPorts.Add(StatusPortInfoText.Socks5Port = controller.Socks5LocalPort());
|
||||
}
|
||||
else
|
||||
{
|
||||
UsingPorts.Add(StatusPortInfoText.Socks5Port = controller.Socks5LocalPort());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -131,22 +154,36 @@ namespace Netch.Controllers
|
||||
return false;
|
||||
}
|
||||
|
||||
private static async Task<bool> StartMode(Server server, Mode mode)
|
||||
private static async Task<bool> StartMode(Mode mode)
|
||||
{
|
||||
ModeController = ModeHelper.GetModeControllerByType(mode.Type, out var port, out var portName, out var portType);
|
||||
|
||||
if (ModeController == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (port != null)
|
||||
{
|
||||
PortCheckAndShowMessageBox((ushort) port, portName, portType);
|
||||
UsingPorts.Add((ushort) port);
|
||||
}
|
||||
|
||||
if (ModeController != null)
|
||||
Global.MainForm.StatusText(i18N.TranslateFormat("Starting {0}", ModeController.Name));
|
||||
if (await Task.Run(() => ModeController.Start(mode)))
|
||||
{
|
||||
Global.MainForm.StatusText(i18N.TranslateFormat("Starting {0}", ModeController.Name));
|
||||
return await Task.Run(() => ModeController.Start(mode));
|
||||
if (ModeController is Guard guard)
|
||||
{
|
||||
if (guard.Instance != null)
|
||||
{
|
||||
Global.Job.AddProcess(guard.Instance);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -178,7 +215,7 @@ namespace Netch.Controllers
|
||||
/// <param name="portName">端口用途名称</param>
|
||||
/// <param name="portType"></param>
|
||||
/// <exception cref="PortInUseException"></exception>
|
||||
private static void PortCheckAndShowMessageBox(ushort port, string portName, PortType portType = PortType.Both)
|
||||
public static void PortCheckAndShowMessageBox(ushort port, string portName, PortType portType = PortType.Both)
|
||||
{
|
||||
if (PortInUse(port, portType))
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@ using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.ServiceProcess;
|
||||
using System.Threading.Tasks;
|
||||
using Netch.Forms;
|
||||
using Netch.Models;
|
||||
using Netch.Servers.Shadowsocks;
|
||||
using Netch.Servers.Socks5;
|
||||
using Netch.Utils;
|
||||
using nfapinet;
|
||||
@@ -49,33 +49,35 @@ namespace Netch.Controllers
|
||||
|
||||
public bool Start(in Mode mode)
|
||||
{
|
||||
var binFileVersion = Utils.Utils.GetFileVersion(BinDriver);
|
||||
var systemFileVersion = Utils.Utils.GetFileVersion(SystemDriver);
|
||||
if (!CheckDriver())
|
||||
return false;
|
||||
|
||||
Logging.Info("内置驱动版本: " + binFileVersion);
|
||||
Logging.Info("系统驱动版本: " + systemFileVersion);
|
||||
|
||||
if (!systemFileVersion.Equals(binFileVersion))
|
||||
{
|
||||
if (File.Exists(SystemDriver))
|
||||
{
|
||||
Logging.Info("更新驱动");
|
||||
UninstallDriver();
|
||||
}
|
||||
|
||||
if (!InstallDriver())
|
||||
return false;
|
||||
}
|
||||
#region aio_dial
|
||||
|
||||
aio_dial((int) NameList.TYPE_FILTERLOOPBACK, "false");
|
||||
aio_dial((int) NameList.TYPE_FILTERTCP, "true");
|
||||
aio_dial((int) NameList.TYPE_FILTERUDP, "true");
|
||||
aio_dial((int) NameList.TYPE_TCPLISN, Global.Settings.RedirectorTCPPort.ToString());
|
||||
aio_dial((int)NameList.TYPE_TCPLISN, Global.Settings.RedirectorTCPPort.ToString());
|
||||
if (Global.Settings.ProcessNoProxyForUdp)
|
||||
{
|
||||
aio_dial((int)NameList.TYPE_FILTERUDP, "false");
|
||||
SetServer(MainController.ServerController, PortType.TCP);
|
||||
}
|
||||
else
|
||||
{
|
||||
aio_dial((int)NameList.TYPE_FILTERUDP, "true");
|
||||
SetServer(MainController.ServerController, PortType.Both);
|
||||
}
|
||||
|
||||
SetServer(MainController.ServerController, PortType.Both);
|
||||
if (!CheckRule(mode.FullRule, out var list))
|
||||
{
|
||||
MessageBoxX.Show($"\"{string.Join("", list.Select(s => s + "\n"))}\" does not conform to C++ regular expression syntax");
|
||||
return false;
|
||||
}
|
||||
|
||||
SetName(mode);
|
||||
|
||||
#endregion
|
||||
|
||||
if (Global.Settings.ModifySystemDNS)
|
||||
{
|
||||
// 备份并替换系统 DNS
|
||||
@@ -88,6 +90,100 @@ namespace Netch.Controllers
|
||||
return aio_init();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="rules"></param>
|
||||
/// <param name="incompatibleRule"></param>
|
||||
/// <returns>No Problem true</returns>
|
||||
public static bool CheckRule(IEnumerable<string> rules, out IEnumerable<string> incompatibleRule)
|
||||
{
|
||||
incompatibleRule = rules.Where(r => !CheckCppRegex(r, false));
|
||||
aio_dial((int) NameList.TYPE_CLRNAME, "");
|
||||
return !incompatibleRule.Any();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="r"></param>
|
||||
/// <param name="clear"></param>
|
||||
/// <returns>No Problem true</returns>
|
||||
public static bool CheckCppRegex(string r, bool clear = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (r.StartsWith("!"))
|
||||
return aio_dial((int) NameList.TYPE_ADDNAME, r.Substring(1));
|
||||
return aio_dial((int) NameList.TYPE_ADDNAME, r);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (clear)
|
||||
aio_dial((int) NameList.TYPE_CLRNAME, "");
|
||||
}
|
||||
}
|
||||
|
||||
private static bool CheckDriver()
|
||||
{
|
||||
var binFileVersion = Utils.Utils.GetFileVersion(BinDriver);
|
||||
var systemFileVersion = Utils.Utils.GetFileVersion(SystemDriver);
|
||||
|
||||
Logging.Info("内置驱动版本: " + binFileVersion);
|
||||
Logging.Info("系统驱动版本: " + systemFileVersion);
|
||||
|
||||
if (!File.Exists(BinDriver))
|
||||
{
|
||||
Logging.Warning("内置驱动不存在");
|
||||
if (File.Exists(SystemDriver))
|
||||
{
|
||||
Logging.Warning("使用系统驱动");
|
||||
return true;
|
||||
}
|
||||
|
||||
Logging.Error("未安装驱动");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!File.Exists(SystemDriver))
|
||||
{
|
||||
return InstallDriver();
|
||||
}
|
||||
|
||||
var updateFlag = false;
|
||||
|
||||
if (Version.TryParse(binFileVersion, out var binResult) && Version.TryParse(systemFileVersion, out var systemResult))
|
||||
{
|
||||
if (binResult.CompareTo(systemResult) > 0)
|
||||
{
|
||||
// Bin greater than Installed
|
||||
updateFlag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Installed greater than Bin
|
||||
if (systemResult.Major != binResult.Major)
|
||||
{
|
||||
// API breaking changes
|
||||
updateFlag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!systemFileVersion.Equals(binFileVersion))
|
||||
{
|
||||
updateFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!updateFlag) return true;
|
||||
|
||||
Logging.Info("更新驱动");
|
||||
UninstallDriver();
|
||||
return InstallDriver();
|
||||
}
|
||||
|
||||
private void SetServer(in IServerController controller, in PortType portType)
|
||||
{
|
||||
if (portType == PortType.Both)
|
||||
@@ -99,22 +195,29 @@ namespace Netch.Controllers
|
||||
|
||||
var offset = portType == PortType.UDP ? UdpNameListOffset : 0;
|
||||
|
||||
aio_dial((int) NameList.TYPE_TCPTYPE + offset, "Socks5");
|
||||
|
||||
if (controller.Server is Socks5 socks5)
|
||||
if (MainController.Server is Socks5 socks5)
|
||||
{
|
||||
aio_dial((int) NameList.TYPE_TCPTYPE + offset, "Socks5");
|
||||
aio_dial((int) NameList.TYPE_TCPHOST + offset, $"{socks5.AutoResolveHostname()}:{socks5.Port}");
|
||||
aio_dial((int) NameList.TYPE_TCPUSER + offset, socks5.Username ?? string.Empty);
|
||||
aio_dial((int) NameList.TYPE_TCPPASS + offset, socks5.Password ?? string.Empty);
|
||||
aio_dial((int) NameList.TYPE_TCPMETH + offset, string.Empty);
|
||||
}
|
||||
else if (MainController.Server is Shadowsocks shadowsocks && !shadowsocks.HasPlugin() && Global.Settings.RedirectorSS)
|
||||
{
|
||||
aio_dial((int) NameList.TYPE_TCPTYPE + offset, "Shadowsocks");
|
||||
aio_dial((int) NameList.TYPE_TCPHOST + offset, $"{shadowsocks.AutoResolveHostname()}:{shadowsocks.Port}");
|
||||
aio_dial((int) NameList.TYPE_TCPMETH + offset, shadowsocks.EncryptMethod ?? string.Empty);
|
||||
aio_dial((int) NameList.TYPE_TCPPASS + offset, shadowsocks.Password ?? string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
aio_dial((int) NameList.TYPE_TCPTYPE + offset, "Socks5");
|
||||
aio_dial((int) NameList.TYPE_TCPHOST + offset, $"127.0.0.1:{controller.Socks5LocalPort()}");
|
||||
aio_dial((int) NameList.TYPE_TCPUSER + offset, string.Empty);
|
||||
aio_dial((int) NameList.TYPE_TCPPASS + offset, string.Empty);
|
||||
aio_dial((int) NameList.TYPE_TCPMETH + offset, string.Empty);
|
||||
}
|
||||
|
||||
aio_dial((int) NameList.TYPE_TCPMETH + offset, string.Empty);
|
||||
}
|
||||
|
||||
private void SetName(Mode mode)
|
||||
@@ -122,10 +225,16 @@ namespace Netch.Controllers
|
||||
aio_dial((int) NameList.TYPE_CLRNAME, "");
|
||||
foreach (var rule in mode.FullRule)
|
||||
{
|
||||
if (rule.StartsWith("!"))
|
||||
{
|
||||
aio_dial((int) NameList.TYPE_BYPNAME, rule.Substring(1));
|
||||
continue;
|
||||
}
|
||||
|
||||
aio_dial((int) NameList.TYPE_ADDNAME, rule);
|
||||
}
|
||||
|
||||
aio_dial((int) NameList.TYPE_ADDNAME, "NTT.exe");
|
||||
aio_dial((int) NameList.TYPE_ADDNAME, @"NTT\.exe");
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
@@ -145,19 +254,19 @@ namespace Netch.Controllers
|
||||
private const int UdpNameListOffset = (int) NameList.TYPE_UDPTYPE - (int) NameList.TYPE_TCPTYPE;
|
||||
|
||||
[DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool aio_dial(int name, [MarshalAs(UnmanagedType.LPWStr)] string value);
|
||||
private static extern bool aio_dial(int name, [MarshalAs(UnmanagedType.LPWStr)] string value);
|
||||
|
||||
[DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool aio_init();
|
||||
private static extern bool aio_init();
|
||||
|
||||
[DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool aio_free();
|
||||
private static extern bool aio_free();
|
||||
|
||||
[DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern ulong aio_getUP();
|
||||
private static extern ulong aio_getUP();
|
||||
|
||||
[DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern ulong aio_getDL();
|
||||
private static extern ulong aio_getDL();
|
||||
|
||||
|
||||
public enum NameList : int
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Netch.Utils;
|
||||
|
||||
@@ -7,10 +8,6 @@ namespace Netch.Controllers
|
||||
{
|
||||
public class NTTController : Guard, IController
|
||||
{
|
||||
private string _localEnd;
|
||||
private string _publicEnd;
|
||||
private string _result;
|
||||
private string _bindingTest;
|
||||
public override string Name { get; protected set; } = "NTT";
|
||||
public override string MainFile { get; protected set; } = "NTT.exe";
|
||||
|
||||
@@ -20,7 +17,10 @@ namespace Netch.Controllers
|
||||
/// <returns></returns>
|
||||
public (string, string, string) Start()
|
||||
{
|
||||
_result = _localEnd = _publicEnd = null;
|
||||
string localEnd=null;
|
||||
string publicEnd=null;
|
||||
string result =null;
|
||||
string bindingTest=null;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -28,12 +28,50 @@ namespace Netch.Controllers
|
||||
Instance.OutputDataReceived += OnOutputDataReceived;
|
||||
Instance.ErrorDataReceived += OnOutputDataReceived;
|
||||
Instance.Start();
|
||||
Instance.BeginOutputReadLine();
|
||||
Instance.BeginErrorReadLine();
|
||||
Instance.WaitForExit();
|
||||
if (_bindingTest == "Fail")
|
||||
_result = "UdpBlocked";
|
||||
return (_result, _localEnd, _publicEnd);
|
||||
var output = Instance.StandardOutput.ReadToEnd();
|
||||
try
|
||||
{
|
||||
File.WriteAllText(Path.Combine(Global.NetchDir, $"logging\\{Name}.log"), output);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logging.Warning($"写入 {Name} 日志错误:\n" + e.Message);
|
||||
}
|
||||
|
||||
foreach (var line in output.Split('\n'))
|
||||
{
|
||||
var str = line.Split(':').Select(s => s.Trim()).ToArray();
|
||||
if (str.Length < 2)
|
||||
continue;
|
||||
var key = str[0];
|
||||
var value = str[1];
|
||||
switch (key)
|
||||
{
|
||||
case "Other address is":
|
||||
case "Nat mapping behavior":
|
||||
case "Nat filtering behavior":
|
||||
break;
|
||||
case "Binding test":
|
||||
bindingTest = value;
|
||||
break;
|
||||
case "Local address":
|
||||
localEnd = value;
|
||||
break;
|
||||
case "Mapped address":
|
||||
publicEnd = value;
|
||||
break;
|
||||
case "result":
|
||||
result = value;
|
||||
break;
|
||||
default:
|
||||
result = str.Last();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bindingTest == "Fail")
|
||||
result = "UdpBlocked";
|
||||
return (result, localEnd, publicEnd);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -51,41 +89,6 @@ namespace Netch.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private new void OnOutputDataReceived(object sender, DataReceivedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(e.Data)) return;
|
||||
Logging.Info($"[NTT] {e.Data}");
|
||||
|
||||
var str = e.Data.Split(':').Select(s => s.Trim()).ToArray();
|
||||
if (str.Length < 2)
|
||||
return;
|
||||
var key = str[0];
|
||||
var value = str[1];
|
||||
switch (key)
|
||||
{
|
||||
case "Other address is":
|
||||
case "Nat mapping behavior":
|
||||
case "Nat filtering behavior":
|
||||
break;
|
||||
case "Binding test":
|
||||
_bindingTest = value;
|
||||
break;
|
||||
case "Local address":
|
||||
_localEnd = value;
|
||||
break;
|
||||
case "Mapped address":
|
||||
_publicEnd = value;
|
||||
break;
|
||||
case "result":
|
||||
_result = value;
|
||||
break;
|
||||
default:
|
||||
_result = str.Last();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Stop()
|
||||
{
|
||||
StopInstance();
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Netch.Models;
|
||||
using Netch.Servers.Socks5;
|
||||
using Netch.Utils;
|
||||
@@ -17,9 +15,7 @@ namespace Netch.Controllers
|
||||
{
|
||||
public class TUNTAPController : Guard, IModeController
|
||||
{
|
||||
private Mode _savedMode = new Mode();
|
||||
private Server _savedServer = new Server();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 服务器 IP 地址
|
||||
/// </summary>
|
||||
@@ -41,11 +37,9 @@ namespace Netch.Controllers
|
||||
|
||||
public bool Start(in Mode mode)
|
||||
{
|
||||
_savedMode = mode;
|
||||
_savedServer = MainController.ServerController.Server;
|
||||
|
||||
var server = MainController.Server;
|
||||
// 查询服务器 IP 地址
|
||||
_serverAddresses = DNS.Lookup(_savedServer.Hostname);
|
||||
_serverAddresses = DNS.Lookup(server.Hostname);
|
||||
|
||||
// 查找出口适配器
|
||||
if (!Utils.Utils.SearchOutboundAdapter())
|
||||
@@ -66,7 +60,9 @@ namespace Netch.Controllers
|
||||
}
|
||||
|
||||
|
||||
SetupRouteTable();
|
||||
SetupRouteTable(mode);
|
||||
|
||||
Global.MainForm.StatusText(i18N.TranslateFormat("Starting {0}", Name));
|
||||
|
||||
string dns;
|
||||
if (Global.Settings.TUNTAP.UseCustomDNS)
|
||||
@@ -83,13 +79,27 @@ namespace Netch.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
var _ = DNSController.Start();
|
||||
try
|
||||
{
|
||||
MainController.PortCheckAndShowMessageBox(53, "DNS");
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!DNSController.Start())
|
||||
{
|
||||
Logging.Error("AioDNS 启动失败");
|
||||
return false;
|
||||
}
|
||||
|
||||
dns = "127.0.0.1";
|
||||
}
|
||||
|
||||
var argument = new StringBuilder();
|
||||
if (_savedServer is Socks5 socks5 && !socks5.Auth())
|
||||
argument.Append($"-proxyServer {_serverAddresses}:{_savedServer.Port} ");
|
||||
if (server is Socks5 socks5 && !socks5.Auth())
|
||||
argument.Append($"-proxyServer {server.AutoResolveHostname()}:{server.Port} ");
|
||||
else
|
||||
argument.Append($"-proxyServer 127.0.0.1:{Global.Settings.Socks5LocalPort} ");
|
||||
|
||||
@@ -124,73 +134,75 @@ namespace Netch.Controllers
|
||||
/// 设置绕行规则
|
||||
/// </summary>
|
||||
/// <returns>是否设置成功</returns>
|
||||
private void SetupRouteTable()
|
||||
private void SetupRouteTable(Mode mode)
|
||||
{
|
||||
Global.MainForm.StatusText(i18N.Translate("SetupBypass"));
|
||||
Logging.Info("设置路由规则");
|
||||
|
||||
#region Rule IPs
|
||||
|
||||
if (_savedMode.Type == 1)
|
||||
switch (mode.Type)
|
||||
{
|
||||
// 代理规则
|
||||
Logging.Info("代理 → 规则 IP");
|
||||
RouteAction(Action.Create, _savedMode.FullRule, RouteType.TUNTAP);
|
||||
case 1:
|
||||
// 代理规则
|
||||
Logging.Info("代理 → 规则 IP");
|
||||
RouteAction(Action.Create, mode.FullRule, RouteType.TUNTAP);
|
||||
|
||||
//处理 NAT 类型检测,由于协议的原因,无法仅通过域名确定需要代理的 IP,自己记录解析了返回的 IP,仅支持默认检测服务器
|
||||
if (Global.Settings.STUN_Server == "stun.stunprotocol.org")
|
||||
{
|
||||
try
|
||||
//处理 NAT 类型检测,由于协议的原因,无法仅通过域名确定需要代理的 IP,自己记录解析了返回的 IP,仅支持默认检测服务器
|
||||
if (Global.Settings.STUN_Server == "stun.stunprotocol.org")
|
||||
{
|
||||
Logging.Info("代理 → STUN 服务器 IP");
|
||||
RouteAction(Action.Create,
|
||||
new[]
|
||||
{
|
||||
Dns.GetHostAddresses(Global.Settings.STUN_Server)[0],
|
||||
Dns.GetHostAddresses("stunresponse.coldthunder11.com")[0]
|
||||
}.Select(ip => $"{ip}/32"),
|
||||
RouteType.TUNTAP);
|
||||
try
|
||||
{
|
||||
Logging.Info("代理 → STUN 服务器 IP");
|
||||
RouteAction(Action.Create,
|
||||
new[]
|
||||
{
|
||||
Dns.GetHostAddresses(Global.Settings.STUN_Server)[0],
|
||||
Dns.GetHostAddresses("stunresponse.coldthunder11.com")[0]
|
||||
}.Select(ip => $"{ip}/32"),
|
||||
RouteType.TUNTAP);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Logging.Info("NAT 类型测试域名解析失败,将不会被添加到代理列表");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Logging.Info("NAT 类型测试域名解析失败,将不会被添加到代理列表");
|
||||
}
|
||||
}
|
||||
|
||||
if (Global.Settings.TUNTAP.ProxyDNS)
|
||||
{
|
||||
Logging.Info("代理 → 自定义 DNS");
|
||||
if (Global.Settings.TUNTAP.UseCustomDNS)
|
||||
if (Global.Settings.TUNTAP.ProxyDNS)
|
||||
{
|
||||
RouteAction(Action.Create,
|
||||
Global.Settings.TUNTAP.DNS.Select(ip => $"{ip}/32"),
|
||||
RouteType.TUNTAP);
|
||||
Logging.Info("代理 → 自定义 DNS");
|
||||
if (Global.Settings.TUNTAP.UseCustomDNS)
|
||||
{
|
||||
RouteAction(Action.Create,
|
||||
Global.Settings.TUNTAP.DNS.Select(ip => $"{ip}/32"),
|
||||
RouteType.TUNTAP);
|
||||
}
|
||||
else
|
||||
{
|
||||
RouteAction(Action.Create,
|
||||
new[] {"1.1.1.1", "8.8.8.8", "9.9.9.9", "185.222.222.222"}.Select(ip => $"{ip}/32"),
|
||||
RouteType.TUNTAP);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RouteAction(Action.Create,
|
||||
new[] {"1.1.1.1", "8.8.8.8", "9.9.9.9", "185.222.222.222"}.Select(ip => $"{ip}/32"),
|
||||
RouteType.TUNTAP);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_savedMode.Type == 2)
|
||||
{
|
||||
// 绕过规则
|
||||
|
||||
// 将 TUN/TAP 网卡权重放到最高
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "netsh",
|
||||
Arguments = $"interface ip set interface {Global.TUNTAP.Index} metric=0",
|
||||
WindowStyle = ProcessWindowStyle.Hidden,
|
||||
UseShellExecute = true,
|
||||
CreateNoWindow = true
|
||||
}
|
||||
);
|
||||
break;
|
||||
case 2:
|
||||
// 绕过规则
|
||||
|
||||
Logging.Info("绕行 → 规则 IP");
|
||||
RouteAction(Action.Create, _savedMode.FullRule, RouteType.Outbound);
|
||||
// 将 TUN/TAP 网卡权重放到最高
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "netsh",
|
||||
Arguments = $"interface ip set interface {Global.TUNTAP.Index} metric=0",
|
||||
WindowStyle = ProcessWindowStyle.Hidden,
|
||||
UseShellExecute = true,
|
||||
CreateNoWindow = true
|
||||
}
|
||||
);
|
||||
|
||||
Logging.Info("绕行 → 规则 IP");
|
||||
RouteAction(Action.Create, mode.FullRule, RouteType.Outbound);
|
||||
break;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -202,7 +214,7 @@ namespace Netch.Controllers
|
||||
Logging.Info("绕行 → 全局绕过 IP");
|
||||
RouteAction(Action.Create, Global.Settings.BypassIPs, RouteType.Outbound);
|
||||
|
||||
if (_savedMode.Type == 2)
|
||||
if (mode.Type == 2)
|
||||
{
|
||||
// 绕过规则
|
||||
Logging.Info("代理 → 全局");
|
||||
@@ -226,33 +238,11 @@ namespace Netch.Controllers
|
||||
|
||||
public bool TestFakeDNS()
|
||||
{
|
||||
var exited = false;
|
||||
var helpStr = new StringBuilder();
|
||||
try
|
||||
{
|
||||
void OnOutputDataReceived(object sender, DataReceivedEventArgs e)
|
||||
{
|
||||
if (e.Data == null)
|
||||
{
|
||||
exited = true;
|
||||
return;
|
||||
}
|
||||
|
||||
helpStr.Append(e.Data);
|
||||
}
|
||||
|
||||
InitInstance("-h");
|
||||
// Instance.OutputDataReceived += OnOutputDataReceived;
|
||||
Instance.ErrorDataReceived += OnOutputDataReceived;
|
||||
Instance.Start();
|
||||
Instance.BeginOutputReadLine();
|
||||
Instance.BeginErrorReadLine();
|
||||
while (!exited)
|
||||
{
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
|
||||
return helpStr.ToString().Contains("-fakeDns");
|
||||
return Instance.StandardError.ReadToEnd().Contains("-fakeDns");
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using Netch.Models.GitHubRelease;
|
||||
using Netch.Utils;
|
||||
@@ -15,14 +16,14 @@ namespace Netch.Controllers
|
||||
public const string Name = @"Netch";
|
||||
public const string Copyright = @"Copyright © 2019 - 2020";
|
||||
|
||||
public const string AssemblyVersion = @"1.6.5";
|
||||
public const string AssemblyVersion = @"1.6.8";
|
||||
private const string Suffix = @"";
|
||||
|
||||
public static readonly string Version = $"{AssemblyVersion}{(string.IsNullOrEmpty(Suffix) ? "" : $"-{Suffix}")}";
|
||||
|
||||
public string LatestVersionNumber;
|
||||
public string LatestVersionUrl;
|
||||
public string LatestVersionDownloadUrl;
|
||||
public Release LatestRelease;
|
||||
|
||||
public event EventHandler NewVersionFound;
|
||||
public event EventHandler NewVersionFoundFailed;
|
||||
@@ -38,12 +39,11 @@ namespace Netch.Controllers
|
||||
var json = await WebUtil.DownloadStringAsync(WebUtil.CreateRequest(url));
|
||||
|
||||
var releases = JsonConvert.DeserializeObject<List<Release>>(json);
|
||||
var latestRelease = VersionUtil.GetLatestRelease(releases, isPreRelease);
|
||||
LatestVersionNumber = latestRelease.tag_name;
|
||||
LatestVersionUrl = latestRelease.html_url;
|
||||
LatestVersionDownloadUrl = latestRelease.assets[0].browser_download_url;
|
||||
Logging.Info($"Github 最新发布版本: {latestRelease.tag_name}");
|
||||
if (VersionUtil.CompareVersion(latestRelease.tag_name, Version) > 0)
|
||||
LatestRelease = VersionUtil.GetLatestRelease(releases, isPreRelease);
|
||||
LatestVersionNumber = LatestRelease.tag_name;
|
||||
LatestVersionUrl = LatestRelease.html_url;
|
||||
Logging.Info($"Github 最新发布版本: {LatestRelease.tag_name}");
|
||||
if (VersionUtil.CompareVersion(LatestRelease.tag_name, Version) > 0)
|
||||
{
|
||||
Logging.Info("发现新版本");
|
||||
NewVersionFound?.Invoke(this, new EventArgs());
|
||||
|
||||
6
Netch/Forms/MainForm.Designer.cs
generated
6
Netch/Forms/MainForm.Designer.cs
generated
@@ -441,6 +441,7 @@
|
||||
this.EditServerPictureBox.Location = new System.Drawing.Point(3, 3);
|
||||
this.EditServerPictureBox.Name = "EditServerPictureBox";
|
||||
this.EditServerPictureBox.Size = new System.Drawing.Size(16, 16);
|
||||
this.EditServerPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.EditServerPictureBox.TabIndex = 7;
|
||||
this.EditServerPictureBox.TabStop = false;
|
||||
this.EditServerPictureBox.Click += new System.EventHandler(this.EditServerPictureBox_Click);
|
||||
@@ -452,6 +453,7 @@
|
||||
this.CopyLinkPictureBox.Location = new System.Drawing.Point(72, 3);
|
||||
this.CopyLinkPictureBox.Name = "CopyLinkPictureBox";
|
||||
this.CopyLinkPictureBox.Size = new System.Drawing.Size(18, 18);
|
||||
this.CopyLinkPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.CopyLinkPictureBox.TabIndex = 14;
|
||||
this.CopyLinkPictureBox.TabStop = false;
|
||||
this.CopyLinkPictureBox.Click += new System.EventHandler(this.CopyLinkPictureBox_Click);
|
||||
@@ -463,6 +465,7 @@
|
||||
this.DeleteServerPictureBox.Location = new System.Drawing.Point(26, 3);
|
||||
this.DeleteServerPictureBox.Name = "DeleteServerPictureBox";
|
||||
this.DeleteServerPictureBox.Size = new System.Drawing.Size(16, 16);
|
||||
this.DeleteServerPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.DeleteServerPictureBox.TabIndex = 8;
|
||||
this.DeleteServerPictureBox.TabStop = false;
|
||||
this.DeleteServerPictureBox.Click += new System.EventHandler(this.DeleteServerPictureBox_Click);
|
||||
@@ -474,6 +477,7 @@
|
||||
this.SpeedPictureBox.Location = new System.Drawing.Point(49, 3);
|
||||
this.SpeedPictureBox.Name = "SpeedPictureBox";
|
||||
this.SpeedPictureBox.Size = new System.Drawing.Size(16, 16);
|
||||
this.SpeedPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.SpeedPictureBox.TabIndex = 9;
|
||||
this.SpeedPictureBox.TabStop = false;
|
||||
this.SpeedPictureBox.Click += new System.EventHandler(this.SpeedPictureBox_Click);
|
||||
@@ -501,6 +505,7 @@
|
||||
this.EditModePictureBox.Location = new System.Drawing.Point(3, 3);
|
||||
this.EditModePictureBox.Name = "EditModePictureBox";
|
||||
this.EditModePictureBox.Size = new System.Drawing.Size(16, 16);
|
||||
this.EditModePictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.EditModePictureBox.TabIndex = 12;
|
||||
this.EditModePictureBox.TabStop = false;
|
||||
this.EditModePictureBox.Click += new System.EventHandler(this.EditModePictureBox_Click);
|
||||
@@ -512,6 +517,7 @@
|
||||
this.DeleteModePictureBox.Location = new System.Drawing.Point(26, 3);
|
||||
this.DeleteModePictureBox.Name = "DeleteModePictureBox";
|
||||
this.DeleteModePictureBox.Size = new System.Drawing.Size(16, 16);
|
||||
this.DeleteModePictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.DeleteModePictureBox.TabIndex = 13;
|
||||
this.DeleteModePictureBox.TabStop = false;
|
||||
this.DeleteModePictureBox.Click += new System.EventHandler(this.DeleteModePictureBox_Click);
|
||||
|
||||
@@ -100,9 +100,7 @@ namespace Netch.Forms
|
||||
}
|
||||
|
||||
|
||||
private readonly object _serverLock = new object();
|
||||
|
||||
public async Task UpdateServersFromSubscribe()
|
||||
private async Task UpdateServersFromSubscribe()
|
||||
{
|
||||
void DisableItems(bool v)
|
||||
{
|
||||
@@ -126,9 +124,11 @@ namespace Netch.Forms
|
||||
|
||||
StatusText(i18N.Translate("Starting update subscription"));
|
||||
DisableItems(false);
|
||||
var useProxyToUpdateSubscription = Global.Settings.UseProxyToUpdateSubscription;
|
||||
try
|
||||
{
|
||||
if (Global.Settings.UseProxyToUpdateSubscription)
|
||||
string proxyServer = null;
|
||||
if (useProxyToUpdateSubscription)
|
||||
{
|
||||
var mode = new Models.Mode
|
||||
{
|
||||
@@ -136,50 +136,10 @@ namespace Netch.Forms
|
||||
Type = 5
|
||||
};
|
||||
await MainController.Start(ServerComboBox.SelectedItem as Server, mode);
|
||||
proxyServer = $"http://127.0.0.1:{Global.Settings.HTTPLocalPort}";
|
||||
}
|
||||
|
||||
await Task.WhenAll(Global.Settings.SubscribeLink.Select(async item => await Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = WebUtil.CreateRequest(item.Link);
|
||||
|
||||
if (!string.IsNullOrEmpty(item.UserAgent)) request.UserAgent = item.UserAgent;
|
||||
if (Global.Settings.UseProxyToUpdateSubscription)
|
||||
request.Proxy = new WebProxy($"http://127.0.0.1:{Global.Settings.HTTPLocalPort}");
|
||||
|
||||
List<Server> servers;
|
||||
|
||||
var result = WebUtil.DownloadString(request, out var rep);
|
||||
if (rep.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
servers = ShareLink.ParseText(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{item.Remark} Response Status Code: {rep.StatusCode}");
|
||||
}
|
||||
|
||||
foreach (var server in servers)
|
||||
{
|
||||
server.Group = item.Remark;
|
||||
}
|
||||
|
||||
lock (_serverLock)
|
||||
{
|
||||
Global.Settings.Server.RemoveAll(server => server.Group.Equals(item.Remark));
|
||||
Global.Settings.Server.AddRange(servers);
|
||||
}
|
||||
|
||||
|
||||
NotifyTip(i18N.TranslateFormat("Update {1} server(s) from {0}", item.Remark, servers.Count));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
NotifyTip($"{i18N.TranslateFormat("Update servers error from {0}", item.Remark)}\n{e.Message}", info: false);
|
||||
Logging.Error(e.ToString());
|
||||
}
|
||||
})).ToArray());
|
||||
await Subscription.UpdateServersAsync(proxyServer);
|
||||
|
||||
InitServer();
|
||||
Configuration.Save();
|
||||
@@ -191,9 +151,16 @@ namespace Netch.Forms
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (Global.Settings.UseProxyToUpdateSubscription)
|
||||
if (useProxyToUpdateSubscription)
|
||||
{
|
||||
await MainController.Stop();
|
||||
try
|
||||
{
|
||||
await MainController.Stop();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
DisableItems(true);
|
||||
@@ -235,7 +202,12 @@ namespace Netch.Forms
|
||||
{
|
||||
try
|
||||
{
|
||||
await Task.Run(() => DNS.Cache.Clear());
|
||||
await Task.Run(() =>
|
||||
{
|
||||
NativeMethods.FlushDNSResolverCache();
|
||||
DNS.Cache.Clear();
|
||||
});
|
||||
|
||||
StatusText(i18N.Translate("DNS cache cleanup succeeded"));
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -256,19 +228,13 @@ namespace Netch.Forms
|
||||
|
||||
private async void UpdateACL(bool useProxy)
|
||||
{
|
||||
void DisableItems(bool v)
|
||||
{
|
||||
UpdateACLToolStripMenuItem.Enabled = updateACLWithProxyToolStripMenuItem.Enabled = v;
|
||||
}
|
||||
|
||||
if (useProxy && ServerComboBox.SelectedIndex == -1)
|
||||
{
|
||||
MessageBoxX.Show(i18N.Translate("Please select a server first"));
|
||||
return;
|
||||
}
|
||||
|
||||
DisableItems(false);
|
||||
|
||||
Enabled = false;
|
||||
|
||||
NotifyTip(i18N.Translate("Updating in the background"));
|
||||
try
|
||||
@@ -304,7 +270,7 @@ namespace Netch.Forms
|
||||
State = State.Stopped;
|
||||
}
|
||||
|
||||
DisableItems(true);
|
||||
Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using Netch.Controllers;
|
||||
@@ -36,7 +37,7 @@ namespace Netch.Forms
|
||||
|
||||
private async void NewVersionLabel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!_updater.LatestVersionDownloadUrl.Contains("Netch"))
|
||||
if (!_updater.LatestRelease.assets.Any())
|
||||
{
|
||||
Utils.Utils.Open(_updater.LatestVersionUrl);
|
||||
return;
|
||||
@@ -46,11 +47,12 @@ namespace Netch.Forms
|
||||
return;
|
||||
NotifyTip(i18N.Translate("Start downloading new version"));
|
||||
|
||||
var latestVersionDownloadUrl = _updater.LatestRelease.assets[0].browser_download_url;
|
||||
var tagPage = await WebUtil.DownloadStringAsync(WebUtil.CreateRequest(_updater.LatestVersionUrl));
|
||||
var match = Regex.Match(tagPage, @"<td .*>(?<sha256>.*)</td>", RegexOptions.Singleline);
|
||||
|
||||
// TODO Replace with regex get basename and sha256
|
||||
var fileName = Path.GetFileName(new Uri(_updater.LatestVersionDownloadUrl).LocalPath);
|
||||
var fileName = Path.GetFileName(new Uri(latestVersionDownloadUrl).LocalPath);
|
||||
fileName = fileName.Insert(fileName.LastIndexOf('.'), _updater.LatestVersionNumber);
|
||||
var fileFullPath = Path.Combine(Global.NetchDir, "data", fileName);
|
||||
|
||||
@@ -70,7 +72,7 @@ namespace Netch.Forms
|
||||
}
|
||||
|
||||
// TODO Replace "New Version Found" to Progress bar
|
||||
await WebUtil.DownloadFileAsync(WebUtil.CreateRequest(_updater.LatestVersionDownloadUrl), fileFullPath);
|
||||
await WebUtil.DownloadFileAsync(WebUtil.CreateRequest(latestVersionDownloadUrl), fileFullPath);
|
||||
|
||||
if (Utils.Utils.SHA256CheckSum(fileFullPath) != sha256)
|
||||
{
|
||||
|
||||
@@ -79,7 +79,8 @@ namespace Netch.Forms
|
||||
private void LoadProfile(int index)
|
||||
{
|
||||
var p = Global.Settings.Profiles[index];
|
||||
ProfileNameText.Text = p.ModeRemark;
|
||||
ProfileNameText.Text = p.ProfileName;
|
||||
ModeComboBox.ResetCompletionList();
|
||||
|
||||
if (p.IsDummy)
|
||||
throw new Exception("Profile not found.");
|
||||
@@ -160,9 +161,6 @@ namespace Netch.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset Mode ComboBox Items
|
||||
ModeComboBox.Text = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
LoadProfile(index);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using Netch.Models;
|
||||
using Netch.Utils;
|
||||
|
||||
@@ -35,10 +36,11 @@ namespace Netch.Forms
|
||||
|
||||
// 启动需要禁用的控件
|
||||
UninstallServiceToolStripMenuItem.Enabled =
|
||||
updateACLWithProxyToolStripMenuItem.Enabled =
|
||||
UpdateServersFromSubscribeLinksToolStripMenuItem.Enabled =
|
||||
UninstallTapDriverToolStripMenuItem.Enabled =
|
||||
ReloadModesToolStripMenuItem.Enabled = enabled;
|
||||
UpdateACLToolStripMenuItem.Enabled =
|
||||
updateACLWithProxyToolStripMenuItem.Enabled =
|
||||
UpdateServersFromSubscribeLinksToolStripMenuItem.Enabled =
|
||||
UninstallTapDriverToolStripMenuItem.Enabled =
|
||||
ReloadModesToolStripMenuItem.Enabled = enabled;
|
||||
}
|
||||
|
||||
_state = value;
|
||||
@@ -185,12 +187,7 @@ namespace Netch.Forms
|
||||
{
|
||||
private static ushort? _socks5Port;
|
||||
private static ushort? _httpPort;
|
||||
private static bool? _shareLan;
|
||||
|
||||
public static bool ShareLan
|
||||
{
|
||||
set => _shareLan = value;
|
||||
}
|
||||
private static bool _shareLan;
|
||||
|
||||
public static ushort HttpPort
|
||||
{
|
||||
@@ -202,35 +199,34 @@ namespace Netch.Forms
|
||||
set => _socks5Port = value;
|
||||
}
|
||||
|
||||
public static void UpdateShareLan() => _shareLan = Global.Settings.LocalAddress != "127.0.0.1";
|
||||
|
||||
public static string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_socks5Port == null && _httpPort == null)
|
||||
return string.Empty;
|
||||
|
||||
var text = new StringBuilder();
|
||||
if (_shareLan == true)
|
||||
text.Append(i18N.Translate("Allow other Devices to connect") + " ");
|
||||
var strings = new List<string>();
|
||||
|
||||
if (_socks5Port != null)
|
||||
text.Append($"Socks5 {i18N.Translate("Local Port", ": ")}{_socks5Port}");
|
||||
{
|
||||
strings.Add($"Socks5 {i18N.Translate("Local Port", ": ")}{_socks5Port}");
|
||||
}
|
||||
|
||||
if (_httpPort != null)
|
||||
{
|
||||
if (_socks5Port != null)
|
||||
text.Append(" | ");
|
||||
text.Append($"HTTP {i18N.Translate("Local Port", ": ")}{_httpPort}");
|
||||
strings.Add($"HTTP {i18N.Translate("Local Port", ": ")}{_httpPort}");
|
||||
}
|
||||
|
||||
return $" ({text})";
|
||||
if (!strings.Any())
|
||||
return string.Empty;
|
||||
|
||||
return $" ({(_shareLan ? i18N.Translate("Allow other Devices to connect") + " " : "")}{string.Join(" | ", strings)})";
|
||||
}
|
||||
}
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
_httpPort = _socks5Port = null;
|
||||
_shareLan = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,14 +283,19 @@ namespace Netch.Forms
|
||||
|
||||
Configuration.Save();
|
||||
|
||||
if (File.Exists("data\\last.json"))
|
||||
File.Delete("data\\last.json");
|
||||
foreach (var file in new[] {"data\\last.json", "data\\privoxy.conf"})
|
||||
{
|
||||
if (File.Exists(file))
|
||||
File.Delete(file);
|
||||
}
|
||||
|
||||
State = State.Terminating;
|
||||
}
|
||||
|
||||
#region MISC
|
||||
|
||||
private bool _resumeFlag;
|
||||
|
||||
/// <summary>
|
||||
/// 监听电源事件,自动重启Netch服务
|
||||
/// </summary>
|
||||
@@ -298,20 +303,24 @@ namespace Netch.Forms
|
||||
/// <param name="e"></param>
|
||||
private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
||||
{
|
||||
//不对Netch命令等待状态的电源事件做任何处理
|
||||
if (!State.Equals(State.Waiting))
|
||||
switch (e.Mode)
|
||||
{
|
||||
switch (e.Mode)
|
||||
{
|
||||
case PowerModes.Suspend: //操作系统即将挂起
|
||||
Logging.Info("操作系统即将挂起,自动停止===>" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
||||
case PowerModes.Suspend: //操作系统即将挂起
|
||||
if (!IsWaiting)
|
||||
{
|
||||
_resumeFlag = true;
|
||||
Logging.Info("操作系统即将挂起,自动停止");
|
||||
ControlFun();
|
||||
break;
|
||||
case PowerModes.Resume: //操作系统即将从挂起状态继续
|
||||
Logging.Info("操作系统即将从挂起状态继续,自动重启===>" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
||||
}
|
||||
break;
|
||||
case PowerModes.Resume: //操作系统即将从挂起状态继续
|
||||
if (_resumeFlag)
|
||||
{
|
||||
_resumeFlag = false;
|
||||
Logging.Info("操作系统即将从挂起状态继续,自动重启");
|
||||
ControlFun();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,21 +366,23 @@ namespace Netch.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedMode = (Models.Mode) ModeComboBox.SelectedItem;
|
||||
switch (selectedMode.Type)
|
||||
var mode = (Models.Mode) ModeComboBox.SelectedItem;
|
||||
if (ModifierKeys == Keys.Control)
|
||||
{
|
||||
Utils.Utils.Open(ModeHelper.GetFullPath(mode.RelativePath));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (mode.Type)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Hide();
|
||||
new Process(selectedMode).ShowDialog();
|
||||
new Process(mode).ShowDialog();
|
||||
Show();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
MessageBoxX.Show($"Current not support editing {selectedMode.TypeToString()} Mode");
|
||||
Utils.Utils.Open(ModeHelper.GetFullPath(mode.RelativePath));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,7 +456,7 @@ namespace Netch.Forms
|
||||
if (WindowState == FormWindowState.Minimized)
|
||||
{
|
||||
Visible = true;
|
||||
ShowInTaskbar = true; // 显示在系统任务栏
|
||||
ShowInTaskbar = true; // 显示在系统任务栏
|
||||
WindowState = FormWindowState.Normal; // 还原窗体
|
||||
}
|
||||
|
||||
@@ -462,14 +473,14 @@ namespace Netch.Forms
|
||||
if (WindowState == FormWindowState.Minimized)
|
||||
{
|
||||
Visible = true;
|
||||
ShowInTaskbar = true; //显示在系统任务栏
|
||||
ShowInTaskbar = true; //显示在系统任务栏
|
||||
WindowState = FormWindowState.Normal; //还原窗体
|
||||
}
|
||||
|
||||
Activate();
|
||||
}
|
||||
|
||||
private void NotifyTip(string text, int timeout = 0, bool info = true)
|
||||
public void NotifyTip(string text, int timeout = 0, bool info = true)
|
||||
{
|
||||
// 会阻塞线程 timeout 秒
|
||||
NotifyIcon.ShowBalloonTip(timeout,
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||
using Netch.Controllers;
|
||||
using Netch.Utils;
|
||||
|
||||
namespace Netch.Forms.Mode
|
||||
@@ -139,23 +140,28 @@ namespace Netch.Forms.Mode
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(ProcessNameTextBox.Text))
|
||||
{
|
||||
var process = ProcessNameTextBox.Text;
|
||||
|
||||
if (!RuleListBox.Items.Contains(process))
|
||||
{
|
||||
RuleListBox.Items.Add(process);
|
||||
}
|
||||
|
||||
Edited = true;
|
||||
RuleListBox.SelectedIndex = RuleListBox.Items.IndexOf(process);
|
||||
ProcessNameTextBox.Text = string.Empty;
|
||||
}
|
||||
else
|
||||
if (string.IsNullOrWhiteSpace(ProcessNameTextBox.Text))
|
||||
{
|
||||
MessageBoxX.Show(i18N.Translate("Please enter an process name (xxx.exe)"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!NFController.CheckCppRegex(ProcessNameTextBox.Text))
|
||||
{
|
||||
MessageBoxX.Show("Rule does not conform to C++ regular expression syntax");
|
||||
return;
|
||||
}
|
||||
|
||||
var process = ProcessNameTextBox.Text;
|
||||
|
||||
if (!RuleListBox.Items.Contains(process))
|
||||
{
|
||||
RuleListBox.Items.Add(process);
|
||||
}
|
||||
|
||||
Edited = true;
|
||||
RuleListBox.SelectedIndex = RuleListBox.Items.IndexOf(process);
|
||||
ProcessNameTextBox.Text = string.Empty;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -168,28 +168,37 @@ namespace Netch.Forms
|
||||
|
||||
private void ControlButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_checkActions.All(pair => pair.Value.Invoke(pair.Key.Text)))
|
||||
Utils.Utils.ComponentIterator(this, component => Utils.Utils.ChangeControlForeColor(component, Color.Black));
|
||||
|
||||
var flag = true;
|
||||
foreach (var pair in _checkActions.Where(pair => !pair.Value.Invoke(pair.Key.Text)))
|
||||
{
|
||||
foreach (var pair in _saveActions)
|
||||
{
|
||||
switch (pair.Key)
|
||||
{
|
||||
case CheckBox c:
|
||||
pair.Value.Invoke(c.Checked);
|
||||
break;
|
||||
default:
|
||||
pair.Value.Invoke(pair.Key.Text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Global.Settings.Server.IndexOf(Server) == -1)
|
||||
Global.Settings.Server.Add(Server);
|
||||
|
||||
MessageBoxX.Show(i18N.Translate("Saved"));
|
||||
Utils.Utils.ChangeControlForeColor(pair.Key, Color.Red);
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var pair in _saveActions)
|
||||
{
|
||||
switch (pair.Key)
|
||||
{
|
||||
case CheckBox c:
|
||||
pair.Value.Invoke(c.Checked);
|
||||
break;
|
||||
default:
|
||||
pair.Value.Invoke(pair.Key.Text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Global.Settings.Server.IndexOf(Server) == -1)
|
||||
Global.Settings.Server.Add(Server);
|
||||
|
||||
MessageBoxX.Show(i18N.Translate("Saved"));
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
437
Netch/Forms/SettingForm.Designer.cs
generated
437
Netch/Forms/SettingForm.Designer.cs
generated
@@ -59,6 +59,7 @@ namespace Netch.Forms
|
||||
this.ModifySystemDNSCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.ModifiedDNSLabel = new System.Windows.Forms.Label();
|
||||
this.ModifiedDNSTextBox = new System.Windows.Forms.TextBox();
|
||||
this.RedirectorSSCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.TAPTabPage = new System.Windows.Forms.TabPage();
|
||||
this.TUNTAPGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.TUNTAPAddressLabel = new System.Windows.Forms.Label();
|
||||
@@ -109,6 +110,7 @@ namespace Netch.Forms
|
||||
this.OtherDNSTextBox = new System.Windows.Forms.TextBox();
|
||||
this.ControlButton = new System.Windows.Forms.Button();
|
||||
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.NoProxyForUdpCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.TabControl.SuspendLayout();
|
||||
this.GeneralTabPage.SuspendLayout();
|
||||
this.PortGroupBox.SuspendLayout();
|
||||
@@ -131,10 +133,11 @@ namespace Netch.Forms
|
||||
this.TabControl.Controls.Add(this.v2rayTabPage);
|
||||
this.TabControl.Controls.Add(this.OtherTabPage);
|
||||
this.TabControl.Controls.Add(this.AioDNSTabPage);
|
||||
this.TabControl.Location = new System.Drawing.Point(3, 3);
|
||||
this.TabControl.Location = new System.Drawing.Point(4, 4);
|
||||
this.TabControl.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.TabControl.Name = "TabControl";
|
||||
this.TabControl.SelectedIndex = 0;
|
||||
this.TabControl.Size = new System.Drawing.Size(469, 354);
|
||||
this.TabControl.Size = new System.Drawing.Size(586, 442);
|
||||
this.TabControl.TabIndex = 0;
|
||||
//
|
||||
// GeneralTabPage
|
||||
@@ -154,10 +157,11 @@ namespace Netch.Forms
|
||||
this.GeneralTabPage.Controls.Add(this.AclAddrTextBox);
|
||||
this.GeneralTabPage.Controls.Add(this.LanguageLabel);
|
||||
this.GeneralTabPage.Controls.Add(this.LanguageComboBox);
|
||||
this.GeneralTabPage.Location = new System.Drawing.Point(4, 25);
|
||||
this.GeneralTabPage.Location = new System.Drawing.Point(4, 33);
|
||||
this.GeneralTabPage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.GeneralTabPage.Name = "GeneralTabPage";
|
||||
this.GeneralTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.GeneralTabPage.Size = new System.Drawing.Size(461, 325);
|
||||
this.GeneralTabPage.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.GeneralTabPage.Size = new System.Drawing.Size(578, 405);
|
||||
this.GeneralTabPage.TabIndex = 0;
|
||||
this.GeneralTabPage.Text = "General";
|
||||
//
|
||||
@@ -170,9 +174,11 @@ namespace Netch.Forms
|
||||
this.PortGroupBox.Controls.Add(this.RedirectorLabel);
|
||||
this.PortGroupBox.Controls.Add(this.RedirectorTextBox);
|
||||
this.PortGroupBox.Controls.Add(this.AllowDevicesCheckBox);
|
||||
this.PortGroupBox.Location = new System.Drawing.Point(8, 6);
|
||||
this.PortGroupBox.Location = new System.Drawing.Point(10, 8);
|
||||
this.PortGroupBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.PortGroupBox.Name = "PortGroupBox";
|
||||
this.PortGroupBox.Size = new System.Drawing.Size(241, 140);
|
||||
this.PortGroupBox.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.PortGroupBox.Size = new System.Drawing.Size(301, 175);
|
||||
this.PortGroupBox.TabIndex = 0;
|
||||
this.PortGroupBox.TabStop = false;
|
||||
this.PortGroupBox.Text = "Local Port";
|
||||
@@ -180,60 +186,67 @@ namespace Netch.Forms
|
||||
// Socks5PortLabel
|
||||
//
|
||||
this.Socks5PortLabel.AutoSize = true;
|
||||
this.Socks5PortLabel.Location = new System.Drawing.Point(9, 25);
|
||||
this.Socks5PortLabel.Location = new System.Drawing.Point(11, 31);
|
||||
this.Socks5PortLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.Socks5PortLabel.Name = "Socks5PortLabel";
|
||||
this.Socks5PortLabel.Size = new System.Drawing.Size(41, 12);
|
||||
this.Socks5PortLabel.Size = new System.Drawing.Size(55, 15);
|
||||
this.Socks5PortLabel.TabIndex = 0;
|
||||
this.Socks5PortLabel.Text = "Socks5";
|
||||
//
|
||||
// Socks5PortTextBox
|
||||
//
|
||||
this.Socks5PortTextBox.Location = new System.Drawing.Point(120, 22);
|
||||
this.Socks5PortTextBox.Location = new System.Drawing.Point(150, 28);
|
||||
this.Socks5PortTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.Socks5PortTextBox.Name = "Socks5PortTextBox";
|
||||
this.Socks5PortTextBox.Size = new System.Drawing.Size(90, 21);
|
||||
this.Socks5PortTextBox.Size = new System.Drawing.Size(112, 25);
|
||||
this.Socks5PortTextBox.TabIndex = 1;
|
||||
this.Socks5PortTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// HTTPPortLabel
|
||||
//
|
||||
this.HTTPPortLabel.AutoSize = true;
|
||||
this.HTTPPortLabel.Location = new System.Drawing.Point(9, 54);
|
||||
this.HTTPPortLabel.Location = new System.Drawing.Point(11, 68);
|
||||
this.HTTPPortLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.HTTPPortLabel.Name = "HTTPPortLabel";
|
||||
this.HTTPPortLabel.Size = new System.Drawing.Size(29, 12);
|
||||
this.HTTPPortLabel.Size = new System.Drawing.Size(39, 15);
|
||||
this.HTTPPortLabel.TabIndex = 2;
|
||||
this.HTTPPortLabel.Text = "HTTP";
|
||||
//
|
||||
// HTTPPortTextBox
|
||||
//
|
||||
this.HTTPPortTextBox.Location = new System.Drawing.Point(120, 51);
|
||||
this.HTTPPortTextBox.Location = new System.Drawing.Point(150, 64);
|
||||
this.HTTPPortTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.HTTPPortTextBox.Name = "HTTPPortTextBox";
|
||||
this.HTTPPortTextBox.Size = new System.Drawing.Size(90, 21);
|
||||
this.HTTPPortTextBox.Size = new System.Drawing.Size(112, 25);
|
||||
this.HTTPPortTextBox.TabIndex = 3;
|
||||
this.HTTPPortTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// RedirectorLabel
|
||||
//
|
||||
this.RedirectorLabel.AutoSize = true;
|
||||
this.RedirectorLabel.Location = new System.Drawing.Point(9, 83);
|
||||
this.RedirectorLabel.Location = new System.Drawing.Point(11, 104);
|
||||
this.RedirectorLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.RedirectorLabel.Name = "RedirectorLabel";
|
||||
this.RedirectorLabel.Size = new System.Drawing.Size(89, 12);
|
||||
this.RedirectorLabel.Size = new System.Drawing.Size(119, 15);
|
||||
this.RedirectorLabel.TabIndex = 4;
|
||||
this.RedirectorLabel.Text = "Redirector TCP";
|
||||
//
|
||||
// RedirectorTextBox
|
||||
//
|
||||
this.RedirectorTextBox.Location = new System.Drawing.Point(120, 80);
|
||||
this.RedirectorTextBox.Location = new System.Drawing.Point(150, 100);
|
||||
this.RedirectorTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.RedirectorTextBox.Name = "RedirectorTextBox";
|
||||
this.RedirectorTextBox.Size = new System.Drawing.Size(90, 21);
|
||||
this.RedirectorTextBox.Size = new System.Drawing.Size(112, 25);
|
||||
this.RedirectorTextBox.TabIndex = 5;
|
||||
this.RedirectorTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// AllowDevicesCheckBox
|
||||
//
|
||||
this.AllowDevicesCheckBox.AutoSize = true;
|
||||
this.AllowDevicesCheckBox.Location = new System.Drawing.Point(6, 107);
|
||||
this.AllowDevicesCheckBox.Location = new System.Drawing.Point(8, 134);
|
||||
this.AllowDevicesCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.AllowDevicesCheckBox.Name = "AllowDevicesCheckBox";
|
||||
this.AllowDevicesCheckBox.Size = new System.Drawing.Size(204, 16);
|
||||
this.AllowDevicesCheckBox.Size = new System.Drawing.Size(269, 19);
|
||||
this.AllowDevicesCheckBox.TabIndex = 6;
|
||||
this.AllowDevicesCheckBox.Text = "Allow other Devices to connect";
|
||||
this.AllowDevicesCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
@@ -242,9 +255,10 @@ namespace Netch.Forms
|
||||
// BootShadowsocksFromDLLCheckBox
|
||||
//
|
||||
this.BootShadowsocksFromDLLCheckBox.AutoSize = true;
|
||||
this.BootShadowsocksFromDLLCheckBox.Location = new System.Drawing.Point(267, 15);
|
||||
this.BootShadowsocksFromDLLCheckBox.Location = new System.Drawing.Point(334, 19);
|
||||
this.BootShadowsocksFromDLLCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.BootShadowsocksFromDLLCheckBox.Name = "BootShadowsocksFromDLLCheckBox";
|
||||
this.BootShadowsocksFromDLLCheckBox.Size = new System.Drawing.Size(60, 16);
|
||||
this.BootShadowsocksFromDLLCheckBox.Size = new System.Drawing.Size(77, 19);
|
||||
this.BootShadowsocksFromDLLCheckBox.TabIndex = 1;
|
||||
this.BootShadowsocksFromDLLCheckBox.Text = "SS DLL";
|
||||
this.BootShadowsocksFromDLLCheckBox.UseVisualStyleBackColor = true;
|
||||
@@ -252,9 +266,10 @@ namespace Netch.Forms
|
||||
// ResolveServerHostnameCheckBox
|
||||
//
|
||||
this.ResolveServerHostnameCheckBox.AutoSize = true;
|
||||
this.ResolveServerHostnameCheckBox.Location = new System.Drawing.Point(266, 42);
|
||||
this.ResolveServerHostnameCheckBox.Location = new System.Drawing.Point(332, 52);
|
||||
this.ResolveServerHostnameCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.ResolveServerHostnameCheckBox.Name = "ResolveServerHostnameCheckBox";
|
||||
this.ResolveServerHostnameCheckBox.Size = new System.Drawing.Size(162, 16);
|
||||
this.ResolveServerHostnameCheckBox.Size = new System.Drawing.Size(213, 19);
|
||||
this.ResolveServerHostnameCheckBox.TabIndex = 2;
|
||||
this.ResolveServerHostnameCheckBox.Text = "Resolve Server Hostname";
|
||||
this.ResolveServerHostnameCheckBox.UseVisualStyleBackColor = true;
|
||||
@@ -262,26 +277,29 @@ namespace Netch.Forms
|
||||
// ProfileCountLabel
|
||||
//
|
||||
this.ProfileCountLabel.AutoSize = true;
|
||||
this.ProfileCountLabel.Location = new System.Drawing.Point(12, 160);
|
||||
this.ProfileCountLabel.Location = new System.Drawing.Point(15, 200);
|
||||
this.ProfileCountLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.ProfileCountLabel.Name = "ProfileCountLabel";
|
||||
this.ProfileCountLabel.Size = new System.Drawing.Size(77, 12);
|
||||
this.ProfileCountLabel.Size = new System.Drawing.Size(103, 15);
|
||||
this.ProfileCountLabel.TabIndex = 3;
|
||||
this.ProfileCountLabel.Text = "ProfileCount";
|
||||
//
|
||||
// ProfileCountTextBox
|
||||
//
|
||||
this.ProfileCountTextBox.Location = new System.Drawing.Point(120, 157);
|
||||
this.ProfileCountTextBox.Location = new System.Drawing.Point(150, 196);
|
||||
this.ProfileCountTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.ProfileCountTextBox.Name = "ProfileCountTextBox";
|
||||
this.ProfileCountTextBox.Size = new System.Drawing.Size(90, 21);
|
||||
this.ProfileCountTextBox.Size = new System.Drawing.Size(112, 25);
|
||||
this.ProfileCountTextBox.TabIndex = 4;
|
||||
this.ProfileCountTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// TcpingAtStartedCheckBox
|
||||
//
|
||||
this.TcpingAtStartedCheckBox.AutoSize = true;
|
||||
this.TcpingAtStartedCheckBox.Location = new System.Drawing.Point(15, 186);
|
||||
this.TcpingAtStartedCheckBox.Location = new System.Drawing.Point(19, 232);
|
||||
this.TcpingAtStartedCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.TcpingAtStartedCheckBox.Name = "TcpingAtStartedCheckBox";
|
||||
this.TcpingAtStartedCheckBox.Size = new System.Drawing.Size(156, 16);
|
||||
this.TcpingAtStartedCheckBox.Size = new System.Drawing.Size(205, 19);
|
||||
this.TcpingAtStartedCheckBox.TabIndex = 5;
|
||||
this.TcpingAtStartedCheckBox.Text = "Delay test after start";
|
||||
this.TcpingAtStartedCheckBox.UseVisualStyleBackColor = true;
|
||||
@@ -289,60 +307,67 @@ namespace Netch.Forms
|
||||
// DetectionIntervalLabel
|
||||
//
|
||||
this.DetectionIntervalLabel.AutoSize = true;
|
||||
this.DetectionIntervalLabel.Location = new System.Drawing.Point(228, 187);
|
||||
this.DetectionIntervalLabel.Location = new System.Drawing.Point(285, 234);
|
||||
this.DetectionIntervalLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.DetectionIntervalLabel.Name = "DetectionIntervalLabel";
|
||||
this.DetectionIntervalLabel.Size = new System.Drawing.Size(143, 12);
|
||||
this.DetectionIntervalLabel.Size = new System.Drawing.Size(191, 15);
|
||||
this.DetectionIntervalLabel.TabIndex = 6;
|
||||
this.DetectionIntervalLabel.Text = "Detection interval(sec)";
|
||||
//
|
||||
// DetectionIntervalTextBox
|
||||
//
|
||||
this.DetectionIntervalTextBox.Location = new System.Drawing.Point(366, 184);
|
||||
this.DetectionIntervalTextBox.Location = new System.Drawing.Point(458, 230);
|
||||
this.DetectionIntervalTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.DetectionIntervalTextBox.Name = "DetectionIntervalTextBox";
|
||||
this.DetectionIntervalTextBox.Size = new System.Drawing.Size(68, 21);
|
||||
this.DetectionIntervalTextBox.Size = new System.Drawing.Size(84, 25);
|
||||
this.DetectionIntervalTextBox.TabIndex = 7;
|
||||
this.DetectionIntervalTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// STUNServerLabel
|
||||
//
|
||||
this.STUNServerLabel.AutoSize = true;
|
||||
this.STUNServerLabel.Location = new System.Drawing.Point(12, 216);
|
||||
this.STUNServerLabel.Location = new System.Drawing.Point(15, 270);
|
||||
this.STUNServerLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.STUNServerLabel.Name = "STUNServerLabel";
|
||||
this.STUNServerLabel.Size = new System.Drawing.Size(71, 12);
|
||||
this.STUNServerLabel.Size = new System.Drawing.Size(95, 15);
|
||||
this.STUNServerLabel.TabIndex = 8;
|
||||
this.STUNServerLabel.Text = "STUN Server";
|
||||
//
|
||||
// STUN_ServerComboBox
|
||||
//
|
||||
this.STUN_ServerComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
|
||||
this.STUN_ServerComboBox.Location = new System.Drawing.Point(120, 213);
|
||||
this.STUN_ServerComboBox.Location = new System.Drawing.Point(150, 266);
|
||||
this.STUN_ServerComboBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.STUN_ServerComboBox.Name = "STUN_ServerComboBox";
|
||||
this.STUN_ServerComboBox.Size = new System.Drawing.Size(314, 20);
|
||||
this.STUN_ServerComboBox.Size = new System.Drawing.Size(392, 28);
|
||||
this.STUN_ServerComboBox.TabIndex = 9;
|
||||
//
|
||||
// AclLabel
|
||||
//
|
||||
this.AclLabel.AutoSize = true;
|
||||
this.AclLabel.Location = new System.Drawing.Point(12, 248);
|
||||
this.AclLabel.Location = new System.Drawing.Point(15, 310);
|
||||
this.AclLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.AclLabel.Name = "AclLabel";
|
||||
this.AclLabel.Size = new System.Drawing.Size(65, 12);
|
||||
this.AclLabel.Size = new System.Drawing.Size(87, 15);
|
||||
this.AclLabel.TabIndex = 10;
|
||||
this.AclLabel.Text = "Custom ACL";
|
||||
//
|
||||
// AclAddrTextBox
|
||||
//
|
||||
this.AclAddrTextBox.Location = new System.Drawing.Point(120, 245);
|
||||
this.AclAddrTextBox.Location = new System.Drawing.Point(150, 306);
|
||||
this.AclAddrTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.AclAddrTextBox.Name = "AclAddrTextBox";
|
||||
this.AclAddrTextBox.Size = new System.Drawing.Size(315, 21);
|
||||
this.AclAddrTextBox.Size = new System.Drawing.Size(393, 25);
|
||||
this.AclAddrTextBox.TabIndex = 11;
|
||||
this.AclAddrTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// LanguageLabel
|
||||
//
|
||||
this.LanguageLabel.AutoSize = true;
|
||||
this.LanguageLabel.Location = new System.Drawing.Point(12, 277);
|
||||
this.LanguageLabel.Location = new System.Drawing.Point(15, 346);
|
||||
this.LanguageLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.LanguageLabel.Name = "LanguageLabel";
|
||||
this.LanguageLabel.Size = new System.Drawing.Size(53, 12);
|
||||
this.LanguageLabel.Size = new System.Drawing.Size(71, 15);
|
||||
this.LanguageLabel.TabIndex = 12;
|
||||
this.LanguageLabel.Text = "Language";
|
||||
//
|
||||
@@ -350,30 +375,35 @@ namespace Netch.Forms
|
||||
//
|
||||
this.LanguageComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.LanguageComboBox.FormattingEnabled = true;
|
||||
this.LanguageComboBox.Location = new System.Drawing.Point(120, 274);
|
||||
this.LanguageComboBox.Location = new System.Drawing.Point(150, 342);
|
||||
this.LanguageComboBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.LanguageComboBox.Name = "LanguageComboBox";
|
||||
this.LanguageComboBox.Size = new System.Drawing.Size(121, 20);
|
||||
this.LanguageComboBox.Size = new System.Drawing.Size(150, 28);
|
||||
this.LanguageComboBox.TabIndex = 13;
|
||||
//
|
||||
// NFTabPage
|
||||
//
|
||||
this.NFTabPage.BackColor = System.Drawing.SystemColors.ButtonFace;
|
||||
this.NFTabPage.Controls.Add(this.NoProxyForUdpCheckBox);
|
||||
this.NFTabPage.Controls.Add(this.ModifySystemDNSCheckBox);
|
||||
this.NFTabPage.Controls.Add(this.ModifiedDNSLabel);
|
||||
this.NFTabPage.Controls.Add(this.ModifiedDNSTextBox);
|
||||
this.NFTabPage.Location = new System.Drawing.Point(4, 25);
|
||||
this.NFTabPage.Controls.Add(this.RedirectorSSCheckBox);
|
||||
this.NFTabPage.Location = new System.Drawing.Point(4, 33);
|
||||
this.NFTabPage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.NFTabPage.Name = "NFTabPage";
|
||||
this.NFTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.NFTabPage.Size = new System.Drawing.Size(461, 325);
|
||||
this.NFTabPage.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.NFTabPage.Size = new System.Drawing.Size(578, 405);
|
||||
this.NFTabPage.TabIndex = 1;
|
||||
this.NFTabPage.Text = "Process Mode";
|
||||
//
|
||||
// ModifySystemDNSCheckBox
|
||||
//
|
||||
this.ModifySystemDNSCheckBox.AutoSize = true;
|
||||
this.ModifySystemDNSCheckBox.Location = new System.Drawing.Point(8, 16);
|
||||
this.ModifySystemDNSCheckBox.Location = new System.Drawing.Point(10, 20);
|
||||
this.ModifySystemDNSCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.ModifySystemDNSCheckBox.Name = "ModifySystemDNSCheckBox";
|
||||
this.ModifySystemDNSCheckBox.Size = new System.Drawing.Size(126, 16);
|
||||
this.ModifySystemDNSCheckBox.Size = new System.Drawing.Size(165, 19);
|
||||
this.ModifySystemDNSCheckBox.TabIndex = 0;
|
||||
this.ModifySystemDNSCheckBox.Text = "Modify System DNS";
|
||||
this.ModifySystemDNSCheckBox.UseVisualStyleBackColor = true;
|
||||
@@ -382,29 +412,44 @@ namespace Netch.Forms
|
||||
// ModifiedDNSLabel
|
||||
//
|
||||
this.ModifiedDNSLabel.AutoSize = true;
|
||||
this.ModifiedDNSLabel.Location = new System.Drawing.Point(24, 41);
|
||||
this.ModifiedDNSLabel.Location = new System.Drawing.Point(30, 51);
|
||||
this.ModifiedDNSLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.ModifiedDNSLabel.Name = "ModifiedDNSLabel";
|
||||
this.ModifiedDNSLabel.Size = new System.Drawing.Size(23, 12);
|
||||
this.ModifiedDNSLabel.Size = new System.Drawing.Size(31, 15);
|
||||
this.ModifiedDNSLabel.TabIndex = 2;
|
||||
this.ModifiedDNSLabel.Text = "DNS";
|
||||
//
|
||||
// ModifiedDNSTextBox
|
||||
//
|
||||
this.ModifiedDNSTextBox.Location = new System.Drawing.Point(99, 38);
|
||||
this.ModifiedDNSTextBox.Location = new System.Drawing.Point(124, 48);
|
||||
this.ModifiedDNSTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.ModifiedDNSTextBox.Name = "ModifiedDNSTextBox";
|
||||
this.ModifiedDNSTextBox.Size = new System.Drawing.Size(194, 21);
|
||||
this.ModifiedDNSTextBox.Size = new System.Drawing.Size(242, 25);
|
||||
this.ModifiedDNSTextBox.TabIndex = 1;
|
||||
this.ModifiedDNSTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// RedirectorSSCheckBox
|
||||
//
|
||||
this.RedirectorSSCheckBox.AutoSize = true;
|
||||
this.RedirectorSSCheckBox.Location = new System.Drawing.Point(10, 81);
|
||||
this.RedirectorSSCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.RedirectorSSCheckBox.Name = "RedirectorSSCheckBox";
|
||||
this.RedirectorSSCheckBox.Size = new System.Drawing.Size(133, 19);
|
||||
this.RedirectorSSCheckBox.TabIndex = 0;
|
||||
this.RedirectorSSCheckBox.Text = "Redirector SS";
|
||||
this.RedirectorSSCheckBox.UseVisualStyleBackColor = true;
|
||||
this.RedirectorSSCheckBox.CheckedChanged += new System.EventHandler(this.ModifySystemDNSCheckBox_CheckedChanged);
|
||||
//
|
||||
// TAPTabPage
|
||||
//
|
||||
this.TAPTabPage.BackColor = System.Drawing.SystemColors.ButtonFace;
|
||||
this.TAPTabPage.Controls.Add(this.TUNTAPGroupBox);
|
||||
this.TAPTabPage.Controls.Add(this.GlobalBypassIPsButton);
|
||||
this.TAPTabPage.Location = new System.Drawing.Point(4, 25);
|
||||
this.TAPTabPage.Location = new System.Drawing.Point(4, 33);
|
||||
this.TAPTabPage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.TAPTabPage.Name = "TAPTabPage";
|
||||
this.TAPTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.TAPTabPage.Size = new System.Drawing.Size(461, 325);
|
||||
this.TAPTabPage.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.TAPTabPage.Size = new System.Drawing.Size(578, 405);
|
||||
this.TAPTabPage.TabIndex = 2;
|
||||
this.TAPTabPage.Text = "TUN/TAP";
|
||||
//
|
||||
@@ -422,9 +467,11 @@ namespace Netch.Forms
|
||||
this.TUNTAPGroupBox.Controls.Add(this.ProxyDNSCheckBox);
|
||||
this.TUNTAPGroupBox.Controls.Add(this.UseFakeDNSCheckBox);
|
||||
this.TUNTAPGroupBox.Controls.Add(this.ICSCheckBox);
|
||||
this.TUNTAPGroupBox.Location = new System.Drawing.Point(6, 6);
|
||||
this.TUNTAPGroupBox.Location = new System.Drawing.Point(8, 8);
|
||||
this.TUNTAPGroupBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.TUNTAPGroupBox.Name = "TUNTAPGroupBox";
|
||||
this.TUNTAPGroupBox.Size = new System.Drawing.Size(420, 187);
|
||||
this.TUNTAPGroupBox.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.TUNTAPGroupBox.Size = new System.Drawing.Size(525, 234);
|
||||
this.TUNTAPGroupBox.TabIndex = 0;
|
||||
this.TUNTAPGroupBox.TabStop = false;
|
||||
this.TUNTAPGroupBox.Text = "TUN/TAP";
|
||||
@@ -432,77 +479,86 @@ namespace Netch.Forms
|
||||
// TUNTAPAddressLabel
|
||||
//
|
||||
this.TUNTAPAddressLabel.AutoSize = true;
|
||||
this.TUNTAPAddressLabel.Location = new System.Drawing.Point(9, 25);
|
||||
this.TUNTAPAddressLabel.Location = new System.Drawing.Point(11, 31);
|
||||
this.TUNTAPAddressLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.TUNTAPAddressLabel.Name = "TUNTAPAddressLabel";
|
||||
this.TUNTAPAddressLabel.Size = new System.Drawing.Size(47, 12);
|
||||
this.TUNTAPAddressLabel.Size = new System.Drawing.Size(63, 15);
|
||||
this.TUNTAPAddressLabel.TabIndex = 0;
|
||||
this.TUNTAPAddressLabel.Text = "Address";
|
||||
//
|
||||
// TUNTAPAddressTextBox
|
||||
//
|
||||
this.TUNTAPAddressTextBox.Location = new System.Drawing.Point(120, 22);
|
||||
this.TUNTAPAddressTextBox.Location = new System.Drawing.Point(150, 28);
|
||||
this.TUNTAPAddressTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.TUNTAPAddressTextBox.Name = "TUNTAPAddressTextBox";
|
||||
this.TUNTAPAddressTextBox.Size = new System.Drawing.Size(294, 21);
|
||||
this.TUNTAPAddressTextBox.Size = new System.Drawing.Size(366, 25);
|
||||
this.TUNTAPAddressTextBox.TabIndex = 1;
|
||||
this.TUNTAPAddressTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// TUNTAPNetmaskLabel
|
||||
//
|
||||
this.TUNTAPNetmaskLabel.AutoSize = true;
|
||||
this.TUNTAPNetmaskLabel.Location = new System.Drawing.Point(9, 54);
|
||||
this.TUNTAPNetmaskLabel.Location = new System.Drawing.Point(11, 68);
|
||||
this.TUNTAPNetmaskLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.TUNTAPNetmaskLabel.Name = "TUNTAPNetmaskLabel";
|
||||
this.TUNTAPNetmaskLabel.Size = new System.Drawing.Size(47, 12);
|
||||
this.TUNTAPNetmaskLabel.Size = new System.Drawing.Size(63, 15);
|
||||
this.TUNTAPNetmaskLabel.TabIndex = 2;
|
||||
this.TUNTAPNetmaskLabel.Text = "Netmask";
|
||||
//
|
||||
// TUNTAPNetmaskTextBox
|
||||
//
|
||||
this.TUNTAPNetmaskTextBox.Location = new System.Drawing.Point(120, 51);
|
||||
this.TUNTAPNetmaskTextBox.Location = new System.Drawing.Point(150, 64);
|
||||
this.TUNTAPNetmaskTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.TUNTAPNetmaskTextBox.Name = "TUNTAPNetmaskTextBox";
|
||||
this.TUNTAPNetmaskTextBox.Size = new System.Drawing.Size(294, 21);
|
||||
this.TUNTAPNetmaskTextBox.Size = new System.Drawing.Size(366, 25);
|
||||
this.TUNTAPNetmaskTextBox.TabIndex = 3;
|
||||
this.TUNTAPNetmaskTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// TUNTAPGatewayLabel
|
||||
//
|
||||
this.TUNTAPGatewayLabel.AutoSize = true;
|
||||
this.TUNTAPGatewayLabel.Location = new System.Drawing.Point(9, 83);
|
||||
this.TUNTAPGatewayLabel.Location = new System.Drawing.Point(11, 104);
|
||||
this.TUNTAPGatewayLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.TUNTAPGatewayLabel.Name = "TUNTAPGatewayLabel";
|
||||
this.TUNTAPGatewayLabel.Size = new System.Drawing.Size(47, 12);
|
||||
this.TUNTAPGatewayLabel.Size = new System.Drawing.Size(63, 15);
|
||||
this.TUNTAPGatewayLabel.TabIndex = 4;
|
||||
this.TUNTAPGatewayLabel.Text = "Gateway";
|
||||
//
|
||||
// TUNTAPGatewayTextBox
|
||||
//
|
||||
this.TUNTAPGatewayTextBox.Location = new System.Drawing.Point(120, 80);
|
||||
this.TUNTAPGatewayTextBox.Location = new System.Drawing.Point(150, 100);
|
||||
this.TUNTAPGatewayTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.TUNTAPGatewayTextBox.Name = "TUNTAPGatewayTextBox";
|
||||
this.TUNTAPGatewayTextBox.Size = new System.Drawing.Size(294, 21);
|
||||
this.TUNTAPGatewayTextBox.Size = new System.Drawing.Size(366, 25);
|
||||
this.TUNTAPGatewayTextBox.TabIndex = 5;
|
||||
this.TUNTAPGatewayTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// TUNTAPDNSLabel
|
||||
//
|
||||
this.TUNTAPDNSLabel.AutoSize = true;
|
||||
this.TUNTAPDNSLabel.Location = new System.Drawing.Point(9, 112);
|
||||
this.TUNTAPDNSLabel.Location = new System.Drawing.Point(11, 140);
|
||||
this.TUNTAPDNSLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.TUNTAPDNSLabel.Name = "TUNTAPDNSLabel";
|
||||
this.TUNTAPDNSLabel.Size = new System.Drawing.Size(23, 12);
|
||||
this.TUNTAPDNSLabel.Size = new System.Drawing.Size(31, 15);
|
||||
this.TUNTAPDNSLabel.TabIndex = 6;
|
||||
this.TUNTAPDNSLabel.Text = "DNS";
|
||||
//
|
||||
// TUNTAPDNSTextBox
|
||||
//
|
||||
this.TUNTAPDNSTextBox.Location = new System.Drawing.Point(120, 110);
|
||||
this.TUNTAPDNSTextBox.Location = new System.Drawing.Point(150, 138);
|
||||
this.TUNTAPDNSTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.TUNTAPDNSTextBox.Name = "TUNTAPDNSTextBox";
|
||||
this.TUNTAPDNSTextBox.Size = new System.Drawing.Size(294, 21);
|
||||
this.TUNTAPDNSTextBox.Size = new System.Drawing.Size(366, 25);
|
||||
this.TUNTAPDNSTextBox.TabIndex = 7;
|
||||
this.TUNTAPDNSTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// UseCustomDNSCheckBox
|
||||
//
|
||||
this.UseCustomDNSCheckBox.AutoSize = true;
|
||||
this.UseCustomDNSCheckBox.Location = new System.Drawing.Point(10, 139);
|
||||
this.UseCustomDNSCheckBox.Location = new System.Drawing.Point(12, 174);
|
||||
this.UseCustomDNSCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.UseCustomDNSCheckBox.Name = "UseCustomDNSCheckBox";
|
||||
this.UseCustomDNSCheckBox.Size = new System.Drawing.Size(108, 16);
|
||||
this.UseCustomDNSCheckBox.Size = new System.Drawing.Size(141, 19);
|
||||
this.UseCustomDNSCheckBox.TabIndex = 8;
|
||||
this.UseCustomDNSCheckBox.Text = "Use Custom DNS";
|
||||
this.UseCustomDNSCheckBox.UseVisualStyleBackColor = true;
|
||||
@@ -511,9 +567,10 @@ namespace Netch.Forms
|
||||
// ProxyDNSCheckBox
|
||||
//
|
||||
this.ProxyDNSCheckBox.AutoSize = true;
|
||||
this.ProxyDNSCheckBox.Location = new System.Drawing.Point(261, 139);
|
||||
this.ProxyDNSCheckBox.Location = new System.Drawing.Point(326, 174);
|
||||
this.ProxyDNSCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.ProxyDNSCheckBox.Name = "ProxyDNSCheckBox";
|
||||
this.ProxyDNSCheckBox.Size = new System.Drawing.Size(138, 16);
|
||||
this.ProxyDNSCheckBox.Size = new System.Drawing.Size(181, 19);
|
||||
this.ProxyDNSCheckBox.TabIndex = 9;
|
||||
this.ProxyDNSCheckBox.Text = "Proxy DNS in Mode 2";
|
||||
this.ProxyDNSCheckBox.UseVisualStyleBackColor = true;
|
||||
@@ -521,9 +578,10 @@ namespace Netch.Forms
|
||||
// UseFakeDNSCheckBox
|
||||
//
|
||||
this.UseFakeDNSCheckBox.AutoSize = true;
|
||||
this.UseFakeDNSCheckBox.Location = new System.Drawing.Point(10, 160);
|
||||
this.UseFakeDNSCheckBox.Location = new System.Drawing.Point(12, 200);
|
||||
this.UseFakeDNSCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.UseFakeDNSCheckBox.Name = "UseFakeDNSCheckBox";
|
||||
this.UseFakeDNSCheckBox.Size = new System.Drawing.Size(96, 16);
|
||||
this.UseFakeDNSCheckBox.Size = new System.Drawing.Size(125, 19);
|
||||
this.UseFakeDNSCheckBox.TabIndex = 10;
|
||||
this.UseFakeDNSCheckBox.Text = "Use Fake DNS";
|
||||
this.UseFakeDNSCheckBox.UseVisualStyleBackColor = true;
|
||||
@@ -533,9 +591,10 @@ namespace Netch.Forms
|
||||
//
|
||||
this.ICSCheckBox.AutoSize = true;
|
||||
this.ICSCheckBox.Enabled = false;
|
||||
this.ICSCheckBox.Location = new System.Drawing.Point(261, 160);
|
||||
this.ICSCheckBox.Location = new System.Drawing.Point(326, 200);
|
||||
this.ICSCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.ICSCheckBox.Name = "ICSCheckBox";
|
||||
this.ICSCheckBox.Size = new System.Drawing.Size(138, 16);
|
||||
this.ICSCheckBox.Size = new System.Drawing.Size(181, 19);
|
||||
this.ICSCheckBox.TabIndex = 11;
|
||||
this.ICSCheckBox.Text = "Tap Network Sharing";
|
||||
this.ICSCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
@@ -544,9 +603,10 @@ namespace Netch.Forms
|
||||
//
|
||||
// GlobalBypassIPsButton
|
||||
//
|
||||
this.GlobalBypassIPsButton.Location = new System.Drawing.Point(6, 199);
|
||||
this.GlobalBypassIPsButton.Location = new System.Drawing.Point(8, 249);
|
||||
this.GlobalBypassIPsButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.GlobalBypassIPsButton.Name = "GlobalBypassIPsButton";
|
||||
this.GlobalBypassIPsButton.Size = new System.Drawing.Size(128, 23);
|
||||
this.GlobalBypassIPsButton.Size = new System.Drawing.Size(160, 29);
|
||||
this.GlobalBypassIPsButton.TabIndex = 1;
|
||||
this.GlobalBypassIPsButton.Text = "Global Bypass IPs";
|
||||
this.GlobalBypassIPsButton.UseVisualStyleBackColor = true;
|
||||
@@ -558,19 +618,21 @@ namespace Netch.Forms
|
||||
this.v2rayTabPage.Controls.Add(this.TLSAllowInsecureCheckBox);
|
||||
this.v2rayTabPage.Controls.Add(this.UseMuxCheckBox);
|
||||
this.v2rayTabPage.Controls.Add(this.KCPGroupBox);
|
||||
this.v2rayTabPage.Location = new System.Drawing.Point(4, 25);
|
||||
this.v2rayTabPage.Location = new System.Drawing.Point(4, 33);
|
||||
this.v2rayTabPage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.v2rayTabPage.Name = "v2rayTabPage";
|
||||
this.v2rayTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.v2rayTabPage.Size = new System.Drawing.Size(461, 325);
|
||||
this.v2rayTabPage.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.v2rayTabPage.Size = new System.Drawing.Size(578, 405);
|
||||
this.v2rayTabPage.TabIndex = 3;
|
||||
this.v2rayTabPage.Text = "V2Ray";
|
||||
//
|
||||
// TLSAllowInsecureCheckBox
|
||||
//
|
||||
this.TLSAllowInsecureCheckBox.AutoSize = true;
|
||||
this.TLSAllowInsecureCheckBox.Location = new System.Drawing.Point(6, 15);
|
||||
this.TLSAllowInsecureCheckBox.Location = new System.Drawing.Point(8, 19);
|
||||
this.TLSAllowInsecureCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.TLSAllowInsecureCheckBox.Name = "TLSAllowInsecureCheckBox";
|
||||
this.TLSAllowInsecureCheckBox.Size = new System.Drawing.Size(126, 16);
|
||||
this.TLSAllowInsecureCheckBox.Size = new System.Drawing.Size(165, 19);
|
||||
this.TLSAllowInsecureCheckBox.TabIndex = 0;
|
||||
this.TLSAllowInsecureCheckBox.Text = "TLS AllowInsecure";
|
||||
this.TLSAllowInsecureCheckBox.UseVisualStyleBackColor = true;
|
||||
@@ -578,9 +640,10 @@ namespace Netch.Forms
|
||||
// UseMuxCheckBox
|
||||
//
|
||||
this.UseMuxCheckBox.AutoSize = true;
|
||||
this.UseMuxCheckBox.Location = new System.Drawing.Point(148, 15);
|
||||
this.UseMuxCheckBox.Location = new System.Drawing.Point(185, 19);
|
||||
this.UseMuxCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.UseMuxCheckBox.Name = "UseMuxCheckBox";
|
||||
this.UseMuxCheckBox.Size = new System.Drawing.Size(66, 16);
|
||||
this.UseMuxCheckBox.Size = new System.Drawing.Size(85, 19);
|
||||
this.UseMuxCheckBox.TabIndex = 1;
|
||||
this.UseMuxCheckBox.Text = "Use Mux";
|
||||
this.UseMuxCheckBox.UseVisualStyleBackColor = true;
|
||||
@@ -600,9 +663,11 @@ namespace Netch.Forms
|
||||
this.KCPGroupBox.Controls.Add(this.writeBufferSizeLabel);
|
||||
this.KCPGroupBox.Controls.Add(this.writeBufferSizeTextBox);
|
||||
this.KCPGroupBox.Controls.Add(this.congestionCheckBox);
|
||||
this.KCPGroupBox.Location = new System.Drawing.Point(9, 48);
|
||||
this.KCPGroupBox.Location = new System.Drawing.Point(11, 60);
|
||||
this.KCPGroupBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.KCPGroupBox.Name = "KCPGroupBox";
|
||||
this.KCPGroupBox.Size = new System.Drawing.Size(427, 204);
|
||||
this.KCPGroupBox.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.KCPGroupBox.Size = new System.Drawing.Size(534, 255);
|
||||
this.KCPGroupBox.TabIndex = 2;
|
||||
this.KCPGroupBox.TabStop = false;
|
||||
this.KCPGroupBox.Text = "KCP";
|
||||
@@ -610,111 +675,124 @@ namespace Netch.Forms
|
||||
// mtuLabel
|
||||
//
|
||||
this.mtuLabel.AutoSize = true;
|
||||
this.mtuLabel.Location = new System.Drawing.Point(6, 26);
|
||||
this.mtuLabel.Location = new System.Drawing.Point(8, 32);
|
||||
this.mtuLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.mtuLabel.Name = "mtuLabel";
|
||||
this.mtuLabel.Size = new System.Drawing.Size(23, 12);
|
||||
this.mtuLabel.Size = new System.Drawing.Size(31, 15);
|
||||
this.mtuLabel.TabIndex = 0;
|
||||
this.mtuLabel.Text = "mtu";
|
||||
//
|
||||
// mtuTextBox
|
||||
//
|
||||
this.mtuTextBox.Location = new System.Drawing.Point(103, 17);
|
||||
this.mtuTextBox.Location = new System.Drawing.Point(129, 21);
|
||||
this.mtuTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.mtuTextBox.Name = "mtuTextBox";
|
||||
this.mtuTextBox.Size = new System.Drawing.Size(90, 21);
|
||||
this.mtuTextBox.Size = new System.Drawing.Size(112, 25);
|
||||
this.mtuTextBox.TabIndex = 1;
|
||||
this.mtuTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// ttiLabel
|
||||
//
|
||||
this.ttiLabel.AutoSize = true;
|
||||
this.ttiLabel.Location = new System.Drawing.Point(224, 26);
|
||||
this.ttiLabel.Location = new System.Drawing.Point(280, 32);
|
||||
this.ttiLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.ttiLabel.Name = "ttiLabel";
|
||||
this.ttiLabel.Size = new System.Drawing.Size(23, 12);
|
||||
this.ttiLabel.Size = new System.Drawing.Size(31, 15);
|
||||
this.ttiLabel.TabIndex = 2;
|
||||
this.ttiLabel.Text = "tti";
|
||||
//
|
||||
// ttiTextBox
|
||||
//
|
||||
this.ttiTextBox.Location = new System.Drawing.Point(331, 17);
|
||||
this.ttiTextBox.Location = new System.Drawing.Point(414, 21);
|
||||
this.ttiTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.ttiTextBox.Name = "ttiTextBox";
|
||||
this.ttiTextBox.Size = new System.Drawing.Size(90, 21);
|
||||
this.ttiTextBox.Size = new System.Drawing.Size(112, 25);
|
||||
this.ttiTextBox.TabIndex = 3;
|
||||
this.ttiTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// uplinkCapacityLabel
|
||||
//
|
||||
this.uplinkCapacityLabel.AutoSize = true;
|
||||
this.uplinkCapacityLabel.Location = new System.Drawing.Point(6, 68);
|
||||
this.uplinkCapacityLabel.Location = new System.Drawing.Point(8, 85);
|
||||
this.uplinkCapacityLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.uplinkCapacityLabel.Name = "uplinkCapacityLabel";
|
||||
this.uplinkCapacityLabel.Size = new System.Drawing.Size(89, 12);
|
||||
this.uplinkCapacityLabel.Size = new System.Drawing.Size(119, 15);
|
||||
this.uplinkCapacityLabel.TabIndex = 4;
|
||||
this.uplinkCapacityLabel.Text = "uplinkCapacity";
|
||||
//
|
||||
// uplinkCapacityTextBox
|
||||
//
|
||||
this.uplinkCapacityTextBox.Location = new System.Drawing.Point(103, 59);
|
||||
this.uplinkCapacityTextBox.Location = new System.Drawing.Point(129, 74);
|
||||
this.uplinkCapacityTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.uplinkCapacityTextBox.Name = "uplinkCapacityTextBox";
|
||||
this.uplinkCapacityTextBox.Size = new System.Drawing.Size(90, 21);
|
||||
this.uplinkCapacityTextBox.Size = new System.Drawing.Size(112, 25);
|
||||
this.uplinkCapacityTextBox.TabIndex = 5;
|
||||
this.uplinkCapacityTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// downlinkCapacityLabel
|
||||
//
|
||||
this.downlinkCapacityLabel.AutoSize = true;
|
||||
this.downlinkCapacityLabel.Location = new System.Drawing.Point(224, 68);
|
||||
this.downlinkCapacityLabel.Location = new System.Drawing.Point(280, 85);
|
||||
this.downlinkCapacityLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.downlinkCapacityLabel.Name = "downlinkCapacityLabel";
|
||||
this.downlinkCapacityLabel.Size = new System.Drawing.Size(101, 12);
|
||||
this.downlinkCapacityLabel.Size = new System.Drawing.Size(135, 15);
|
||||
this.downlinkCapacityLabel.TabIndex = 6;
|
||||
this.downlinkCapacityLabel.Text = "downlinkCapacity";
|
||||
//
|
||||
// downlinkCapacityTextBox
|
||||
//
|
||||
this.downlinkCapacityTextBox.Location = new System.Drawing.Point(331, 65);
|
||||
this.downlinkCapacityTextBox.Location = new System.Drawing.Point(414, 81);
|
||||
this.downlinkCapacityTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.downlinkCapacityTextBox.Name = "downlinkCapacityTextBox";
|
||||
this.downlinkCapacityTextBox.Size = new System.Drawing.Size(90, 21);
|
||||
this.downlinkCapacityTextBox.Size = new System.Drawing.Size(112, 25);
|
||||
this.downlinkCapacityTextBox.TabIndex = 7;
|
||||
this.downlinkCapacityTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// readBufferSizeLabel
|
||||
//
|
||||
this.readBufferSizeLabel.AutoSize = true;
|
||||
this.readBufferSizeLabel.Location = new System.Drawing.Point(6, 109);
|
||||
this.readBufferSizeLabel.Location = new System.Drawing.Point(8, 136);
|
||||
this.readBufferSizeLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.readBufferSizeLabel.Name = "readBufferSizeLabel";
|
||||
this.readBufferSizeLabel.Size = new System.Drawing.Size(89, 12);
|
||||
this.readBufferSizeLabel.Size = new System.Drawing.Size(119, 15);
|
||||
this.readBufferSizeLabel.TabIndex = 8;
|
||||
this.readBufferSizeLabel.Text = "readBufferSize";
|
||||
//
|
||||
// readBufferSizeTextBox
|
||||
//
|
||||
this.readBufferSizeTextBox.Location = new System.Drawing.Point(103, 100);
|
||||
this.readBufferSizeTextBox.Location = new System.Drawing.Point(129, 125);
|
||||
this.readBufferSizeTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.readBufferSizeTextBox.Name = "readBufferSizeTextBox";
|
||||
this.readBufferSizeTextBox.Size = new System.Drawing.Size(90, 21);
|
||||
this.readBufferSizeTextBox.Size = new System.Drawing.Size(112, 25);
|
||||
this.readBufferSizeTextBox.TabIndex = 9;
|
||||
this.readBufferSizeTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// writeBufferSizeLabel
|
||||
//
|
||||
this.writeBufferSizeLabel.AutoSize = true;
|
||||
this.writeBufferSizeLabel.Location = new System.Drawing.Point(224, 109);
|
||||
this.writeBufferSizeLabel.Location = new System.Drawing.Point(280, 136);
|
||||
this.writeBufferSizeLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.writeBufferSizeLabel.Name = "writeBufferSizeLabel";
|
||||
this.writeBufferSizeLabel.Size = new System.Drawing.Size(95, 12);
|
||||
this.writeBufferSizeLabel.Size = new System.Drawing.Size(127, 15);
|
||||
this.writeBufferSizeLabel.TabIndex = 10;
|
||||
this.writeBufferSizeLabel.Text = "writeBufferSize";
|
||||
//
|
||||
// writeBufferSizeTextBox
|
||||
//
|
||||
this.writeBufferSizeTextBox.Location = new System.Drawing.Point(331, 106);
|
||||
this.writeBufferSizeTextBox.Location = new System.Drawing.Point(414, 132);
|
||||
this.writeBufferSizeTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.writeBufferSizeTextBox.Name = "writeBufferSizeTextBox";
|
||||
this.writeBufferSizeTextBox.Size = new System.Drawing.Size(90, 21);
|
||||
this.writeBufferSizeTextBox.Size = new System.Drawing.Size(112, 25);
|
||||
this.writeBufferSizeTextBox.TabIndex = 11;
|
||||
this.writeBufferSizeTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// congestionCheckBox
|
||||
//
|
||||
this.congestionCheckBox.AutoSize = true;
|
||||
this.congestionCheckBox.Location = new System.Drawing.Point(8, 139);
|
||||
this.congestionCheckBox.Location = new System.Drawing.Point(10, 174);
|
||||
this.congestionCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.congestionCheckBox.Name = "congestionCheckBox";
|
||||
this.congestionCheckBox.Size = new System.Drawing.Size(84, 16);
|
||||
this.congestionCheckBox.Size = new System.Drawing.Size(109, 19);
|
||||
this.congestionCheckBox.TabIndex = 12;
|
||||
this.congestionCheckBox.Text = "congestion";
|
||||
this.congestionCheckBox.UseVisualStyleBackColor = true;
|
||||
@@ -730,19 +808,21 @@ namespace Netch.Forms
|
||||
this.OtherTabPage.Controls.Add(this.CheckUpdateWhenOpenedCheckBox);
|
||||
this.OtherTabPage.Controls.Add(this.CheckBetaUpdateCheckBox);
|
||||
this.OtherTabPage.Controls.Add(this.UpdateSubscribeatWhenOpenedCheckBox);
|
||||
this.OtherTabPage.Location = new System.Drawing.Point(4, 25);
|
||||
this.OtherTabPage.Location = new System.Drawing.Point(4, 33);
|
||||
this.OtherTabPage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.OtherTabPage.Name = "OtherTabPage";
|
||||
this.OtherTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.OtherTabPage.Size = new System.Drawing.Size(461, 325);
|
||||
this.OtherTabPage.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.OtherTabPage.Size = new System.Drawing.Size(578, 405);
|
||||
this.OtherTabPage.TabIndex = 4;
|
||||
this.OtherTabPage.Text = "Others";
|
||||
//
|
||||
// ExitWhenClosedCheckBox
|
||||
//
|
||||
this.ExitWhenClosedCheckBox.AutoSize = true;
|
||||
this.ExitWhenClosedCheckBox.Location = new System.Drawing.Point(6, 6);
|
||||
this.ExitWhenClosedCheckBox.Location = new System.Drawing.Point(8, 8);
|
||||
this.ExitWhenClosedCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.ExitWhenClosedCheckBox.Name = "ExitWhenClosedCheckBox";
|
||||
this.ExitWhenClosedCheckBox.Size = new System.Drawing.Size(120, 16);
|
||||
this.ExitWhenClosedCheckBox.Size = new System.Drawing.Size(157, 19);
|
||||
this.ExitWhenClosedCheckBox.TabIndex = 0;
|
||||
this.ExitWhenClosedCheckBox.Text = "Exit when closed";
|
||||
this.ExitWhenClosedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
@@ -751,9 +831,10 @@ namespace Netch.Forms
|
||||
// StopWhenExitedCheckBox
|
||||
//
|
||||
this.StopWhenExitedCheckBox.AutoSize = true;
|
||||
this.StopWhenExitedCheckBox.Location = new System.Drawing.Point(200, 7);
|
||||
this.StopWhenExitedCheckBox.Location = new System.Drawing.Point(250, 9);
|
||||
this.StopWhenExitedCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.StopWhenExitedCheckBox.Name = "StopWhenExitedCheckBox";
|
||||
this.StopWhenExitedCheckBox.Size = new System.Drawing.Size(120, 16);
|
||||
this.StopWhenExitedCheckBox.Size = new System.Drawing.Size(157, 19);
|
||||
this.StopWhenExitedCheckBox.TabIndex = 1;
|
||||
this.StopWhenExitedCheckBox.Text = "Stop when exited";
|
||||
this.StopWhenExitedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
@@ -762,9 +843,10 @@ namespace Netch.Forms
|
||||
// StartWhenOpenedCheckBox
|
||||
//
|
||||
this.StartWhenOpenedCheckBox.AutoSize = true;
|
||||
this.StartWhenOpenedCheckBox.Location = new System.Drawing.Point(6, 33);
|
||||
this.StartWhenOpenedCheckBox.Location = new System.Drawing.Point(8, 41);
|
||||
this.StartWhenOpenedCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.StartWhenOpenedCheckBox.Name = "StartWhenOpenedCheckBox";
|
||||
this.StartWhenOpenedCheckBox.Size = new System.Drawing.Size(126, 16);
|
||||
this.StartWhenOpenedCheckBox.Size = new System.Drawing.Size(165, 19);
|
||||
this.StartWhenOpenedCheckBox.TabIndex = 2;
|
||||
this.StartWhenOpenedCheckBox.Text = "Start when opened";
|
||||
this.StartWhenOpenedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
@@ -773,9 +855,10 @@ namespace Netch.Forms
|
||||
// MinimizeWhenStartedCheckBox
|
||||
//
|
||||
this.MinimizeWhenStartedCheckBox.AutoSize = true;
|
||||
this.MinimizeWhenStartedCheckBox.Location = new System.Drawing.Point(200, 33);
|
||||
this.MinimizeWhenStartedCheckBox.Location = new System.Drawing.Point(250, 41);
|
||||
this.MinimizeWhenStartedCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.MinimizeWhenStartedCheckBox.Name = "MinimizeWhenStartedCheckBox";
|
||||
this.MinimizeWhenStartedCheckBox.Size = new System.Drawing.Size(150, 16);
|
||||
this.MinimizeWhenStartedCheckBox.Size = new System.Drawing.Size(197, 19);
|
||||
this.MinimizeWhenStartedCheckBox.TabIndex = 3;
|
||||
this.MinimizeWhenStartedCheckBox.Text = "Minimize when started";
|
||||
this.MinimizeWhenStartedCheckBox.UseVisualStyleBackColor = true;
|
||||
@@ -783,9 +866,10 @@ namespace Netch.Forms
|
||||
// RunAtStartupCheckBox
|
||||
//
|
||||
this.RunAtStartupCheckBox.AutoSize = true;
|
||||
this.RunAtStartupCheckBox.Location = new System.Drawing.Point(6, 60);
|
||||
this.RunAtStartupCheckBox.Location = new System.Drawing.Point(8, 75);
|
||||
this.RunAtStartupCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.RunAtStartupCheckBox.Name = "RunAtStartupCheckBox";
|
||||
this.RunAtStartupCheckBox.Size = new System.Drawing.Size(108, 16);
|
||||
this.RunAtStartupCheckBox.Size = new System.Drawing.Size(141, 19);
|
||||
this.RunAtStartupCheckBox.TabIndex = 4;
|
||||
this.RunAtStartupCheckBox.Text = "Run at startup";
|
||||
this.RunAtStartupCheckBox.UseVisualStyleBackColor = true;
|
||||
@@ -793,9 +877,10 @@ namespace Netch.Forms
|
||||
// CheckUpdateWhenOpenedCheckBox
|
||||
//
|
||||
this.CheckUpdateWhenOpenedCheckBox.AutoSize = true;
|
||||
this.CheckUpdateWhenOpenedCheckBox.Location = new System.Drawing.Point(200, 60);
|
||||
this.CheckUpdateWhenOpenedCheckBox.Location = new System.Drawing.Point(250, 75);
|
||||
this.CheckUpdateWhenOpenedCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.CheckUpdateWhenOpenedCheckBox.Name = "CheckUpdateWhenOpenedCheckBox";
|
||||
this.CheckUpdateWhenOpenedCheckBox.Size = new System.Drawing.Size(168, 16);
|
||||
this.CheckUpdateWhenOpenedCheckBox.Size = new System.Drawing.Size(221, 19);
|
||||
this.CheckUpdateWhenOpenedCheckBox.TabIndex = 5;
|
||||
this.CheckUpdateWhenOpenedCheckBox.Text = "Check update when opened";
|
||||
this.CheckUpdateWhenOpenedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
@@ -804,9 +889,10 @@ namespace Netch.Forms
|
||||
// CheckBetaUpdateCheckBox
|
||||
//
|
||||
this.CheckBetaUpdateCheckBox.AutoSize = true;
|
||||
this.CheckBetaUpdateCheckBox.Location = new System.Drawing.Point(200, 87);
|
||||
this.CheckBetaUpdateCheckBox.Location = new System.Drawing.Point(250, 109);
|
||||
this.CheckBetaUpdateCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.CheckBetaUpdateCheckBox.Name = "CheckBetaUpdateCheckBox";
|
||||
this.CheckBetaUpdateCheckBox.Size = new System.Drawing.Size(126, 16);
|
||||
this.CheckBetaUpdateCheckBox.Size = new System.Drawing.Size(165, 19);
|
||||
this.CheckBetaUpdateCheckBox.TabIndex = 6;
|
||||
this.CheckBetaUpdateCheckBox.Text = "Check Beta update";
|
||||
this.CheckBetaUpdateCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
@@ -815,9 +901,10 @@ namespace Netch.Forms
|
||||
// UpdateSubscribeatWhenOpenedCheckBox
|
||||
//
|
||||
this.UpdateSubscribeatWhenOpenedCheckBox.AutoSize = true;
|
||||
this.UpdateSubscribeatWhenOpenedCheckBox.Location = new System.Drawing.Point(200, 109);
|
||||
this.UpdateSubscribeatWhenOpenedCheckBox.Location = new System.Drawing.Point(250, 136);
|
||||
this.UpdateSubscribeatWhenOpenedCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.UpdateSubscribeatWhenOpenedCheckBox.Name = "UpdateSubscribeatWhenOpenedCheckBox";
|
||||
this.UpdateSubscribeatWhenOpenedCheckBox.Size = new System.Drawing.Size(204, 16);
|
||||
this.UpdateSubscribeatWhenOpenedCheckBox.Size = new System.Drawing.Size(269, 19);
|
||||
this.UpdateSubscribeatWhenOpenedCheckBox.TabIndex = 7;
|
||||
this.UpdateSubscribeatWhenOpenedCheckBox.Text = "Update subscribeat when opened";
|
||||
this.UpdateSubscribeatWhenOpenedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
@@ -831,10 +918,11 @@ namespace Netch.Forms
|
||||
this.AioDNSTabPage.Controls.Add(this.ChinaDNSTextBox);
|
||||
this.AioDNSTabPage.Controls.Add(this.OtherDNSLabel);
|
||||
this.AioDNSTabPage.Controls.Add(this.OtherDNSTextBox);
|
||||
this.AioDNSTabPage.Location = new System.Drawing.Point(4, 25);
|
||||
this.AioDNSTabPage.Location = new System.Drawing.Point(4, 33);
|
||||
this.AioDNSTabPage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.AioDNSTabPage.Name = "AioDNSTabPage";
|
||||
this.AioDNSTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.AioDNSTabPage.Size = new System.Drawing.Size(461, 325);
|
||||
this.AioDNSTabPage.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.AioDNSTabPage.Size = new System.Drawing.Size(578, 405);
|
||||
this.AioDNSTabPage.TabIndex = 5;
|
||||
this.AioDNSTabPage.Text = "AioDNS";
|
||||
this.AioDNSTabPage.UseVisualStyleBackColor = true;
|
||||
@@ -842,60 +930,67 @@ namespace Netch.Forms
|
||||
// AioDNSRuleRuleLabel
|
||||
//
|
||||
this.AioDNSRuleRuleLabel.AutoSize = true;
|
||||
this.AioDNSRuleRuleLabel.Location = new System.Drawing.Point(16, 27);
|
||||
this.AioDNSRuleRuleLabel.Location = new System.Drawing.Point(20, 34);
|
||||
this.AioDNSRuleRuleLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.AioDNSRuleRuleLabel.Name = "AioDNSRuleRuleLabel";
|
||||
this.AioDNSRuleRuleLabel.Size = new System.Drawing.Size(59, 12);
|
||||
this.AioDNSRuleRuleLabel.Size = new System.Drawing.Size(79, 15);
|
||||
this.AioDNSRuleRuleLabel.TabIndex = 0;
|
||||
this.AioDNSRuleRuleLabel.Text = "Rule File";
|
||||
//
|
||||
// AioDNSRulePathTextBox
|
||||
//
|
||||
this.AioDNSRulePathTextBox.Enabled = false;
|
||||
this.AioDNSRulePathTextBox.Location = new System.Drawing.Point(147, 24);
|
||||
this.AioDNSRulePathTextBox.Location = new System.Drawing.Point(184, 30);
|
||||
this.AioDNSRulePathTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.AioDNSRulePathTextBox.Name = "AioDNSRulePathTextBox";
|
||||
this.AioDNSRulePathTextBox.Size = new System.Drawing.Size(201, 21);
|
||||
this.AioDNSRulePathTextBox.Size = new System.Drawing.Size(250, 25);
|
||||
this.AioDNSRulePathTextBox.TabIndex = 1;
|
||||
//
|
||||
// ChinaDNSLabel
|
||||
//
|
||||
this.ChinaDNSLabel.AutoSize = true;
|
||||
this.ChinaDNSLabel.Location = new System.Drawing.Point(16, 73);
|
||||
this.ChinaDNSLabel.Location = new System.Drawing.Point(20, 91);
|
||||
this.ChinaDNSLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.ChinaDNSLabel.Name = "ChinaDNSLabel";
|
||||
this.ChinaDNSLabel.Size = new System.Drawing.Size(59, 12);
|
||||
this.ChinaDNSLabel.Size = new System.Drawing.Size(79, 15);
|
||||
this.ChinaDNSLabel.TabIndex = 2;
|
||||
this.ChinaDNSLabel.Text = "China DNS";
|
||||
//
|
||||
// ChinaDNSTextBox
|
||||
//
|
||||
this.ChinaDNSTextBox.Location = new System.Drawing.Point(147, 70);
|
||||
this.ChinaDNSTextBox.Location = new System.Drawing.Point(184, 88);
|
||||
this.ChinaDNSTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.ChinaDNSTextBox.Name = "ChinaDNSTextBox";
|
||||
this.ChinaDNSTextBox.Size = new System.Drawing.Size(201, 21);
|
||||
this.ChinaDNSTextBox.Size = new System.Drawing.Size(250, 25);
|
||||
this.ChinaDNSTextBox.TabIndex = 3;
|
||||
this.ChinaDNSTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// OtherDNSLabel
|
||||
//
|
||||
this.OtherDNSLabel.AutoSize = true;
|
||||
this.OtherDNSLabel.Location = new System.Drawing.Point(16, 109);
|
||||
this.OtherDNSLabel.Location = new System.Drawing.Point(20, 136);
|
||||
this.OtherDNSLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.OtherDNSLabel.Name = "OtherDNSLabel";
|
||||
this.OtherDNSLabel.Size = new System.Drawing.Size(59, 12);
|
||||
this.OtherDNSLabel.Size = new System.Drawing.Size(79, 15);
|
||||
this.OtherDNSLabel.TabIndex = 4;
|
||||
this.OtherDNSLabel.Text = "Other DNS";
|
||||
//
|
||||
// OtherDNSTextBox
|
||||
//
|
||||
this.OtherDNSTextBox.Location = new System.Drawing.Point(147, 106);
|
||||
this.OtherDNSTextBox.Location = new System.Drawing.Point(184, 132);
|
||||
this.OtherDNSTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.OtherDNSTextBox.Name = "OtherDNSTextBox";
|
||||
this.OtherDNSTextBox.Size = new System.Drawing.Size(201, 21);
|
||||
this.OtherDNSTextBox.Size = new System.Drawing.Size(250, 25);
|
||||
this.OtherDNSTextBox.TabIndex = 5;
|
||||
this.OtherDNSTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// ControlButton
|
||||
//
|
||||
this.ControlButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ControlButton.Location = new System.Drawing.Point(397, 363);
|
||||
this.ControlButton.Location = new System.Drawing.Point(496, 454);
|
||||
this.ControlButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.ControlButton.Name = "ControlButton";
|
||||
this.ControlButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.ControlButton.Size = new System.Drawing.Size(94, 29);
|
||||
this.ControlButton.TabIndex = 1;
|
||||
this.ControlButton.Text = "Save";
|
||||
this.ControlButton.UseVisualStyleBackColor = true;
|
||||
@@ -910,24 +1005,38 @@ namespace Netch.Forms
|
||||
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(480, 400);
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(600, 500);
|
||||
this.flowLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// NoProxyForUdpCheckBox
|
||||
//
|
||||
this.NoProxyForUdpCheckBox.AutoSize = true;
|
||||
this.NoProxyForUdpCheckBox.Location = new System.Drawing.Point(10, 108);
|
||||
this.NoProxyForUdpCheckBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.NoProxyForUdpCheckBox.Name = "NoProxyForUdpCheckBox";
|
||||
this.NoProxyForUdpCheckBox.Size = new System.Drawing.Size(157, 19);
|
||||
this.NoProxyForUdpCheckBox.TabIndex = 3;
|
||||
this.NoProxyForUdpCheckBox.Text = "No Proxy for Udp";
|
||||
this.NoProxyForUdpCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// SettingForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.AutoSize = true;
|
||||
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.ClientSize = new System.Drawing.Size(480, 400);
|
||||
this.ClientSize = new System.Drawing.Size(600, 500);
|
||||
this.Controls.Add(this.flowLayoutPanel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "SettingForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Settings";
|
||||
this.Load += new System.EventHandler(this.SettingForm2_Load);
|
||||
this.Load += new System.EventHandler(this.SettingForm_Load);
|
||||
this.TabControl.ResumeLayout(false);
|
||||
this.GeneralTabPage.ResumeLayout(false);
|
||||
this.GeneralTabPage.PerformLayout();
|
||||
@@ -1031,5 +1140,7 @@ namespace Netch.Forms
|
||||
private System.Windows.Forms.TextBox ChinaDNSTextBox;
|
||||
private System.Windows.Forms.TextBox ModifiedDNSTextBox;
|
||||
private System.Windows.Forms.Label ModifiedDNSLabel;
|
||||
private System.Windows.Forms.CheckBox RedirectorSSCheckBox;
|
||||
private System.Windows.Forms.CheckBox NoProxyForUdpCheckBox;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
using Netch.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TaskScheduler;
|
||||
|
||||
namespace Netch.Forms
|
||||
{
|
||||
@@ -20,8 +21,9 @@ namespace Netch.Forms
|
||||
}
|
||||
|
||||
|
||||
private void SettingForm2_Load(object sender, EventArgs e)
|
||||
private void SettingForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
TUNTAPUseCustomDNSCheckBox_CheckedChanged(null, null);
|
||||
Task.Run(() => BeginInvoke(new Action(() => UseFakeDNSCheckBox.Visible = Global.Flags.SupportFakeDns)));
|
||||
}
|
||||
|
||||
@@ -30,17 +32,17 @@ namespace Netch.Forms
|
||||
#region General
|
||||
|
||||
BindTextBox<ushort>(Socks5PortTextBox,
|
||||
p => CheckPort("Socks5", p, Global.Settings.Socks5LocalPort),
|
||||
p => p.ToString() != HTTPPortTextBox.Text && p.ToString() != RedirectorTextBox.Text,
|
||||
p => Global.Settings.Socks5LocalPort = p,
|
||||
Global.Settings.Socks5LocalPort);
|
||||
BindTextBox<ushort>(HTTPPortTextBox,
|
||||
p => CheckPort("HTTP", p, Global.Settings.HTTPLocalPort),
|
||||
p => p.ToString() != Socks5PortTextBox.Text && p.ToString() != RedirectorTextBox.Text,
|
||||
p => Global.Settings.HTTPLocalPort = p,
|
||||
Global.Settings.HTTPLocalPort);
|
||||
BindTextBox<ushort>(RedirectorTextBox,
|
||||
s => CheckPort("RedirectorTCP", s, Global.Settings.RedirectorTCPPort),
|
||||
s => Global.Settings.RedirectorTCPPort = s,
|
||||
Global.Settings.HTTPLocalPort);
|
||||
p => p.ToString() != Socks5PortTextBox.Text && p.ToString() != HTTPPortTextBox.Text,
|
||||
p => Global.Settings.RedirectorTCPPort = p,
|
||||
Global.Settings.RedirectorTCPPort);
|
||||
BindCheckBox(AllowDevicesCheckBox,
|
||||
c => Global.Settings.LocalAddress = AllowDevicesCheckBox.Checked ? "0.0.0.0" : "127.0.0.1",
|
||||
Global.Settings.LocalAddress switch
|
||||
@@ -50,7 +52,6 @@ namespace Netch.Forms
|
||||
_ => false
|
||||
});
|
||||
|
||||
|
||||
BindCheckBox(BootShadowsocksFromDLLCheckBox,
|
||||
c => Global.Settings.BootShadowsocksFromDLL = c,
|
||||
Global.Settings.BootShadowsocksFromDLL);
|
||||
@@ -89,11 +90,21 @@ namespace Netch.Forms
|
||||
b => Global.Settings.ModifySystemDNS = b,
|
||||
Global.Settings.ModifySystemDNS);
|
||||
|
||||
ModifySystemDNSCheckBox_CheckedChanged(null, null);
|
||||
|
||||
BindTextBox(ModifiedDNSTextBox,
|
||||
s => DNS.TrySplit(s, out _, 2),
|
||||
s => Global.Settings.ModifiedDNS = s,
|
||||
Global.Settings.ModifiedDNS);
|
||||
|
||||
BindCheckBox(RedirectorSSCheckBox,
|
||||
s => Global.Settings.RedirectorSS = s,
|
||||
Global.Settings.RedirectorSS);
|
||||
|
||||
BindCheckBox(NoProxyForUdpCheckBox,
|
||||
s => Global.Settings.ProcessNoProxyForUdp = s,
|
||||
Global.Settings.ProcessNoProxyForUdp);
|
||||
|
||||
#endregion
|
||||
|
||||
#region TUN/TAP
|
||||
@@ -117,7 +128,11 @@ namespace Netch.Forms
|
||||
|
||||
BindTextBox(TUNTAPDNSTextBox,
|
||||
s => !UseCustomDNSCheckBox.Checked || DNS.TrySplit(s, out _, 2),
|
||||
s => Global.Settings.TUNTAP.DNS = DNS.Split(s).ToList(),
|
||||
s =>
|
||||
{
|
||||
if (UseCustomDNSCheckBox.Checked)
|
||||
Global.Settings.TUNTAP.DNS = DNS.Split(s).ToList();
|
||||
},
|
||||
DNS.Join(Global.Settings.TUNTAP.DNS));
|
||||
|
||||
BindCheckBox(ProxyDNSCheckBox,
|
||||
@@ -279,34 +294,48 @@ namespace Netch.Forms
|
||||
|
||||
private void ControlButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!_checkActions.All(pair => pair.Value.Invoke(pair.Key.Text)))
|
||||
return;
|
||||
Utils.Utils.ComponentIterator(this, component => Utils.Utils.ChangeControlForeColor(component, Color.Black));
|
||||
|
||||
#region Check
|
||||
|
||||
#region Behavior
|
||||
|
||||
// STUN
|
||||
string stunServer;
|
||||
int stunServerPort;
|
||||
try
|
||||
var flag = true;
|
||||
foreach (var pair in _checkActions.Where(pair => !pair.Value.Invoke(pair.Key.Text)))
|
||||
{
|
||||
var stun = STUN_ServerComboBox.Text.Split(':');
|
||||
stunServer = stun[0];
|
||||
|
||||
stunServerPort = 3478;
|
||||
if (stun.Length > 1)
|
||||
stunServerPort = int.Parse(stun[1]);
|
||||
|
||||
if (stunServerPort <= 0)
|
||||
{
|
||||
throw new FormatException();
|
||||
}
|
||||
Utils.Utils.ChangeControlForeColor(pair.Key, Color.Red);
|
||||
flag = false;
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
MessageBoxX.Show(i18N.Translate("STUN_ServerPort value illegal. Try again."));
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#region CheckSTUN
|
||||
|
||||
var stunFlag = true;
|
||||
var stunServer = string.Empty;
|
||||
ushort stunServerPort = 3478;
|
||||
|
||||
var stun = STUN_ServerComboBox.Text.Split(':');
|
||||
|
||||
if (stun.Any())
|
||||
{
|
||||
stunServer = stun[0];
|
||||
if (stun.Length > 1)
|
||||
if (!ushort.TryParse(stun[1], out stunServerPort))
|
||||
{
|
||||
stunFlag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
stunFlag = false;
|
||||
}
|
||||
|
||||
if (!stunFlag)
|
||||
{
|
||||
Utils.Utils.ChangeControlForeColor(STUN_ServerComboBox, Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -323,70 +352,17 @@ namespace Netch.Forms
|
||||
|
||||
Global.Settings.STUN_Server = stunServer;
|
||||
Global.Settings.STUN_Server_Port = stunServerPort;
|
||||
Global.Settings.Language = LanguageComboBox.Text;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Register Startup Item
|
||||
|
||||
var scheduler = new TaskSchedulerClass();
|
||||
scheduler.Connect();
|
||||
var folder = scheduler.GetFolder("\\");
|
||||
|
||||
var taskIsExists = false;
|
||||
try
|
||||
{
|
||||
folder.GetTask("Netch Startup");
|
||||
taskIsExists = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
if (Global.Settings.RunAtStartup)
|
||||
{
|
||||
if (taskIsExists)
|
||||
folder.DeleteTask("Netch Startup", 0);
|
||||
|
||||
var task = scheduler.NewTask(0);
|
||||
task.RegistrationInfo.Author = "Netch";
|
||||
task.RegistrationInfo.Description = "Netch run at startup.";
|
||||
task.Principal.RunLevel = _TASK_RUNLEVEL.TASK_RUNLEVEL_HIGHEST;
|
||||
|
||||
task.Triggers.Create(_TASK_TRIGGER_TYPE2.TASK_TRIGGER_LOGON);
|
||||
var action = (IExecAction) task.Actions.Create(_TASK_ACTION_TYPE.TASK_ACTION_EXEC);
|
||||
action.Path = Application.ExecutablePath;
|
||||
|
||||
|
||||
task.Settings.ExecutionTimeLimit = "PT0S";
|
||||
task.Settings.DisallowStartIfOnBatteries = false;
|
||||
task.Settings.RunOnlyIfIdle = false;
|
||||
|
||||
folder.RegisterTaskDefinition("Netch Startup", task, (int) _TASK_CREATION.TASK_CREATE, null, null,
|
||||
_TASK_LOGON_TYPE.TASK_LOGON_INTERACTIVE_TOKEN, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (taskIsExists)
|
||||
folder.DeleteTask("Netch Startup", 0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
Utils.Utils.RegisterNetchStartupItem();
|
||||
|
||||
Configuration.Save();
|
||||
MessageBoxX.Show(i18N.Translate("Saved"));
|
||||
Close();
|
||||
}
|
||||
|
||||
private bool CheckPort(string portName, ushort port, ushort originPort, PortType portType = PortType.Both)
|
||||
{
|
||||
if (port == originPort) return true;
|
||||
if (!PortHelper.PortInUse(port, portType)) return true;
|
||||
|
||||
MessageBoxX.Show(i18N.TranslateFormat("The {0} port is in use.", portName));
|
||||
return false;
|
||||
}
|
||||
|
||||
private async void ICSCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using Netch.Controllers;
|
||||
using Netch.Forms;
|
||||
using Netch.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Netch.Controllers;
|
||||
using Netch.Forms;
|
||||
using Netch.Models;
|
||||
using WindowsJobAPI;
|
||||
|
||||
namespace Netch
|
||||
{
|
||||
@@ -87,5 +87,10 @@ namespace Netch
|
||||
/// 用于存储模式
|
||||
/// </summary>
|
||||
public static readonly List<Mode> Modes = new List<Mode>();
|
||||
|
||||
/// <summary>
|
||||
/// Windows Job API
|
||||
/// </summary>
|
||||
public static readonly JobObject Job = new JobObject();
|
||||
}
|
||||
}
|
||||
@@ -33,20 +33,6 @@ namespace Netch.Models
|
||||
/// </summary>
|
||||
public int Type = 0;
|
||||
|
||||
public bool SupportSocks5Auth => Type switch
|
||||
{
|
||||
0 => true,
|
||||
_ => false
|
||||
};
|
||||
|
||||
public bool TestNatRequired => Type switch
|
||||
{
|
||||
0 => true,
|
||||
1 => true,
|
||||
2 => true,
|
||||
_ => false
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 绕过中国(0. 不绕过 1. 绕过)
|
||||
/// </summary>
|
||||
@@ -131,44 +117,15 @@ namespace Netch.Models
|
||||
/// <returns>模式文件字符串</returns>
|
||||
public string ToFileString()
|
||||
{
|
||||
StringBuilder fileString = new StringBuilder();
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case 0:
|
||||
// 进程模式
|
||||
fileString.Append($"# {Remark}");
|
||||
break;
|
||||
case 1:
|
||||
// TUN/TAP 规则内 IP CIDR,无 Bypass China 设置
|
||||
fileString.Append($"# {Remark}, {Type}, 0");
|
||||
break;
|
||||
default:
|
||||
fileString.Append($"# {Remark}, {Type}, {(BypassChina ? 1 : 0)}");
|
||||
break;
|
||||
}
|
||||
|
||||
if (Rule.Any())
|
||||
{
|
||||
fileString.Append(Global.EOF);
|
||||
fileString.Append(string.Join(Global.EOF, Rule));
|
||||
}
|
||||
|
||||
return fileString.ToString();
|
||||
}
|
||||
|
||||
public string TypeToString()
|
||||
{
|
||||
return Type switch
|
||||
{
|
||||
0 => "Process",
|
||||
1 => "TUNTAP",
|
||||
2 => "TUNTAP",
|
||||
3 => "SYSTEM",
|
||||
4 => "S5",
|
||||
5 => "S5+HTTP",
|
||||
_ => "ERROR",
|
||||
};
|
||||
return $"# {Remark}, {Type}, {(BypassChina ? 1 : 0)}{Global.EOF}{string.Join(Global.EOF, Rule)}";
|
||||
}
|
||||
}
|
||||
public static class ModeExtension
|
||||
{
|
||||
/// 是否会转发 UDP
|
||||
public static bool TestNatRequired(this Mode mode) => mode.Type is 0 or 1 or 2;
|
||||
|
||||
/// Socks5 分流是否能被有效实施
|
||||
public static bool ClientRouting(this Mode mode) => mode.Type is not 1 or 2;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using Netch.Utils;
|
||||
|
||||
namespace Netch.Models
|
||||
{
|
||||
public class Server
|
||||
public class Server:ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// 备注
|
||||
@@ -47,14 +47,17 @@ namespace Netch.Models
|
||||
/// <returns>备注</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Remark))
|
||||
{
|
||||
Remark = $"{Hostname}:{Port}";
|
||||
}
|
||||
var remark = string.IsNullOrWhiteSpace(Remark) ? $"{Hostname}:{Port}" : Remark;
|
||||
|
||||
Group = Group.Equals("None") || Group.Equals("") ? "NONE" : Group;
|
||||
if (Group.Equals("None") || Group.Equals(""))
|
||||
Group = "NONE";
|
||||
|
||||
return $"[{ServerHelper.GetUtilByTypeName(Type)?.ShortName ?? "WTF"}][{Group}] {Remark}";
|
||||
return $"[{ServerHelper.GetUtilByTypeName(Type)?.ShortName ?? "WTF"}][{Group}] {remark}";
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return MemberwiseClone();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -253,5 +253,9 @@ namespace Netch.Models
|
||||
public V2rayConfig V2RayConfig = new V2rayConfig();
|
||||
|
||||
public AioDNSConfig AioDNS = new AioDNSConfig();
|
||||
|
||||
public bool RedirectorSS = false;
|
||||
|
||||
public bool ProcessNoProxyForUdp = false;
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,10 @@ namespace Netch
|
||||
{
|
||||
if (args.Contains("-console"))
|
||||
{
|
||||
NativeMethods.AllocConsole();
|
||||
NativeMethods.AttachConsole(-1);
|
||||
if (!NativeMethods.AttachConsole(-1))
|
||||
{
|
||||
NativeMethods.AllocConsole();
|
||||
}
|
||||
}
|
||||
|
||||
// 创建互斥体防止多次运行
|
||||
|
||||
@@ -67,11 +67,12 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ILMerge" Version="3.0.41" />
|
||||
<PackageReference Include="MaxMind.GeoIP2" Version="3.3.0" />
|
||||
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.61" />
|
||||
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.62" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="System.Collections.Immutable" Version="5.0.0-rc.2.20475.5" />
|
||||
<PackageReference Include="System.Reflection.Metadata" Version="5.0.0-rc.2.20475.5" />
|
||||
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
|
||||
<PackageReference Include="System.Reflection.Metadata" Version="5.0.0" />
|
||||
<PackageReference Include="WindowsAPICodePack-Shell" Version="1.1.1" />
|
||||
<PackageReference Include="WindowsJobAPI" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -155,6 +155,7 @@
|
||||
"Update subscribeat when opened": "自动更新订阅",
|
||||
"SS DLL": "SS DLL",
|
||||
"Modify System DNS": "修改系统 DNS",
|
||||
"No Proxy for Udp": "不代理Udp流量",
|
||||
"ProfileCount": "快捷配置数量",
|
||||
"ProfileCount value illegal. Try again.": "快捷配置数值非法。请重试。",
|
||||
"STUN_ServerPort value illegal. Try again.": "STUN 端口数值非法。请重试。",
|
||||
|
||||
@@ -11,18 +11,17 @@ namespace Netch.Servers.Shadowsocks
|
||||
public override string Name { get; protected set; } = "Shadowsocks";
|
||||
public override string MainFile { get; protected set; } = "Shadowsocks.exe";
|
||||
|
||||
public Server Server { get; set; }
|
||||
public ushort? Socks5LocalPort { get; set; }
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
private Mode _savedMode;
|
||||
public bool DllFlag => Global.Settings.BootShadowsocksFromDLL && (_savedMode.Type == 0 || _savedMode.Type == 1 || _savedMode.Type == 2);
|
||||
public bool DllFlag;
|
||||
|
||||
public bool Start(in Server s, in Mode mode)
|
||||
{
|
||||
_savedMode = mode;
|
||||
Server = s;
|
||||
var server = (Shadowsocks) s;
|
||||
|
||||
DllFlag = Global.Settings.BootShadowsocksFromDLL && mode.Type is 0 or 1 or 2 && !server.HasPlugin();
|
||||
|
||||
//从DLL启动Shaowsocks
|
||||
if (DllFlag)
|
||||
{
|
||||
@@ -76,14 +75,12 @@ namespace Netch.Servers.Shadowsocks
|
||||
|
||||
public override void Stop()
|
||||
{
|
||||
if (Instance == null)
|
||||
if (DllFlag)
|
||||
ShadowsocksDLL.Stop();
|
||||
else
|
||||
StopInstance();
|
||||
_savedMode = null;
|
||||
}
|
||||
|
||||
|
||||
private class ShadowsocksDLL
|
||||
{
|
||||
[DllImport("shadowsocks-windows-dynamic", CallingConvention = CallingConvention.Cdecl)]
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace Netch.Servers.Shadowsocks
|
||||
{
|
||||
Type = "SS";
|
||||
}
|
||||
|
||||
public bool HasPlugin() => !string.IsNullOrWhiteSpace(Plugin) && !string.IsNullOrWhiteSpace(PluginOption);
|
||||
}
|
||||
|
||||
public static class SSGlobal
|
||||
|
||||
@@ -11,13 +11,11 @@ namespace Netch.Servers.ShadowsocksR
|
||||
|
||||
public override string Name { get; protected set; } = "ShadowsocksR";
|
||||
|
||||
public Server Server { get; set; }
|
||||
public ushort? Socks5LocalPort { get; set; }
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
public bool Start(in Server s, in Mode mode)
|
||||
{
|
||||
Server = s;
|
||||
var server = (ShadowsocksR) s;
|
||||
|
||||
#region Argument
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
using Netch.Servers.Shadowsocks;
|
||||
using Netch.Servers.ShadowsocksR.Form;
|
||||
using Netch.Utils;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -100,6 +101,22 @@ namespace Netch.Servers.ShadowsocksR
|
||||
|
||||
var group = paramsDict.ContainsKey("group") ? ShareLink.URLSafeBase64Decode(paramsDict["group"]) : string.Empty;
|
||||
|
||||
if (SSGlobal.EncryptMethods.Contains(method) && protocol == "origin" && obfs == "plain")
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
new Shadowsocks.Shadowsocks
|
||||
{
|
||||
Hostname = serverAddr,
|
||||
Port = serverPort,
|
||||
EncryptMethod = method,
|
||||
Password = password,
|
||||
Remark = remarks,
|
||||
Group = group
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return new[]
|
||||
{
|
||||
new ShadowsocksR
|
||||
|
||||
@@ -12,9 +12,8 @@ namespace Netch.Servers.Socks5
|
||||
|
||||
public bool Start(in Server s, in Mode mode)
|
||||
{
|
||||
Server = s;
|
||||
var server = (Socks5) s;
|
||||
if (server.Auth() && !mode.SupportSocks5Auth)
|
||||
if (server.Auth())
|
||||
{
|
||||
File.WriteAllText("data\\last.json", V2rayConfigUtils.GenerateClientConfig(s, mode));
|
||||
if (StartInstanceAuto("-config ..\\data\\last.json"))
|
||||
@@ -34,7 +33,6 @@ namespace Netch.Servers.Socks5
|
||||
StopInstance();
|
||||
}
|
||||
|
||||
public Server Server { get; set; }
|
||||
public ushort? Socks5LocalPort { get; set; }
|
||||
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
@@ -18,20 +18,18 @@ namespace Netch.Servers.Trojan
|
||||
|
||||
public override string MainFile { get; protected set; } = "Trojan.exe";
|
||||
public override string Name { get; protected set; } = "Trojan";
|
||||
public Server Server { get; set; }
|
||||
public ushort? Socks5LocalPort { get; set; }
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
|
||||
public bool Start(in Server s, in Mode mode)
|
||||
{
|
||||
Server = s;
|
||||
var server = (Trojan) s;
|
||||
File.WriteAllText("data\\last.json", JsonConvert.SerializeObject(new TrojanConfig
|
||||
{
|
||||
local_addr = this.LocalAddress(),
|
||||
local_port = this.Socks5LocalPort(),
|
||||
remote_addr = server.AutoResolveHostname(),
|
||||
remote_addr = server.Hostname,
|
||||
remote_port = server.Port,
|
||||
password = new List<string>
|
||||
{
|
||||
|
||||
@@ -34,7 +34,6 @@ namespace Netch.Servers.VLESS
|
||||
|
||||
public class VLESSGlobal
|
||||
{
|
||||
|
||||
public static List<string> TransferProtocols => VMessGlobal.TransferProtocols;
|
||||
|
||||
public static readonly List<string> FakeTypes = new List<string>
|
||||
@@ -42,5 +41,12 @@ namespace Netch.Servers.VLESS
|
||||
"none",
|
||||
"http"
|
||||
};
|
||||
|
||||
public static readonly List<string> TLSSecure = new List<string>
|
||||
{
|
||||
"",
|
||||
"tls",
|
||||
"xtls"
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -10,14 +10,12 @@ namespace Netch.Servers.VLESS
|
||||
public override string Name { get; protected set; } = "VLESS";
|
||||
public override string MainFile { get; protected set; } = "v2ray.exe";
|
||||
|
||||
public Server Server { get; set; }
|
||||
public ushort? Socks5LocalPort { get; set; }
|
||||
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
public bool Start(in Server s,in Mode mode)
|
||||
{
|
||||
Server = s;
|
||||
File.WriteAllText("data\\last.json", V2rayConfigUtils.GenerateClientConfig(s, mode));
|
||||
return StartInstanceAuto("-config ..\\data\\last.json");
|
||||
}
|
||||
|
||||
@@ -48,10 +48,11 @@ namespace Netch.Servers.VLESS.VLESSForm
|
||||
"false" => false,
|
||||
_ => null
|
||||
},
|
||||
server.UseMux?.ToString() ?? "");
|
||||
CreateCheckBox("TLSSecure", "TLS Secure",
|
||||
b => server.TLSSecure = b,
|
||||
server.TLSSecure);
|
||||
server.UseMux?.ToString().ToLower() ?? "");
|
||||
CreateComboBox("TLSSecure", "TLS Secure",
|
||||
VLESSGlobal.TLSSecure,
|
||||
s => server.TLSSecureType = s,
|
||||
server.TLSSecureType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,10 +57,11 @@ namespace Netch.Servers.VMess.Form
|
||||
"false" => false,
|
||||
_ => null
|
||||
},
|
||||
server.UseMux?.ToString() ?? "");
|
||||
CreateCheckBox("TLSSecure", "TLS Secure",
|
||||
s => server.TLSSecure = s,
|
||||
server.TLSSecure);
|
||||
server.UseMux?.ToString().ToLower() ?? "");
|
||||
CreateComboBox("TLSSecure", "TLS Secure",
|
||||
VMessGlobal.TLSSecure,
|
||||
s => server.TLSSecureType = s,
|
||||
server.TLSSecureType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,8 +195,6 @@ namespace Netch.Servers.VMess.Models
|
||||
|
||||
public class TcpSettings
|
||||
{
|
||||
public bool connectionReuse { get; set; }
|
||||
|
||||
public Header header { get; set; }
|
||||
}
|
||||
|
||||
@@ -257,8 +255,6 @@ namespace Netch.Servers.VMess.Models
|
||||
|
||||
public class WsSettings
|
||||
{
|
||||
public bool connectionReuse { get; set; }
|
||||
|
||||
public string path { get; set; }
|
||||
|
||||
public Headers headers { get; set; }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Netch.Models;
|
||||
using Netch.Servers.VMess.Models;
|
||||
using Newtonsoft.Json;
|
||||
@@ -20,7 +21,7 @@ namespace Netch.Servers.VMess.Utils
|
||||
|
||||
outbound(server, mode, ref v2rayConfig);
|
||||
|
||||
return JsonConvert.SerializeObject(v2rayConfig);
|
||||
return JsonConvert.SerializeObject(v2rayConfig, Formatting.Indented, new JsonSerializerSettings {NullValueHandling = NullValueHandling.Ignore});
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -58,44 +59,72 @@ namespace Netch.Servers.VMess.Utils
|
||||
{
|
||||
try
|
||||
{
|
||||
RulesItem rulesItem;
|
||||
var directRuleObject = new RulesItem
|
||||
{
|
||||
type = "field",
|
||||
ip = new List<string>(),
|
||||
domain = new List<string>(),
|
||||
outboundTag = "direct"
|
||||
};
|
||||
|
||||
var blockRuleObject = new RulesItem
|
||||
{
|
||||
type = "field",
|
||||
ip = new List<string>(),
|
||||
domain = new List<string>(),
|
||||
outboundTag = "block"
|
||||
};
|
||||
|
||||
if (mode.BypassChina)
|
||||
{
|
||||
rulesItem = new RulesItem
|
||||
switch (mode.Type)
|
||||
{
|
||||
type = "field",
|
||||
ip = new List<string>
|
||||
{
|
||||
"geoip:cn",
|
||||
"geoip:private"
|
||||
},
|
||||
domain = new List<string>
|
||||
{
|
||||
"geosite:cn"
|
||||
},
|
||||
outboundTag = "direct"
|
||||
};
|
||||
case 0:
|
||||
directRuleObject.ip.Add("geoip:cn");
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
if (Global.Flags.SupportFakeDns && Global.Settings.TUNTAP.UseFakeDNS)
|
||||
directRuleObject.domain.Add("geosite:cn");
|
||||
else
|
||||
directRuleObject.ip.Add("geoip:cn");
|
||||
break;
|
||||
default:
|
||||
directRuleObject.domain.Add("geosite:cn");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (mode.Type is 0 or 1 or 2)
|
||||
{
|
||||
rulesItem = new RulesItem
|
||||
{
|
||||
type = "field",
|
||||
ip = new List<string>
|
||||
{
|
||||
"geoip:private"
|
||||
},
|
||||
outboundTag = "direct"
|
||||
};
|
||||
blockRuleObject.ip.Add("geoip:private");
|
||||
}
|
||||
|
||||
v2rayConfig.routing = new Routing
|
||||
{
|
||||
rules = new List<RulesItem>
|
||||
{
|
||||
rulesItem
|
||||
}
|
||||
rules = new List<RulesItem>()
|
||||
};
|
||||
|
||||
static bool CheckRuleItem(ref RulesItem rulesItem)
|
||||
{
|
||||
bool ipResult, domainResult;
|
||||
if (!(ipResult = rulesItem.ip.Any()))
|
||||
{
|
||||
rulesItem.ip = null;
|
||||
}
|
||||
|
||||
if (!(domainResult = rulesItem.domain.Any()))
|
||||
{
|
||||
rulesItem.domain = null;
|
||||
}
|
||||
|
||||
return ipResult || domainResult;
|
||||
}
|
||||
|
||||
if (CheckRuleItem(ref directRuleObject))
|
||||
v2rayConfig.routing.rules.Add(directRuleObject);
|
||||
if (CheckRuleItem(ref blockRuleObject))
|
||||
v2rayConfig.routing.rules.Add(blockRuleObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -121,31 +150,25 @@ namespace Netch.Servers.VMess.Utils
|
||||
{
|
||||
case Socks5.Socks5 socks5:
|
||||
{
|
||||
var serversItem = new ServersItem
|
||||
{
|
||||
users = new List<SocksUsersItem>()
|
||||
};
|
||||
outbound.settings.servers = new List<ServersItem>
|
||||
{
|
||||
serversItem
|
||||
};
|
||||
|
||||
serversItem.address = server.AutoResolveHostname();
|
||||
serversItem.port = server.Port;
|
||||
serversItem.method = null;
|
||||
serversItem.password = null;
|
||||
|
||||
if (socks5.Auth())
|
||||
{
|
||||
var socksUsersItem = new SocksUsersItem
|
||||
new ServersItem
|
||||
{
|
||||
user = socks5.Username,
|
||||
pass = socks5.Password,
|
||||
level = 1
|
||||
};
|
||||
|
||||
serversItem.users.Add(socksUsersItem);
|
||||
}
|
||||
users = socks5.Auth()
|
||||
? new List<SocksUsersItem>
|
||||
{
|
||||
new SocksUsersItem
|
||||
{
|
||||
user = socks5.Username,
|
||||
pass = socks5.Password,
|
||||
level = 1
|
||||
}
|
||||
}
|
||||
: null,
|
||||
address = server.AutoResolveHostname(),
|
||||
port = server.Port
|
||||
}
|
||||
};
|
||||
|
||||
outbound.mux.enabled = false;
|
||||
outbound.mux.concurrency = -1;
|
||||
@@ -156,37 +179,36 @@ namespace Netch.Servers.VMess.Utils
|
||||
{
|
||||
var vnextItem = new VnextItem
|
||||
{
|
||||
users = new List<UsersItem>()
|
||||
users = new List<UsersItem>(),
|
||||
address = server.AutoResolveHostname(),
|
||||
port = server.Port
|
||||
};
|
||||
outbound.settings.vnext = new List<VnextItem>
|
||||
outbound.settings.vnext = new List<VnextItem> {vnextItem};
|
||||
|
||||
var usersItem = new UsersItem
|
||||
{
|
||||
vnextItem
|
||||
id = vless.UserID,
|
||||
alterId = 0,
|
||||
flow = string.Empty,
|
||||
encryption = vless.EncryptMethod
|
||||
};
|
||||
|
||||
vnextItem.address = server.AutoResolveHostname();
|
||||
vnextItem.port = server.Port;
|
||||
|
||||
var usersItem = new UsersItem();
|
||||
vnextItem.users.Add(usersItem);
|
||||
|
||||
usersItem.id = vless.UserID;
|
||||
usersItem.alterId = 0;
|
||||
usersItem.flow = string.Empty;
|
||||
usersItem.encryption = vless.EncryptMethod;
|
||||
|
||||
outbound.mux.enabled = vless.UseMux ?? Global.Settings.V2RayConfig.UseMux;
|
||||
outbound.mux.concurrency = vless.UseMux ?? Global.Settings.V2RayConfig.UseMux ? 8 : -1;
|
||||
|
||||
var streamSettings = outbound.streamSettings;
|
||||
boundStreamSettings(vless, ref streamSettings);
|
||||
|
||||
if (vless.TransferProtocol == "xtls")
|
||||
if (vless.TLSSecureType == "xtls")
|
||||
{
|
||||
usersItem.flow = string.IsNullOrEmpty(vless.Flow) ? "xtls-rprx-origin" : vless.Flow;
|
||||
|
||||
outbound.mux.enabled = false;
|
||||
outbound.mux.concurrency = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
outbound.mux.enabled = vless.UseMux ?? Global.Settings.V2RayConfig.UseMux;
|
||||
outbound.mux.concurrency = vless.UseMux ?? Global.Settings.V2RayConfig.UseMux ? 8 : -1;
|
||||
}
|
||||
|
||||
outbound.protocol = "vless";
|
||||
outbound.settings.servers = null;
|
||||
@@ -196,29 +218,25 @@ namespace Netch.Servers.VMess.Utils
|
||||
{
|
||||
var vnextItem = new VnextItem
|
||||
{
|
||||
users = new List<UsersItem>()
|
||||
users = new List<UsersItem>(),
|
||||
address = server.AutoResolveHostname(),
|
||||
port = server.Port
|
||||
};
|
||||
outbound.settings.vnext = new List<VnextItem>
|
||||
outbound.settings.vnext = new List<VnextItem> {vnextItem};
|
||||
|
||||
var usersItem = new UsersItem
|
||||
{
|
||||
vnextItem
|
||||
id = vmess.UserID,
|
||||
alterId = vmess.AlterID,
|
||||
security = vmess.EncryptMethod
|
||||
};
|
||||
|
||||
vnextItem.address = server.AutoResolveHostname();
|
||||
vnextItem.port = server.Port;
|
||||
|
||||
var usersItem = new UsersItem();
|
||||
vnextItem.users.Add(usersItem);
|
||||
|
||||
usersItem.id = vmess.UserID;
|
||||
usersItem.alterId = vmess.AlterID;
|
||||
usersItem.security = vmess.EncryptMethod;
|
||||
|
||||
outbound.mux.enabled = vmess.UseMux ?? Global.Settings.V2RayConfig.UseMux;
|
||||
outbound.mux.concurrency = vmess.UseMux ?? Global.Settings.V2RayConfig.UseMux ? 8 : -1;
|
||||
|
||||
var streamSettings = outbound.streamSettings;
|
||||
boundStreamSettings(vmess, ref streamSettings);
|
||||
|
||||
outbound.mux.enabled = vmess.UseMux ?? Global.Settings.V2RayConfig.UseMux;
|
||||
outbound.mux.concurrency = vmess.UseMux ?? Global.Settings.V2RayConfig.UseMux ? 8 : -1;
|
||||
outbound.protocol = "vmess";
|
||||
break;
|
||||
}
|
||||
@@ -229,8 +247,11 @@ namespace Netch.Servers.VMess.Utils
|
||||
outbound,
|
||||
new Outbounds
|
||||
{
|
||||
tag = "direct",
|
||||
protocol = "freedom"
|
||||
tag = "direct", protocol = "freedom"
|
||||
},
|
||||
new Outbounds
|
||||
{
|
||||
tag = "block", protocol = "blackhole"
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -245,25 +266,24 @@ namespace Netch.Servers.VMess.Utils
|
||||
try
|
||||
{
|
||||
streamSettings.network = server.TransferProtocol;
|
||||
var host = server.Host;
|
||||
if (server.TLSSecure)
|
||||
{
|
||||
streamSettings.security = "tls";
|
||||
|
||||
if ((streamSettings.security = server.TLSSecureType) != "")
|
||||
{
|
||||
var tlsSettings = new TlsSettings
|
||||
{
|
||||
allowInsecure = Global.Settings.V2RayConfig.AllowInsecure
|
||||
allowInsecure = Global.Settings.V2RayConfig.AllowInsecure,
|
||||
serverName = !string.IsNullOrWhiteSpace(server.Host) ? server.Host : null
|
||||
};
|
||||
if (!string.IsNullOrWhiteSpace(host))
|
||||
{
|
||||
tlsSettings.serverName = host;
|
||||
}
|
||||
|
||||
streamSettings.tlsSettings = tlsSettings;
|
||||
}
|
||||
else
|
||||
{
|
||||
streamSettings.security = "";
|
||||
switch (server.TLSSecureType)
|
||||
{
|
||||
case "tls":
|
||||
streamSettings.tlsSettings = tlsSettings;
|
||||
break;
|
||||
case "xtls":
|
||||
streamSettings.xtlsSettings = tlsSettings;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (server.TransferProtocol)
|
||||
@@ -285,21 +305,15 @@ namespace Netch.Servers.VMess.Utils
|
||||
seed = !string.IsNullOrWhiteSpace(server.Path) ? server.Path : null
|
||||
};
|
||||
|
||||
|
||||
streamSettings.kcpSettings = kcpSettings;
|
||||
break;
|
||||
case "ws":
|
||||
var path = server.Path;
|
||||
var wsSettings = new WsSettings
|
||||
{
|
||||
connectionReuse = true,
|
||||
headers = !string.IsNullOrWhiteSpace(host)
|
||||
? new Headers
|
||||
{
|
||||
Host = host
|
||||
}
|
||||
headers = !string.IsNullOrWhiteSpace(server.Host)
|
||||
? new Headers {Host = server.Host}
|
||||
: null,
|
||||
path = !string.IsNullOrWhiteSpace(path) ? path : null
|
||||
path = !string.IsNullOrWhiteSpace(server.Path) ? server.Path : null
|
||||
};
|
||||
|
||||
streamSettings.wsSettings = wsSettings;
|
||||
@@ -319,40 +333,27 @@ namespace Netch.Servers.VMess.Utils
|
||||
case "quic":
|
||||
var quicSettings = new QuicSettings
|
||||
{
|
||||
security = host,
|
||||
security = server.Host,
|
||||
key = server.Path,
|
||||
header = new Header
|
||||
{
|
||||
type = server.FakeType
|
||||
}
|
||||
};
|
||||
if (server.TLSSecure)
|
||||
|
||||
if (server.TLSSecureType != "")
|
||||
{
|
||||
// tls or xtls
|
||||
streamSettings.tlsSettings.serverName = server.Hostname;
|
||||
}
|
||||
|
||||
streamSettings.quicSettings = quicSettings;
|
||||
break;
|
||||
case "xtls":
|
||||
streamSettings.security = server.TransferProtocol;
|
||||
|
||||
var xtlsSettings = new TlsSettings
|
||||
{
|
||||
allowInsecure = Global.Settings.V2RayConfig.AllowInsecure
|
||||
};
|
||||
if (!string.IsNullOrWhiteSpace(host))
|
||||
{
|
||||
xtlsSettings.serverName = host;
|
||||
}
|
||||
|
||||
streamSettings.xtlsSettings = xtlsSettings;
|
||||
break;
|
||||
default:
|
||||
if (server.FakeType == "http")
|
||||
{
|
||||
var tcpSettings = new TcpSettings
|
||||
{
|
||||
connectionReuse = true,
|
||||
header = new Header
|
||||
{
|
||||
type = server.FakeType,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Netch.Models;
|
||||
|
||||
@@ -64,7 +65,7 @@ namespace Netch.Servers.VMess
|
||||
/// <summary>
|
||||
/// TLS 底层传输安全
|
||||
/// </summary>
|
||||
public bool TLSSecure { get; set; } = false;
|
||||
public string TLSSecureType { get; set; } = VMessGlobal.TLSSecure[0];
|
||||
|
||||
/// <summary>
|
||||
/// Mux 多路复用
|
||||
@@ -114,5 +115,14 @@ namespace Netch.Servers.VMess
|
||||
"dtls",
|
||||
"wireguard"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// TLS 安全类型
|
||||
/// </summary>
|
||||
public static readonly List<string> TLSSecure = new List<string>
|
||||
{
|
||||
"",
|
||||
"tls"
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -15,14 +15,12 @@ namespace Netch.Servers.VMess
|
||||
|
||||
public override string Name { get; protected set; } = "VMess";
|
||||
public override string MainFile { get; protected set; } = "v2ray.exe";
|
||||
public Server Server { get; set; }
|
||||
public ushort? Socks5LocalPort { get; set; }
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
|
||||
public bool Start(in Server s,in Mode mode)
|
||||
{
|
||||
Server = s;
|
||||
File.WriteAllText("data\\last.json", V2rayConfigUtils.GenerateClientConfig(s, mode));
|
||||
return StartInstanceAuto("-config ..\\data\\last.json");
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Netch.Servers.VMess
|
||||
type = server.FakeType,
|
||||
host = server.Host,
|
||||
path = server.Path,
|
||||
tls = server.TLSSecure ? "tls" : ""
|
||||
tls = server.TLSSecureType
|
||||
});
|
||||
return "vmess://" + ShareLink.URLSafeBase64Encode(vmessJson);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ namespace Netch.Servers.VMess
|
||||
data.Path = vmess.path;
|
||||
}
|
||||
|
||||
data.TLSSecure = vmess.tls == "tls";
|
||||
data.TLSSecureType = vmess.tls;
|
||||
data.EncryptMethod = "auto"; // V2Ray 加密方式不包括在链接中,主动添加一个
|
||||
|
||||
return CheckServer(data) ? new[] {data} : null;
|
||||
|
||||
@@ -8,6 +8,7 @@ using Microsoft.Diagnostics.Tracing.Session;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
using Netch.Servers.Shadowsocks;
|
||||
using Netch.Servers.Socks5;
|
||||
|
||||
namespace Netch.Utils
|
||||
{
|
||||
@@ -63,26 +64,28 @@ namespace Netch.Utils
|
||||
|
||||
//var processList = Process.GetProcessesByName(ProcessName).Select(p => p.Id).ToHashSet();
|
||||
var instances = new List<Process>();
|
||||
if (server.Type.Equals("Socks5") && MainController.ModeController.Name == "HTTP")
|
||||
switch (MainController.ServerController)
|
||||
{
|
||||
instances.Add(((HTTPController) MainController.ModeController).pPrivoxyController.Instance);
|
||||
}
|
||||
else if (MainController.ServerController != null)
|
||||
{
|
||||
switch (MainController.ServerController)
|
||||
{
|
||||
case SSController ssController when ssController.DllFlag:
|
||||
instances.Add(Process.GetCurrentProcess());
|
||||
break;
|
||||
case Guard instanceController:
|
||||
case null:
|
||||
break;
|
||||
case SSController ssController when ssController.DllFlag:
|
||||
instances.Add(Process.GetCurrentProcess());
|
||||
break;
|
||||
case Guard instanceController:
|
||||
if (instanceController.Instance != null)
|
||||
instances.Add(instanceController.Instance);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (MainController.ModeController != null)
|
||||
|
||||
if (!instances.Any())
|
||||
{
|
||||
switch (MainController.ModeController)
|
||||
{
|
||||
case null:
|
||||
break;
|
||||
case HTTPController httpController:
|
||||
instances.Add(httpController.pPrivoxyController.Instance);
|
||||
break;
|
||||
case NFController _:
|
||||
instances.Add(Process.GetCurrentProcess());
|
||||
break;
|
||||
|
||||
@@ -30,14 +30,14 @@ namespace Netch.Utils
|
||||
Global.Settings = settingJObject?.ToObject<Setting>() ?? new Setting();
|
||||
Global.Settings.Server.Clear();
|
||||
|
||||
foreach (JObject server in settingJObject["Server"])
|
||||
{
|
||||
var serverResult = ServerHelper.ParseJObject(server);
|
||||
if (serverResult != null)
|
||||
Global.Settings.Server.Add(serverResult);
|
||||
}
|
||||
if (settingJObject?["Server"] != null)
|
||||
foreach (JObject server in settingJObject["Server"])
|
||||
{
|
||||
var serverResult = ServerHelper.ParseJObject(server);
|
||||
if (serverResult != null)
|
||||
Global.Settings.Server.Add(serverResult);
|
||||
}
|
||||
}
|
||||
|
||||
catch (JsonException)
|
||||
{
|
||||
}
|
||||
@@ -62,7 +62,15 @@ namespace Netch.Utils
|
||||
Directory.CreateDirectory(DATA_DIR);
|
||||
}
|
||||
|
||||
File.WriteAllText(SETTINGS_JSON, JsonConvert.SerializeObject(Global.Settings, Formatting.Indented));
|
||||
File.WriteAllText(SETTINGS_JSON,
|
||||
JsonConvert.SerializeObject(
|
||||
Global.Settings,
|
||||
Formatting.Indented,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ using System.Linq;
|
||||
using Netch.Controllers;
|
||||
using Netch.Forms;
|
||||
using Netch.Models;
|
||||
using Netch.Servers.Shadowsocks;
|
||||
using Netch.Servers.Socks5;
|
||||
|
||||
namespace Netch.Utils
|
||||
{
|
||||
@@ -66,17 +68,19 @@ namespace Netch.Utils
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
if (text.First() != '#')
|
||||
return;
|
||||
try
|
||||
{
|
||||
var splited = text.Substring(text.IndexOf('#') + 1).Split(',').Select(s => s.Trim()).ToArray();
|
||||
var splited = text.Substring(1).Split(',').Select(s => s.Trim()).ToArray();
|
||||
|
||||
mode.Remark = splited[0];
|
||||
|
||||
var result = int.TryParse(splited.ElementAtOrDefault(1), out var type);
|
||||
mode.Type = result ? type : 0;
|
||||
var typeResult = int.TryParse(splited.ElementAtOrDefault(1), out var type);
|
||||
mode.Type = typeResult ? type : 0;
|
||||
|
||||
var result1 = int.TryParse(splited.ElementAtOrDefault(2), out var bypassChina);
|
||||
mode.BypassChina = result1 && bypassChina == 1;
|
||||
var bypassChinaResult = int.TryParse(splited.ElementAtOrDefault(2), out var bypassChina);
|
||||
mode.BypassChina = mode.ClientRouting() && bypassChinaResult && bypassChina == 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -135,6 +139,21 @@ namespace Netch.Utils
|
||||
Global.MainForm.InitMode();
|
||||
}
|
||||
|
||||
|
||||
public static bool SkipServerController(Server server, Mode mode)
|
||||
{
|
||||
return mode.Type switch
|
||||
{
|
||||
0 => server switch
|
||||
{
|
||||
Socks5 => true,
|
||||
Shadowsocks shadowsocks when !shadowsocks.HasPlugin() && Global.Settings.RedirectorSS => true,
|
||||
_ => false
|
||||
},
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
public static IModeController GetModeControllerByType(int type, out ushort? port, out string portName, out PortType portType)
|
||||
{
|
||||
IModeController modeController;
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Netch.Servers.Shadowsocks;
|
||||
using Netch.Servers.Shadowsocks.Models;
|
||||
using Netch.Servers.VMess;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Server = Netch.Models.Server;
|
||||
@@ -233,7 +234,8 @@ namespace Netch.Utils
|
||||
|
||||
public static string GetNetchLink(Server s)
|
||||
{
|
||||
return "Netch://" + URLSafeBase64Encode(JsonConvert.SerializeObject(s));
|
||||
var server = (Server) s.Clone();
|
||||
return "Netch://" + URLSafeBase64Encode(JsonConvert.SerializeObject(server, new JsonSerializerSettings {NullValueHandling = NullValueHandling.Ignore}));
|
||||
}
|
||||
}
|
||||
}
|
||||
57
Netch/Utils/Subscription.cs
Normal file
57
Netch/Utils/Subscription.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Netch.Models;
|
||||
|
||||
namespace Netch.Utils
|
||||
{
|
||||
public static class Subscription
|
||||
{
|
||||
private static readonly object ServerLock = new object();
|
||||
|
||||
public static async Task UpdateServersAsync(string proxyServer = default)
|
||||
{
|
||||
await Task.WhenAll(
|
||||
Global.Settings.SubscribeLink.Select(item =>
|
||||
Task.Run(() => UpdateServer(item, proxyServer))
|
||||
).ToArray()
|
||||
);
|
||||
}
|
||||
|
||||
public static void UpdateServer(SubscribeLink item, string proxyServer)
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = WebUtil.CreateRequest(item.Link);
|
||||
|
||||
if (!string.IsNullOrEmpty(item.UserAgent)) request.UserAgent = item.UserAgent;
|
||||
if (!string.IsNullOrEmpty(proxyServer)) request.Proxy = new WebProxy(proxyServer);
|
||||
|
||||
List<Server> servers;
|
||||
|
||||
var result = WebUtil.DownloadString(request, out var rep);
|
||||
if (rep.StatusCode == HttpStatusCode.OK)
|
||||
servers = ShareLink.ParseText(result);
|
||||
else
|
||||
throw new Exception($"{item.Remark} Response Status Code: {rep.StatusCode}");
|
||||
|
||||
foreach (var server in servers) server.Group = item.Remark;
|
||||
|
||||
lock (ServerLock)
|
||||
{
|
||||
Global.Settings.Server.RemoveAll(server => server.Group.Equals(item.Remark));
|
||||
Global.Settings.Server.AddRange(servers);
|
||||
}
|
||||
|
||||
Global.MainForm.NotifyTip(i18N.TranslateFormat("Update {1} server(s) from {0}", item.Remark, servers.Count));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Global.MainForm.NotifyTip($"{i18N.TranslateFormat("Update servers error from {0}", item.Remark)}\n{e.Message}", info: false);
|
||||
Logging.Error(e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
@@ -7,10 +7,12 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using MaxMind.GeoIP2;
|
||||
using TaskScheduler;
|
||||
|
||||
namespace Netch.Utils
|
||||
{
|
||||
@@ -37,12 +39,12 @@ namespace Netch.Utils
|
||||
public static async Task<int> TCPingAsync(IPAddress ip, int port, int timeout = 1000, CancellationToken ct = default)
|
||||
{
|
||||
using var client = new TcpClient(ip.AddressFamily);
|
||||
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
|
||||
var task = client.ConnectAsync(ip, port);
|
||||
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
|
||||
var resTask = await Task.WhenAny(Task.Delay(timeout, ct), task);
|
||||
var resTask = await Task.WhenAny(task, Task.Delay(timeout, ct));
|
||||
|
||||
stopwatch.Stop();
|
||||
if (resTask == task && client.Connected)
|
||||
@@ -96,7 +98,7 @@ namespace Netch.Utils
|
||||
{
|
||||
try
|
||||
{
|
||||
var sha256 = System.Security.Cryptography.SHA256.Create();
|
||||
var sha256 = SHA256.Create();
|
||||
var fileStream = File.OpenRead(filePath);
|
||||
return sha256.ComputeHash(fileStream).Aggregate(string.Empty, (current, b) => current + b.ToString("x2"));
|
||||
}
|
||||
@@ -237,5 +239,62 @@ namespace Netch.Utils
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void RegisterNetchStartupItem()
|
||||
{
|
||||
var scheduler = new TaskSchedulerClass();
|
||||
scheduler.Connect();
|
||||
var folder = scheduler.GetFolder("\\");
|
||||
|
||||
var taskIsExists = false;
|
||||
try
|
||||
{
|
||||
folder.GetTask("Netch Startup");
|
||||
taskIsExists = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
if (Global.Settings.RunAtStartup)
|
||||
{
|
||||
if (taskIsExists)
|
||||
folder.DeleteTask("Netch Startup", 0);
|
||||
|
||||
var task = scheduler.NewTask(0);
|
||||
task.RegistrationInfo.Author = "Netch";
|
||||
task.RegistrationInfo.Description = "Netch run at startup.";
|
||||
task.Principal.RunLevel = _TASK_RUNLEVEL.TASK_RUNLEVEL_HIGHEST;
|
||||
|
||||
task.Triggers.Create(_TASK_TRIGGER_TYPE2.TASK_TRIGGER_LOGON);
|
||||
var action = (IExecAction) task.Actions.Create(_TASK_ACTION_TYPE.TASK_ACTION_EXEC);
|
||||
action.Path = Application.ExecutablePath;
|
||||
|
||||
|
||||
task.Settings.ExecutionTimeLimit = "PT0S";
|
||||
task.Settings.DisallowStartIfOnBatteries = false;
|
||||
task.Settings.RunOnlyIfIdle = false;
|
||||
|
||||
folder.RegisterTaskDefinition("Netch Startup", task, (int) _TASK_CREATION.TASK_CREATE, null, null,
|
||||
_TASK_LOGON_TYPE.TASK_LOGON_INTERACTIVE_TOKEN, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (taskIsExists)
|
||||
folder.DeleteTask("Netch Startup", 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ChangeControlForeColor(Component component, Color color)
|
||||
{
|
||||
switch (component)
|
||||
{
|
||||
case TextBox _:
|
||||
case ComboBox _:
|
||||
if (((Control) component).ForeColor != color) ((Control) component).ForeColor = color;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,13 @@ namespace Netch.Utils
|
||||
{
|
||||
public static class WebUtil
|
||||
{
|
||||
static WebUtil()
|
||||
{
|
||||
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;
|
||||
}
|
||||
|
||||
public const string DefaultUserAgent =
|
||||
@"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36";
|
||||
@"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.67 Safari/537.36 Edg/87.0.664.55";
|
||||
|
||||
private static int DefaultGetTimeout => Global.Settings.RequestTimeout;
|
||||
|
||||
@@ -94,4 +99,4 @@ namespace Netch.Utils
|
||||
fileStream.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,67 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Platforms>x86;x64</Platforms>
|
||||
<ProjectGuid>{A8715AF4-ACC6-43F9-9381-4294C5360623}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NetchLib</RootNamespace>
|
||||
<AssemblyName>NetchLib</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<NoWarn />
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors />
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<NoWarn />
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors />
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<NoWarn />
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors />
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SearchComboBox.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<Platforms>x64</Platforms>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -75,7 +75,7 @@ namespace System.Windows.Forms
|
||||
|
||||
private bool IsOriginalItems => Items.Count == AutoFillTag.Length;
|
||||
|
||||
private void ResetCompletionList()
|
||||
public void ResetCompletionList()
|
||||
{
|
||||
Keyword = null;
|
||||
try
|
||||
|
||||
@@ -41,9 +41,7 @@ As well, Netch avoid the restricted NAT problem caused by SSTap. You can use an
|
||||
|
||||
- [RabbitHosts](https://rabbithosts.com/cart.php)
|
||||
- [ManSora](https://www.mansora.co/cart.php)
|
||||
- [ExCloud](https://excloud.net/cart.php)
|
||||
- [NyanCat](https://nyancat.info/register)
|
||||
- [YoYu](https://home.yoyu.ltd/cart.php)
|
||||
|
||||
## Donate
|
||||
- XMR *48ju3ELNZEa6wwPBMexCJ9G218BGY2XwhH6B6bmkFuJ3QgM4hPw2Pra35jPtuBZSc7SLNWeBpiWJZWjQeMAiLnTx2tH2Efx*
|
||||
|
||||
2
binaries
2
binaries
Submodule binaries updated: d80fcdead2...4525fe9c71
@@ -44,9 +44,7 @@ Netch 是一款 Windows 平台的开源游戏加速工具,Netch 可以实现
|
||||
|
||||
- [RabbitHosts](https://rabbithosts.com/cart.php)
|
||||
- [ManSora](https://www.mansora.co/cart.php)
|
||||
- [ExCloud](https://excloud.net/cart.php)
|
||||
- [NyanCat](https://nyancat.info/register)
|
||||
- [YoYu](https://home.yoyu.ltd/cart.php)
|
||||
|
||||
## 捐赠
|
||||
- XMR *48ju3ELNZEa6wwPBMexCJ9G218BGY2XwhH6B6bmkFuJ3QgM4hPw2Pra35jPtuBZSc7SLNWeBpiWJZWjQeMAiLnTx2tH2Efx*
|
||||
|
||||
2
modes
2
modes
Submodule modes updated: 3ac9f3c380...90ffd0c66a
Reference in New Issue
Block a user