Skip to content

Commit

Permalink
Add non system proxy feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Connection Refused authored and Connection Refused committed Jul 20, 2019
1 parent f9391b2 commit 7ba2732
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
13 changes: 8 additions & 5 deletions Netch/Controllers/HTTPController.cs
Expand Up @@ -36,13 +36,16 @@ public bool Start(Objects.Server server, Objects.Mode mode)
Instance.Start(server, mode);
}

using (var registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true))
if (mode.Type != 5)
{
registry.SetValue("ProxyEnable", 1);
registry.SetValue("ProxyServer", "127.0.0.1:2802");
using (var registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true))
{
registry.SetValue("ProxyEnable", 1);
registry.SetValue("ProxyServer", "127.0.0.1:2802");

Win32Native.InternetSetOption(IntPtr.Zero, 39, IntPtr.Zero, 0);
Win32Native.InternetSetOption(IntPtr.Zero, 37, IntPtr.Zero, 0);
Win32Native.InternetSetOption(IntPtr.Zero, 39, IntPtr.Zero, 0);
Win32Native.InternetSetOption(IntPtr.Zero, 37, IntPtr.Zero, 0);
}
}
}
catch (Exception e)
Expand Down
14 changes: 11 additions & 3 deletions Netch/Controllers/MainController.cs
Expand Up @@ -92,10 +92,18 @@ public bool Start(Objects.Server server, Objects.Mode mode)
{
result = pTUNTAPController.Start(server, mode);
}
else if (mode.Type == 3)
else if (mode.Type == 3 || mode.Type == 5)
{
result = pHTTPController.Start(server, mode);
}
else if (mode.Type == 4)
{
// 跳过
}
else
{
result = false;
}
}

if (!result)
Expand All @@ -111,12 +119,12 @@ public bool Start(Objects.Server server, Objects.Mode mode)
/// </summary>
public void Stop()
{
pNFController.Stop();
pSSController.Stop();
pSSRController.Stop();
pVMessController.Stop();
pTUNTAPController.Stop();
pNFController.Stop();
pHTTPController.Stop();
pTUNTAPController.Stop();
}
}
}
10 changes: 5 additions & 5 deletions Netch/Netch.csproj
Expand Up @@ -226,11 +226,11 @@
<Compile Include="Forms\Mode\Process.Designer.cs">
<DependentUpon>Process.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Server\Vmess.cs">
<Compile Include="Forms\Server\VMess.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\Server\Vmess.Designer.cs">
<DependentUpon>Vmess.cs</DependentUpon>
<Compile Include="Forms\Server\VMess.Designer.cs">
<DependentUpon>VMess.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Server\ShadowsocksR.cs">
<SubType>Form</SubType>
Expand Down Expand Up @@ -297,8 +297,8 @@
<EmbeddedResource Include="Forms\Mode\Process.resx">
<DependentUpon>Process.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Server\Vmess.resx">
<DependentUpon>Vmess.cs</DependentUpon>
<EmbeddedResource Include="Forms\Server\VMess.resx">
<DependentUpon>VMess.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Server\ShadowsocksR.resx">
<DependentUpon>ShadowsocksR.cs</DependentUpon>
Expand Down
8 changes: 7 additions & 1 deletion Netch/Objects/Mode.cs
Expand Up @@ -11,7 +11,13 @@ public class Mode
public string Remark;

/// <summary>
/// 类型(0. 进程加速 1. TUN/TAP IP 加速 2. TUN/TAP 全局代理绕过 IP 地址 3. 系统代理 1000. 只启动 Socks5 代理)
/// 类型
/// 0. 进程加速
/// 1. TUN/TAP 规则内 IP CIDR 加速
/// 2. TUN/TAP 全局,绕过规则内 IP CIDR
/// 3. HTTP 代理(自动设置到系统代理)
/// 4. Socks5 代理(不自动设置到系统代理)
/// 5. Socks5 + HTTP 代理(不自动设置到系统代理)
/// </summary>
public int Type = 0;

Expand Down
2 changes: 1 addition & 1 deletion modes
Submodule modes updated from 181cdf to d8a3c5

0 comments on commit 7ba2732

Please sign in to comment.