This commit is contained in:
zmjack 2020-09-24 18:06:57 +08:00
parent c695b5c9b7
commit 8561ab391b
21 changed files with 13323 additions and 215 deletions

File diff suppressed because it is too large Load Diff

View File

@ -134,7 +134,7 @@
</data>
<data name="label1.Text" xml:space="preserve">
<value>这是款免费软件,
你可以在GitHub上浏览源代码。</value>
您可以在 GitHub 上浏览项目源代码。</value>
</data>
<data name="&gt;&gt;label1.Name" xml:space="preserve">
<value>label1</value>

View File

@ -107,6 +107,7 @@
//
// NewProxy
//
this.AcceptButton = this.button1;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.comboBox_type);

View File

@ -1,5 +1,6 @@
using PortProxyGUI._extern.NStandard;
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows.Forms;
@ -22,13 +23,24 @@ namespace PortProxyGUI
Invoke((Action)(() => PortProxyGUI.RefreshProxyList()));
}
private bool IsIPv4(string ip)
{
if (ip == "localhost" || ip == "*") return true;
else return ip.IsMatch(new Regex(@"^(?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])(?:\.(?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])){3}$"));
}
private bool IsIPv6(string ip)
{
if (ip == "localhost" || ip == "*") return true;
else return ip.IsMatch(new Regex(@"^[\dABCDEF]{2}(?::(?:[\dABCDEF]{2})){5}$"));
}
private void button1_Click(object sender, EventArgs e)
{
var type = comboBox_type.Text;
var listenOn = textBox_listenOn.Text.ToUpper();
var connectTo = textBox_connectTo.Text.ToUpper();
var listenPort = textBox_listenPort.Text;
var connectPort = textBox_connectPort.Text;
var type = comboBox_type.Text.Trim();
var listenOn = textBox_listenOn.Text.Trim().ToLower();
var connectTo = textBox_connectTo.Text.Trim().ToLower();
var listenPort = textBox_listenPort.Text.Trim();
var connectPort = textBox_connectPort.Text.Trim();
if (!int.TryParse(listenPort, out var _listenPort) || _listenPort < 0 || _listenPort > 65535)
{
@ -42,40 +54,38 @@ namespace PortProxyGUI
return;
}
var listenOn_any = listenOn == "*";
var listenOn_ipv4 = listenOn.IsMatch(new Regex(@"^(?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])(?:\.(?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])){3}$"));
var listenOn_ipv6 = listenOn.IsMatch(new Regex(@"^[\dABCDEF]{2}(?::(?:[\dABCDEF]{2})){5}$"));
var connectTo_ipv4 = connectTo.IsMatch(new Regex(@"^(?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])(?:\.(?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])){3}$"));
var connectTo_ipv6 = connectTo.IsMatch(new Regex(@"^[\dABCDEF]{2}(?::(?:[\dABCDEF]{2})){5}$"));
if (!listenOn_any && !listenOn_ipv4 && !listenOn_ipv6)
if (string.IsNullOrEmpty(type))
{
MessageBox.Show($"The address which is connect to is neither IPv4 nor IPv6.", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
if (IsIPv4(listenOn) && IsIPv4(connectTo)) type = comboBox_type.Text = "v4tov4";
else if (IsIPv4(listenOn) && IsIPv6(connectTo)) type = comboBox_type.Text = "v4tov6";
else if (IsIPv6(listenOn) && IsIPv4(connectTo)) type = comboBox_type.Text = "v6tov4";
else if (IsIPv6(listenOn) && IsIPv6(connectTo)) type = comboBox_type.Text = "v6tov6";
else
{
MessageBox.Show($"The address which is connect to is neither IPv4 nor IPv6.", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
}
if (!connectTo_ipv4 && !connectTo_ipv6)
else if (new[] { "v4tov4", "v4tov6", "v6tov4", "v6tov6" }.Contains(type))
{
MessageBox.Show($"The address which is connect to is neither IPv4 nor IPv6.", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (listenOn_any && connectTo_ipv4 && !type.EndsWith("v4"))
{
MessageBox.Show($"The type must be v4tov4 or v6tov4.", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
else if (listenOn_any && connectTo_ipv6 && !type.EndsWith("v6"))
{
MessageBox.Show($"The type must be v4tov6 or v6tov6.", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
bool invalid = false;
switch (type)
{
case "v4tov4": if (!IsIPv4(listenOn) || !IsIPv4(connectTo)) invalid = true; break;
case "v4tov6": if (!IsIPv4(listenOn) || !IsIPv6(connectTo)) invalid = true; break;
case "v6tov4": if (!IsIPv6(listenOn) || !IsIPv4(connectTo)) invalid = true; break;
case "v6tov6": if (!IsIPv6(listenOn) || !IsIPv6(connectTo)) invalid = true; break;
}
if (invalid)
{
MessageBox.Show($"The type ({type}) is invalid for ({listenOn} -> {connectTo}).", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
}
else
{
if (listenOn_ipv4 && connectTo_ipv4) type = comboBox_type.Text = "v4tov4";
else if (listenOn_ipv4 && connectTo_ipv6) type = comboBox_type.Text = "v4tov6";
else if (listenOn_ipv6 && connectTo_ipv4) type = comboBox_type.Text = "v6tov4";
else if (listenOn_ipv6 && connectTo_ipv6) type = comboBox_type.Text = "v6tov6";
MessageBox.Show($"Unknow type ({type}).", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
AddPortProxy(type, listenOn, listenPort, connectTo, connectPort);

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,7 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@ -23,12 +24,11 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
@ -38,7 +38,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x86</PlatformTarget>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
@ -49,6 +49,9 @@
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
@ -127,6 +130,9 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
</ItemGroup>
<Import Project="..\PortProxyGUI.Shared\PortProxyGUI.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -31,11 +31,11 @@
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PortProxyGUI));
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();

File diff suppressed because it is too large Load Diff

View File

@ -4,11 +4,11 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("PortProxyGUI - FW")]
[assembly: AssemblyTitle("PortProxyGUI - NET")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PortProxyGUI - FW")]
[assembly: AssemblyProduct("PortProxyGUI - NET")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2.0")]

BIN
PortProxyGUI - NET/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

File diff suppressed because it is too large Load Diff

View File

@ -134,7 +134,7 @@
</data>
<data name="label1.Text" xml:space="preserve">
<value>这是款免费软件,
你可以在GitHub上浏览源代码。</value>
您可以在 GitHub 上浏览项目源代码。</value>
</data>
<data name="&gt;&gt;label1.Name" xml:space="preserve">
<value>label1</value>

View File

@ -107,6 +107,7 @@
//
// NewProxy
//
this.AcceptButton = this.button1;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.comboBox_type);

View File

@ -1,5 +1,6 @@
using PortProxyGUI._extern.NStandard;
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows.Forms;
@ -22,13 +23,24 @@ namespace PortProxyGUI
Invoke((Action)(() => PortProxyGUI.RefreshProxyList()));
}
private bool IsIPv4(string ip)
{
if (ip == "localhost" || ip == "*") return true;
else return ip.IsMatch(new Regex(@"^(?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])(?:\.(?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])){3}$"));
}
private bool IsIPv6(string ip)
{
if (ip == "localhost" || ip == "*") return true;
else return ip.IsMatch(new Regex(@"^[\dABCDEF]{2}(?::(?:[\dABCDEF]{2})){5}$"));
}
private void button1_Click(object sender, EventArgs e)
{
var type = comboBox_type.Text;
var listenOn = textBox_listenOn.Text.ToUpper();
var connectTo = textBox_connectTo.Text.ToUpper();
var listenPort = textBox_listenPort.Text;
var connectPort = textBox_connectPort.Text;
var type = comboBox_type.Text.Trim();
var listenOn = textBox_listenOn.Text.Trim().ToLower();
var connectTo = textBox_connectTo.Text.Trim().ToLower();
var listenPort = textBox_listenPort.Text.Trim();
var connectPort = textBox_connectPort.Text.Trim();
if (!int.TryParse(listenPort, out var _listenPort) || _listenPort < 0 || _listenPort > 65535)
{
@ -42,40 +54,38 @@ namespace PortProxyGUI
return;
}
var listenOn_any = listenOn == "*";
var listenOn_ipv4 = listenOn.IsMatch(new Regex(@"^(?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])(?:\.(?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])){3}$"));
var listenOn_ipv6 = listenOn.IsMatch(new Regex(@"^[\dABCDEF]{2}(?::(?:[\dABCDEF]{2})){5}$"));
var connectTo_ipv4 = connectTo.IsMatch(new Regex(@"^(?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])(?:\.(?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])){3}$"));
var connectTo_ipv6 = connectTo.IsMatch(new Regex(@"^[\dABCDEF]{2}(?::(?:[\dABCDEF]{2})){5}$"));
if (!listenOn_any && !listenOn_ipv4 && !listenOn_ipv6)
if (string.IsNullOrEmpty(type))
{
MessageBox.Show($"The address which is connect to is neither IPv4 nor IPv6.", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
if (IsIPv4(listenOn) && IsIPv4(connectTo)) type = comboBox_type.Text = "v4tov4";
else if (IsIPv4(listenOn) && IsIPv6(connectTo)) type = comboBox_type.Text = "v4tov6";
else if (IsIPv6(listenOn) && IsIPv4(connectTo)) type = comboBox_type.Text = "v6tov4";
else if (IsIPv6(listenOn) && IsIPv6(connectTo)) type = comboBox_type.Text = "v6tov6";
else
{
MessageBox.Show($"The address which is connect to is neither IPv4 nor IPv6.", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
}
if (!connectTo_ipv4 && !connectTo_ipv6)
else if (new[] { "v4tov4", "v4tov6", "v6tov4", "v6tov6" }.Contains(type))
{
MessageBox.Show($"The address which is connect to is neither IPv4 nor IPv6.", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (listenOn_any && connectTo_ipv4 && !type.EndsWith("v4"))
{
MessageBox.Show($"The type must be v4tov4 or v6tov4.", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
else if (listenOn_any && connectTo_ipv6 && !type.EndsWith("v6"))
{
MessageBox.Show($"The type must be v4tov6 or v6tov6.", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
bool invalid = false;
switch (type)
{
case "v4tov4": if (!IsIPv4(listenOn) || !IsIPv4(connectTo)) invalid = true; break;
case "v4tov6": if (!IsIPv4(listenOn) || !IsIPv6(connectTo)) invalid = true; break;
case "v6tov4": if (!IsIPv6(listenOn) || !IsIPv4(connectTo)) invalid = true; break;
case "v6tov6": if (!IsIPv6(listenOn) || !IsIPv6(connectTo)) invalid = true; break;
}
if (invalid)
{
MessageBox.Show($"The type ({type}) is invalid for ({listenOn} -> {connectTo}).", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
}
else
{
if (listenOn_ipv4 && connectTo_ipv4) type = comboBox_type.Text = "v4tov4";
else if (listenOn_ipv4 && connectTo_ipv6) type = comboBox_type.Text = "v4tov6";
else if (listenOn_ipv6 && connectTo_ipv4) type = comboBox_type.Text = "v6tov4";
else if (listenOn_ipv6 && connectTo_ipv6) type = comboBox_type.Text = "v6tov6";
MessageBox.Show($"Unknow type ({type}).", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
AddPortProxy(type, listenOn, listenPort, connectTo, connectPort);

File diff suppressed because it is too large Load Diff

View File

@ -31,11 +31,11 @@
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PortProxyGUI));
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();

View File

@ -14,12 +14,18 @@
<PackageTags>portproxy TCP/IP redirector</PackageTags>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<Copyright>Copyright © nstandard.net 2020</Copyright>
<Version>1.0.1</Version>
<Version>1.0.2</Version>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>

File diff suppressed because it is too large Load Diff

BIN
PortProxyGUI/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

View File

@ -1,6 +1,6 @@
# PortProxyGUI
A manager of the netsh interface portproxy which is to evaluate TCP/IP port redirect on windows.
A manager for netsh interface portproxy, which is to evaluate TCP/IP port redirect on windows.
![UI](https://raw.githubusercontent.com/zmjack/PortProxyGUI/master/docs/ui.png)

BIN
icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB