From 8a5ee63ad371ad7074f6072c692caa01f98f5097 Mon Sep 17 00:00:00 2001 From: zmjack Date: Thu, 30 Sep 2021 13:41:32 +0800 Subject: [PATCH] v1.1.2 --- PortProxyGUI - NET35/About.zh-CN.resx | 2 +- PortProxyGUI - NET35/PortProxyGUI.zh-CN.resx | 14 +++++++------- .../Properties/AssemblyInfo.cs | 4 ++-- PortProxyGUI - NET45/About.zh-CN.resx | 2 +- .../Properties/AssemblyInfo.cs | 4 ++-- PortProxyGUI.Shared/CmdUtil.cs | 18 ++++++++++++++++-- PortProxyGUI/PortProxyGUI.csproj | 2 +- 7 files changed, 30 insertions(+), 16 deletions(-) diff --git a/PortProxyGUI - NET35/About.zh-CN.resx b/PortProxyGUI - NET35/About.zh-CN.resx index 1c97bf3..85bc6fe 100644 --- a/PortProxyGUI - NET35/About.zh-CN.resx +++ b/PortProxyGUI - NET35/About.zh-CN.resx @@ -211,7 +211,7 @@ 2 - 为我点星: + 点星鼓励: MiddleCenter diff --git a/PortProxyGUI - NET35/PortProxyGUI.zh-CN.resx b/PortProxyGUI - NET35/PortProxyGUI.zh-CN.resx index 020290e..5fa0407 100644 --- a/PortProxyGUI - NET35/PortProxyGUI.zh-CN.resx +++ b/PortProxyGUI - NET35/PortProxyGUI.zh-CN.resx @@ -112,15 +112,15 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 24 @@ -154,7 +154,7 @@ 100 - + 17, 17 @@ -167,7 +167,7 @@ System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Fill @@ -185,10 +185,10 @@ - AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADc - CAAAAk1TRnQBSQFMAgEBAgEAAUABAAFEAQABEAEAARABAAT/AQkBEAj/AUIBTQE2AQQGAAE2AQQCAAEo + CAAAAk1TRnQBSQFMAgEBAgEAAUABAAFIAQABEAEAARABAAT/AQkBEAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/PortProxyGUI - NET35/Properties/AssemblyInfo.cs b/PortProxyGUI - NET35/Properties/AssemblyInfo.cs index 8ce07e4..704a750 100644 --- a/PortProxyGUI - NET35/Properties/AssemblyInfo.cs +++ b/PortProxyGUI - NET35/Properties/AssemblyInfo.cs @@ -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.1.1.0")] -[assembly: AssemblyFileVersion("1.1.1.0")] +[assembly: AssemblyVersion("1.1.2.0")] +[assembly: AssemblyFileVersion("1.1.2.0")] diff --git a/PortProxyGUI - NET45/About.zh-CN.resx b/PortProxyGUI - NET45/About.zh-CN.resx index 1c97bf3..85bc6fe 100644 --- a/PortProxyGUI - NET45/About.zh-CN.resx +++ b/PortProxyGUI - NET45/About.zh-CN.resx @@ -211,7 +211,7 @@ 2 - 为我点星: + 点星鼓励: MiddleCenter diff --git a/PortProxyGUI - NET45/Properties/AssemblyInfo.cs b/PortProxyGUI - NET45/Properties/AssemblyInfo.cs index 8ce07e4..704a750 100644 --- a/PortProxyGUI - NET45/Properties/AssemblyInfo.cs +++ b/PortProxyGUI - NET45/Properties/AssemblyInfo.cs @@ -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.1.1.0")] -[assembly: AssemblyFileVersion("1.1.1.0")] +[assembly: AssemblyVersion("1.1.2.0")] +[assembly: AssemblyFileVersion("1.1.2.0")] diff --git a/PortProxyGUI.Shared/CmdUtil.cs b/PortProxyGUI.Shared/CmdUtil.cs index 0103fda..d4b80e5 100644 --- a/PortProxyGUI.Shared/CmdUtil.cs +++ b/PortProxyGUI.Shared/CmdUtil.cs @@ -1,6 +1,7 @@ using NStandard; using PortProxyGUI.Data; using System; +using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; @@ -8,6 +9,19 @@ namespace PortProxyGUI { 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 RegexList = new Dictionary() + { + ["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() { var output = CmdRunner.Execute("netsh interface portproxy show all"); @@ -21,8 +35,8 @@ namespace PortProxyGUI var proxies = types.SelectMany(type => { - var typeProxies = output - .ExtractFirst(new Regex($@"{type.From}:[^\n]+?{type.To}:\r\n\r\n.+?\r\n--------------- ---------- --------------- ----------\r\n(.+?)\r\n\r\n", RegexOptions.Singleline)) + var regex = RegexList[$"{type.From} to {type.To}"]; + var typeProxies = output.ExtractFirst(regex) ?.Split(new[] { Environment.NewLine }, StringSplitOptions.None) .Select(line => { diff --git a/PortProxyGUI/PortProxyGUI.csproj b/PortProxyGUI/PortProxyGUI.csproj index 24e79d2..0b46d15 100644 --- a/PortProxyGUI/PortProxyGUI.csproj +++ b/PortProxyGUI/PortProxyGUI.csproj @@ -14,7 +14,7 @@ portproxy TCP/IP redirector LICENSE.md Copyright © nstandard.net 2020 - 1.1.1 + 1.1.2 icon.ico