This commit is contained in:
zmjack 2021-09-30 13:41:32 +08:00
parent 861434fd72
commit 8a5ee63ad3
7 changed files with 30 additions and 16 deletions

View File

@ -211,7 +211,7 @@
<value>2</value> <value>2</value>
</data> </data>
<data name="label_Star.Text" xml:space="preserve"> <data name="label_Star.Text" xml:space="preserve">
<value>为我点星:</value> <value>点星鼓励</value>
</data> </data>
<data name="label_Star.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing"> <data name="label_Star.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleCenter</value> <value>MiddleCenter</value>

View File

@ -112,15 +112,15 @@
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="columnHeader1.Text" xml:space="preserve"> <data name="columnHeader1.Text" xml:space="preserve">
<value /> <value />
</data> </data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="columnHeader1.Width" type="System.Int32, mscorlib"> <data name="columnHeader1.Width" type="System.Int32, mscorlib">
<value>24</value> <value>24</value>
</data> </data>
@ -154,7 +154,7 @@
<data name="columnHeader6.Width" type="System.Int32, mscorlib"> <data name="columnHeader6.Width" type="System.Int32, mscorlib">
<value>100</value> <value>100</value>
</data> </data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing"> <data name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing">
<value>17, 17</value> <value>17, 17</value>
</data> </data>
@ -167,7 +167,7 @@
<data name="&gt;&gt;contextMenuStrip1.Type" xml:space="preserve"> <data name="&gt;&gt;contextMenuStrip1.Type" xml:space="preserve">
<value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="listViewProxies.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms"> <data name="listViewProxies.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value> <value>Fill</value>
</data> </data>
@ -185,10 +185,10 @@
</data> </data>
<data name="imageListProxies.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64"> <data name="imageListProxies.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
<value> <value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADc ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADc
CAAAAk1TRnQBSQFMAgEBAgEAAUABAAFEAQABEAEAARABAAT/AQkBEAj/AUIBTQE2AQQGAAE2AQQCAAEo CAAAAk1TRnQBSQFMAgEBAgEAAUABAAFIAQABEAEAARABAAT/AQkBEAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.1.0")] [assembly: AssemblyVersion("1.1.2.0")]
[assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyFileVersion("1.1.2.0")]

View File

@ -211,7 +211,7 @@
<value>2</value> <value>2</value>
</data> </data>
<data name="label_Star.Text" xml:space="preserve"> <data name="label_Star.Text" xml:space="preserve">
<value>为我点星:</value> <value>点星鼓励</value>
</data> </data>
<data name="label_Star.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing"> <data name="label_Star.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleCenter</value> <value>MiddleCenter</value>

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.1.0")] [assembly: AssemblyVersion("1.1.2.0")]
[assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyFileVersion("1.1.2.0")]

View File

@ -1,6 +1,7 @@
using NStandard; using NStandard;
using PortProxyGUI.Data; using PortProxyGUI.Data;
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@ -8,6 +9,19 @@ namespace PortProxyGUI
{ {
public static class CmdUtil public static class CmdUtil
{ {
private static Regex GetRegex(string fromType, string toType)
{
return new Regex($@"{fromType}[^:]*:[^\n]+?{toType}[^:]*:\r\n\r\n.+?\r\n--------------- ---------- --------------- ----------\r\n(.+?)\r\n\r\n", RegexOptions.Singleline);
}
private static readonly Dictionary<string, Regex> RegexList = new Dictionary<string, Regex>()
{
["ipv4 to ipv4"] = GetRegex("ipv4", "ipv4"),
["ipv4 to ipv6"] = GetRegex("ipv4", "ipv6"),
["ipv6 to ipv4"] = GetRegex("ipv6", "ipv4"),
["ipv6 to ipv6"] = GetRegex("ipv6", "ipv6"),
};
public static Rule[] GetProxies() public static Rule[] GetProxies()
{ {
var output = CmdRunner.Execute("netsh interface portproxy show all"); var output = CmdRunner.Execute("netsh interface portproxy show all");
@ -21,8 +35,8 @@ namespace PortProxyGUI
var proxies = types.SelectMany(type => var proxies = types.SelectMany(type =>
{ {
var typeProxies = output var regex = RegexList[$"{type.From} to {type.To}"];
.ExtractFirst(new Regex($@"{type.From}:[^\n]+?{type.To}:\r\n\r\n.+?\r\n--------------- ---------- --------------- ----------\r\n(.+?)\r\n\r\n", RegexOptions.Singleline)) var typeProxies = output.ExtractFirst(regex)
?.Split(new[] { Environment.NewLine }, StringSplitOptions.None) ?.Split(new[] { Environment.NewLine }, StringSplitOptions.None)
.Select(line => .Select(line =>
{ {

View File

@ -14,7 +14,7 @@
<PackageTags>portproxy TCP/IP redirector</PackageTags> <PackageTags>portproxy TCP/IP redirector</PackageTags>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile> <PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<Copyright>Copyright © nstandard.net 2020</Copyright> <Copyright>Copyright © nstandard.net 2020</Copyright>
<Version>1.1.1</Version> <Version>1.1.2</Version>
<ApplicationIcon>icon.ico</ApplicationIcon> <ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>