Compare commits

...

12 Commits

Author SHA1 Message Date
zmjack 8e36f87205 v1.4.2 2024-06-14 01:15:48 +08:00
Jack 6bee3ea985
Update README.md 2024-06-13 21:09:05 +08:00
zmjack cf386cefb7 Update Readme 2024-06-13 21:03:47 +08:00
zmjack ffeffca952 PortProxyGUI.1.4.2 2024-06-13 19:39:58 +08:00
zmjack eb0d604421 PortProxyGUI.1.4.1 2023-06-14 01:52:07 +08:00
zmjack ce199ef05b PortProxyGUI.1.4.1 2023-06-14 01:46:48 +08:00
zmjack 8b9199f202 PortProxyGUI.1.4.1 2023-06-14 01:30:52 +08:00
zmjack fe77568021 PortProxyGUI.1.4.1 2023-06-14 01:28:22 +08:00
zmjack 5bb57e43e9 PortProxyGUI.1.4.0 2023-04-18 19:04:56 +08:00
zmjack 3c5c88354b PortProxyGUI.1.4.0 2023-03-10 21:28:51 +08:00
zmjack c4694d696d PortProxyGUI.1.4.0 2023-03-10 04:15:00 +08:00
zmjack ae85166efa PortProxyGUI.1.4.0 2023-03-10 04:08:15 +08:00
33 changed files with 2001 additions and 1756 deletions

View File

@ -1,7 +1,7 @@
namespace PortProxyGUI namespace PortProxyGUI;
partial class About
{ {
partial class About
{
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
@ -81,5 +81,4 @@
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label_version; private System.Windows.Forms.Label label_version;
private System.Windows.Forms.Label label_Star; private System.Windows.Forms.Label label_Star;
}
} }

View File

@ -1,13 +1,11 @@
using PortProxyGUI.Utils; using System;
using System;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
namespace PortProxyGUI namespace PortProxyGUI;
public partial class About : Form
{ {
public partial class About : Form
{
public readonly PortProxyGUI PortProxyGUI; public readonly PortProxyGUI PortProxyGUI;
public About(PortProxyGUI portProxyGUI) public About(PortProxyGUI portProxyGUI)
@ -15,8 +13,6 @@ namespace PortProxyGUI
PortProxyGUI = portProxyGUI; PortProxyGUI = portProxyGUI;
InitializeComponent(); InitializeComponent();
Font = InterfaceUtil.UiFont;
label_version.Text = label_version.Text + " v" + Application.ProductVersion; label_version.Text = label_version.Text + " v" + Application.ProductVersion;
} }
@ -32,5 +28,4 @@ namespace PortProxyGUI
{ {
PortProxyGUI.AboutForm = null; PortProxyGUI.AboutForm = null;
} }
}
} }

View File

@ -3,12 +3,12 @@ using System.Drawing;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace PortProxyGUI.Data namespace PortProxyGUI.Data;
public class AppConfig
{ {
public class AppConfig
{
public Size MainWindowSize = new(720, 500); public Size MainWindowSize = new(720, 500);
public int[] PortProxyColumnWidths = new int[] { 24, 64, 140, 100, 140, 100, 100 }; public int[] PortProxyColumnWidths = [24, 64, 140, 100, 140, 100, 100];
private readonly Regex _intArrayRegex = new(@"^\[\s*(\d+)(?:\s*,\s*(\d+))*\s*\]$"); private readonly Regex _intArrayRegex = new(@"^\[\s*(\d+)(?:\s*,\s*(\d+))*\s*\]$");
@ -43,11 +43,10 @@ namespace PortProxyGUI.Data
#if NETCOREAPP3_0_OR_GREATER #if NETCOREAPP3_0_OR_GREATER
PortProxyColumnWidths = Array.Empty<int>(); PortProxyColumnWidths = Array.Empty<int>();
#else #else
PortProxyColumnWidths = new int[0]; PortProxyColumnWidths = [];
#endif #endif
} }
} }
} }
}
} }

View File

@ -5,20 +5,19 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
namespace PortProxyGUI.Data namespace PortProxyGUI.Data;
public class ApplicationDbScope : SqliteScope<ApplicationDbScope>
{ {
public class ApplicationDbScope : SqliteScope<ApplicationDbScope>
{
public static readonly string AppDbDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "PortProxyGUI"); public static readonly string AppDbDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "PortProxyGUI");
public static readonly string AppDbFile = Path.Combine(AppDbDirectory, "config.db"); public static readonly string AppDbFile = Path.Combine(AppDbDirectory, "config.db");
public static ApplicationDbScope FromFile(string file) public static ApplicationDbScope FromFile(string file)
{ {
var dir = Path.GetDirectoryName(file); var dir = Path.GetDirectoryName(file);
var fileName = Path.GetFileName(file);
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
if (!File.Exists(fileName)) if (!File.Exists(file))
{ {
#if NETCOREAPP3_0_OR_GREATER #if NETCOREAPP3_0_OR_GREATER
#else #else
@ -110,5 +109,4 @@ namespace PortProxyGUI.Data
Sql($"UPDATE Configs SET Value = {s_portProxyColumnWidths} WHERE Item = 'PortProxy' AND `Key` = 'ColumnWidths';"); Sql($"UPDATE Configs SET Value = {s_portProxyColumnWidths} WHERE Item = 'PortProxy' AND `Key` = 'ColumnWidths';");
} }
}
} }

View File

@ -1,9 +1,8 @@
namespace PortProxyGUI.Data namespace PortProxyGUI.Data;
public class Config
{ {
public class Config
{
public string Item { get; set; } public string Item { get; set; }
public string Key { get; set; } public string Key { get; set; }
public string Value { get; set; } public string Value { get; set; }
}
} }

View File

@ -1,8 +1,7 @@
namespace PortProxyGUI.Data namespace PortProxyGUI.Data;
public class Migration
{ {
public class Migration
{
public string MigrationId { get; set; } public string MigrationId { get; set; }
public string ProductVersion { get; set; } public string ProductVersion { get; set; }
}
} }

View File

@ -1,8 +1,7 @@
namespace PortProxyGUI.Data namespace PortProxyGUI.Data;
public struct MigrationKey
{ {
public struct MigrationKey
{
public string MigrationId { get; set; } public string MigrationId { get; set; }
public string ProductVersion { get; set; } public string ProductVersion { get; set; }
}
} }

View File

@ -5,10 +5,10 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using System.Windows.Forms; using System.Windows.Forms;
namespace PortProxyGUI.Data namespace PortProxyGUI.Data;
public class MigrationUtil
{ {
public class MigrationUtil
{
public ApplicationDbScope DbScope { get; private set; } public ApplicationDbScope DbScope { get; private set; }
public MigrationUtil(ApplicationDbScope context) public MigrationUtil(ApplicationDbScope context)
@ -67,8 +67,8 @@ Would you like to download it now?", "Upgrade", MessageBoxButtons.YesNo, Message
public Dictionary<MigrationKey, string[]> History = new Dictionary<MigrationKey, string[]> public Dictionary<MigrationKey, string[]> History = new Dictionary<MigrationKey, string[]>
{ {
[new MigrationKey { MigrationId = "202103021542", ProductVersion = "1.1.0" }] = new[] [new MigrationKey { MigrationId = "202103021542", ProductVersion = "1.1.0" }] =
{ [
@"CREATE TABLE rules @"CREATE TABLE rules
( (
Id text PRIMARY KEY, Id text PRIMARY KEY,
@ -79,16 +79,16 @@ Would you like to download it now?", "Upgrade", MessageBoxButtons.YesNo, Message
ConnectPort integer ConnectPort integer
);", );",
"CREATE UNIQUE INDEX IX_Rules_Type_ListenOn_ListenPort ON Rules(Type, ListenOn, ListenPort);", "CREATE UNIQUE INDEX IX_Rules_Type_ListenOn_ListenPort ON Rules(Type, ListenOn, ListenPort);",
}, ],
[new MigrationKey { MigrationId = "202201172103", ProductVersion = "1.2.0" }] = new[] [new MigrationKey { MigrationId = "202201172103", ProductVersion = "1.2.0" }] =
{ [
"ALTER TABLE rules ADD Note text;", "ALTER TABLE rules ADD Note text;",
"ALTER TABLE rules ADD `Group` text;", "ALTER TABLE rules ADD `Group` text;",
}, ],
[new MigrationKey { MigrationId = "202202221635", ProductVersion = "1.3.0" }] = new[] [new MigrationKey { MigrationId = "202202221635", ProductVersion = "1.3.0" }] =
{ [
"ALTER TABLE rules RENAME TO rulesOld;", "ALTER TABLE rules RENAME TO rulesOld;",
"DROP INDEX IX_Rules_Type_ListenOn_ListenPort;", "DROP INDEX IX_Rules_Type_ListenOn_ListenPort;",
@ -106,10 +106,10 @@ Would you like to download it now?", "Upgrade", MessageBoxButtons.YesNo, Message
"INSERT INTO rules SELECT Id, Type, ListenOn, ListenPort, ConnectTo, ConnectPort, Note, `Group` FROM rulesOld;", "INSERT INTO rules SELECT Id, Type, ListenOn, ListenPort, ConnectTo, ConnectPort, Note, `Group` FROM rulesOld;",
"DROP TABLE rulesOld;", "DROP TABLE rulesOld;",
}, ],
[new MigrationKey { MigrationId = "202303092024", ProductVersion = "1.4.0" }] = new[] [new MigrationKey { MigrationId = "202303092024", ProductVersion = "1.4.0" }] =
{ [
@"CREATE TABLE configs ( @"CREATE TABLE configs (
Item text, Item text,
`Key` text, `Key` text,
@ -121,7 +121,6 @@ Would you like to download it now?", "Upgrade", MessageBoxButtons.YesNo, Message
"INSERT INTO configs ( Item, `Key`, Value ) VALUES ( 'MainWindow', 'Width', '720' );", "INSERT INTO configs ( Item, `Key`, Value ) VALUES ( 'MainWindow', 'Width', '720' );",
"INSERT INTO configs ( Item, `Key`, Value ) VALUES ( 'MainWindow', 'Height', '500' );", "INSERT INTO configs ( Item, `Key`, Value ) VALUES ( 'MainWindow', 'Height', '500' );",
"INSERT INTO configs ( Item, `Key`, Value ) VALUES ( 'PortProxy', 'ColumnWidths', '[24, 64, 140, 100, 140, 100, 100]' );", "INSERT INTO configs ( Item, `Key`, Value ) VALUES ( 'PortProxy', 'ColumnWidths', '[24, 64, 140, 100, 140, 100, 100]' );",
}, ],
}; };
}
} }

View File

@ -1,9 +1,9 @@
using System; using System;
namespace PortProxyGUI.Data namespace PortProxyGUI.Data;
public class Rule : IEquatable<Rule>
{ {
public class Rule : IEquatable<Rule>
{
public string Id { get; set; } public string Id { get; set; }
public string Type { get; set; } public string Type { get; set; }
@ -36,6 +36,11 @@ namespace PortProxyGUI.Data
set => _realConnectPort = value; set => _realConnectPort = value;
} }
public override int GetHashCode()
{
return base.GetHashCode();
}
public bool Equals(Rule other) public bool Equals(Rule other)
{ {
return Id == other.Id return Id == other.Id
@ -65,5 +70,4 @@ namespace PortProxyGUI.Data
{ {
return Equals(obj as Rule); return Equals(obj as Rule);
} }
}
} }

View File

@ -1,10 +1,12 @@
using System; using System;
namespace PortProxyGUI.Native namespace PortProxyGUI.Native;
[Flags]
internal enum GenericRights : uint
{ {
[Flags]
public enum GenericRights : uint
{
GENERIC_READ = 0x80000000, GENERIC_READ = 0x80000000,
} GENERIC_WRITE = 0x40000000,
GENERIC_EXECUTE = 0x20000000,
GENERIC_ALL = 0x10000000,
} }

View File

@ -1,22 +1,32 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace PortProxyGUI.Native namespace PortProxyGUI.Native;
internal class NativeMethods
{ {
internal class NativeMethods
{
[DllImport("advapi32.dll", EntryPoint = "OpenSCManagerW", ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] [DllImport("advapi32.dll", EntryPoint = "OpenSCManagerW", ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern IntPtr OpenSCManager(string machineName, string databaseName, uint dwAccess); internal static extern IntPtr OpenSCManager(string machineName, string databaseName, uint dwAccess);
[DllImport("advapi32.dll", EntryPoint = "OpenServiceW", SetLastError = true, CharSet = CharSet.Unicode)] [DllImport("advapi32.dll", EntryPoint = "OpenServiceW", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern IntPtr OpenService(IntPtr hSCManager, string lpServiceName, ServiceRights dwDesiredAccess); internal static extern IntPtr OpenService(IntPtr hSCManager, string lpServiceName, ServiceRights dwDesiredAccess);
[DllImport("advapi32.dll", EntryPoint = "QueryServiceStatus", CharSet = CharSet.Auto)]
internal static extern bool QueryServiceStatus(IntPtr hService, ref ServiceStatus dwServiceStatus);
[DllImport("advapi32.dll", SetLastError = true)] [DllImport("advapi32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ControlService(IntPtr hService, ServiceControls dwControl, ref ServiceStatus lpServiceStatus); internal static extern bool ControlService(IntPtr hService, ServiceControls dwControl, ref ServiceStatus lpServiceStatus);
[DllImport("advapi32.dll", SetLastError = true)] [DllImport("advapi32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CloseServiceHandle(IntPtr hSCObject); internal static extern bool CloseServiceHandle(IntPtr hSCObject);
}
[DllImport("dnsapi.dll", EntryPoint = "DnsFlushResolverCache")]
internal static extern uint DnsFlushResolverCache();
[DllImport("advapi32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool StartService(IntPtr hService, int dwNumServiceArgs, string[] lpServiceArgVectors);
} }

View File

@ -0,0 +1,20 @@
namespace PortProxyGUI.Native;
internal enum ScmRights : uint
{
SC_MANAGER_CONNECT = 0x0001,
SC_MANAGER_CREATE_SERVICE = 0x0002,
SC_MANAGER_ENUMERATE_SERVICE = 0x0004,
SC_MANAGER_LOCK = 0x0008,
SC_MANAGER_QUERY_LOCK_STATUS = 0x0010,
SC_MANAGER_MODIFY_BOOT_CONFIG = 0x0020,
SC_MANAGER_ALL_ACCESS =
StandardRights.STANDARD_RIGHTS_REQUIRED
| SC_MANAGER_CONNECT
| SC_MANAGER_CREATE_SERVICE
| SC_MANAGER_ENUMERATE_SERVICE
| SC_MANAGER_LOCK
| SC_MANAGER_QUERY_LOCK_STATUS
| SC_MANAGER_MODIFY_BOOT_CONFIG
}

View File

@ -1,10 +1,9 @@
using System; using System;
namespace PortProxyGUI.Native namespace PortProxyGUI.Native;
[Flags]
internal enum ServiceControls : uint
{ {
[Flags]
public enum ServiceControls : uint
{
SERVICE_CONTROL_PARAMCHANGE = 0x00000006, SERVICE_CONTROL_PARAMCHANGE = 0x00000006,
}
} }

View File

@ -1,10 +1,28 @@
using System; using System;
namespace PortProxyGUI.Native namespace PortProxyGUI.Native;
[Flags]
internal enum ServiceRights : uint
{ {
[Flags] SERVICE_QUERY_CONFIG = 0x0001,
public enum ServiceRights : uint SERVICE_CHANGE_CONFIG = 0x0002,
{ SERVICE_QUERY_STATUS = 0x0004,
SERVICE_ENUMERATE_DEPENDENTS = 0x0008,
SERVICE_START = 0x0010,
SERVICE_STOP = 0x0020,
SERVICE_PAUSE_CONTINUE = 0x0040, SERVICE_PAUSE_CONTINUE = 0x0040,
} SERVICE_INTERROGATE = 0x0080,
SERVICE_USER_DEFINED_CONTROL = 0x0100,
SERVICE_ALL_ACCESS =
SERVICE_QUERY_CONFIG
| SERVICE_CHANGE_CONFIG
| SERVICE_QUERY_STATUS
| SERVICE_ENUMERATE_DEPENDENTS
| SERVICE_START
| SERVICE_STOP
| SERVICE_PAUSE_CONTINUE
| SERVICE_INTERROGATE
| SERVICE_USER_DEFINED_CONTROL
} }

View File

@ -0,0 +1,12 @@
namespace PortProxyGUI.Native;
internal enum ServiceState : int
{
SERVICE_STOPPED = 0x00000001,
SERVICE_START_PENDING = 0x00000002,
SERVICE_STOP_PENDING = 0x00000003,
SERVICE_RUNNING = 0x00000004,
SERVICE_CONTINUE_PENDING = 0x00000005,
SERVICE_PAUSE_PENDING = 0x00000006,
SERVICE_PAUSED = 0x00000007,
}

View File

@ -1,16 +1,15 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace PortProxyGUI.Native namespace PortProxyGUI.Native;
[StructLayout(LayoutKind.Sequential)]
internal struct ServiceStatus
{ {
[StructLayout(LayoutKind.Sequential)]
public struct ServiceStatus
{
public uint dwServiceType; public uint dwServiceType;
public uint dwCurrentState; public ServiceState dwCurrentState;
public uint dwControlsAccepted; public uint dwControlsAccepted;
public uint dwWin32ExitCode; public uint dwWin32ExitCode;
public uint dwServiceSpecificExitCode; public uint dwServiceSpecificExitCode;
public uint dwCheckPoint; public uint dwCheckPoint;
public uint dwWaitHint; public uint dwWaitHint;
}
} }

View File

@ -0,0 +1,6 @@
namespace PortProxyGUI.Native;
internal enum StandardRights : uint
{
STANDARD_RIGHTS_REQUIRED = 0x000F0000,
}

View File

@ -1,7 +1,7 @@
namespace PortProxyGUI namespace PortProxyGUI;
partial class PortProxyGUI
{ {
partial class PortProxyGUI
{
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
@ -52,14 +52,18 @@
toolStripMenuItem_More = new System.Windows.Forms.ToolStripMenuItem(); toolStripMenuItem_More = new System.Windows.Forms.ToolStripMenuItem();
toolStripMenuItem_Import = new System.Windows.Forms.ToolStripMenuItem(); toolStripMenuItem_Import = new System.Windows.Forms.ToolStripMenuItem();
toolStripMenuItem_Export = new System.Windows.Forms.ToolStripMenuItem(); toolStripMenuItem_Export = new System.Windows.Forms.ToolStripMenuItem();
toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
toolStripMenuItem_ResetWindowSize = new System.Windows.Forms.ToolStripMenuItem();
toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
toolStripMenuItem_About = new System.Windows.Forms.ToolStripMenuItem(); toolStripMenuItem_About = new System.Windows.Forms.ToolStripMenuItem();
imageListProxies = new System.Windows.Forms.ImageList(components); imageListProxies = new System.Windows.Forms.ImageList(components);
saveFileDialog_Export = new System.Windows.Forms.SaveFileDialog(); saveFileDialog_Export = new System.Windows.Forms.SaveFileDialog();
openFileDialog_Import = new System.Windows.Forms.OpenFileDialog(); openFileDialog_Import = new System.Windows.Forms.OpenFileDialog();
toolStripMenuItem_ResetWindowSize = new System.Windows.Forms.ToolStripMenuItem(); statusStrip_Footer = new System.Windows.Forms.StatusStrip();
toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); toolStripStatusLabel_Status = new System.Windows.Forms.ToolStripStatusLabel();
toolStripStatusLabel_ServiceNotRunning = new System.Windows.Forms.ToolStripStatusLabel();
contextMenuStrip_RightClick.SuspendLayout(); contextMenuStrip_RightClick.SuspendLayout();
statusStrip_Footer.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
// listViewProxies // listViewProxies
@ -69,7 +73,6 @@
listViewProxies.ContextMenuStrip = contextMenuStrip_RightClick; listViewProxies.ContextMenuStrip = contextMenuStrip_RightClick;
resources.ApplyResources(listViewProxies, "listViewProxies"); resources.ApplyResources(listViewProxies, "listViewProxies");
listViewProxies.FullRowSelect = true; listViewProxies.FullRowSelect = true;
listViewProxies.HideSelection = false;
listViewProxies.Name = "listViewProxies"; listViewProxies.Name = "listViewProxies";
listViewProxies.SmallImageList = imageListProxies; listViewProxies.SmallImageList = imageListProxies;
listViewProxies.UseCompatibleStateImageBehavior = false; listViewProxies.UseCompatibleStateImageBehavior = false;
@ -185,6 +188,17 @@
resources.ApplyResources(toolStripMenuItem_Export, "toolStripMenuItem_Export"); resources.ApplyResources(toolStripMenuItem_Export, "toolStripMenuItem_Export");
toolStripMenuItem_Export.Click += toolStripMenuItem_Export_Click; toolStripMenuItem_Export.Click += toolStripMenuItem_Export_Click;
// //
// toolStripSeparator5
//
toolStripSeparator5.Name = "toolStripSeparator5";
resources.ApplyResources(toolStripSeparator5, "toolStripSeparator5");
//
// toolStripMenuItem_ResetWindowSize
//
toolStripMenuItem_ResetWindowSize.Name = "toolStripMenuItem_ResetWindowSize";
resources.ApplyResources(toolStripMenuItem_ResetWindowSize, "toolStripMenuItem_ResetWindowSize");
toolStripMenuItem_ResetWindowSize.Click += toolStripMenuItem_ResetWindowSize_Click;
//
// toolStripSeparator4 // toolStripSeparator4
// //
toolStripSeparator4.Name = "toolStripSeparator4"; toolStripSeparator4.Name = "toolStripSeparator4";
@ -212,21 +226,30 @@
openFileDialog_Import.FileName = "openFileDialog1"; openFileDialog_Import.FileName = "openFileDialog1";
resources.ApplyResources(openFileDialog_Import, "openFileDialog_Import"); resources.ApplyResources(openFileDialog_Import, "openFileDialog_Import");
// //
// toolStripMenuItem_ResetWindowSize // statusStrip_Footer
// //
toolStripMenuItem_ResetWindowSize.Name = "toolStripMenuItem_ResetWindowSize"; statusStrip_Footer.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripStatusLabel_Status, toolStripStatusLabel_ServiceNotRunning });
resources.ApplyResources(toolStripMenuItem_ResetWindowSize, "toolStripMenuItem_ResetWindowSize"); resources.ApplyResources(statusStrip_Footer, "statusStrip_Footer");
toolStripMenuItem_ResetWindowSize.Click += toolStripMenuItem_ResetWindowSize_Click; statusStrip_Footer.Name = "statusStrip_Footer";
// //
// toolStripSeparator5 // toolStripStatusLabel_Status
// //
toolStripSeparator5.Name = "toolStripSeparator5"; toolStripStatusLabel_Status.Name = "toolStripStatusLabel_Status";
resources.ApplyResources(toolStripSeparator5, "toolStripSeparator5"); resources.ApplyResources(toolStripStatusLabel_Status, "toolStripStatusLabel_Status");
//
// toolStripStatusLabel_ServiceNotRunning
//
toolStripStatusLabel_ServiceNotRunning.IsLink = true;
toolStripStatusLabel_ServiceNotRunning.LinkColor = System.Drawing.Color.Red;
toolStripStatusLabel_ServiceNotRunning.Name = "toolStripStatusLabel_ServiceNotRunning";
resources.ApplyResources(toolStripStatusLabel_ServiceNotRunning, "toolStripStatusLabel_ServiceNotRunning");
toolStripStatusLabel_ServiceNotRunning.Click += toolStripStatusLabel_ServiceNotRunning_Click;
// //
// PortProxyGUI // PortProxyGUI
// //
resources.ApplyResources(this, "$this"); resources.ApplyResources(this, "$this");
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
Controls.Add(statusStrip_Footer);
Controls.Add(listViewProxies); Controls.Add(listViewProxies);
Name = "PortProxyGUI"; Name = "PortProxyGUI";
FormClosing += PortProxyGUI_FormClosing; FormClosing += PortProxyGUI_FormClosing;
@ -234,7 +257,10 @@
Shown += PortProxyGUI_Shown; Shown += PortProxyGUI_Shown;
Resize += PortProxyGUI_Resize; Resize += PortProxyGUI_Resize;
contextMenuStrip_RightClick.ResumeLayout(false); contextMenuStrip_RightClick.ResumeLayout(false);
statusStrip_Footer.ResumeLayout(false);
statusStrip_Footer.PerformLayout();
ResumeLayout(false); ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion
@ -267,6 +293,8 @@
private System.Windows.Forms.OpenFileDialog openFileDialog_Import; private System.Windows.Forms.OpenFileDialog openFileDialog_Import;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; private System.Windows.Forms.ToolStripSeparator toolStripSeparator5;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_ResetWindowSize; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_ResetWindowSize;
} private System.Windows.Forms.StatusStrip statusStrip_Footer;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_Status;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_ServiceNotRunning;
} }

View File

@ -4,16 +4,15 @@ using PortProxyGUI.UI;
using PortProxyGUI.Utils; using PortProxyGUI.Utils;
using System; using System;
using System.Data; using System.Data;
using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using static System.Windows.Forms.ListViewItem; using static System.Windows.Forms.ListViewItem;
namespace PortProxyGUI namespace PortProxyGUI;
public partial class PortProxyGUI : Form
{ {
public partial class PortProxyGUI : Form
{
private readonly ListViewColumnSorter lvwColumnSorter = new ListViewColumnSorter(); private readonly ListViewColumnSorter lvwColumnSorter = new ListViewColumnSorter();
public SetProxy SetProxyForm; public SetProxy SetProxyForm;
@ -23,8 +22,6 @@ namespace PortProxyGUI
public PortProxyGUI() public PortProxyGUI()
{ {
InitializeComponent(); InitializeComponent();
Font = InterfaceUtil.UiFont;
listViewProxies.ListViewItemSorter = lvwColumnSorter; listViewProxies.ListViewItemSorter = lvwColumnSorter;
} }
@ -90,7 +87,7 @@ namespace PortProxyGUI
try try
{ {
var rule = ParseRule(item); var rule = ParseRule(item);
PortPorxyUtil.AddOrUpdateProxy(rule); Util.AddOrUpdateProxy(rule);
} }
catch (NotSupportedException ex) catch (NotSupportedException ex)
{ {
@ -98,7 +95,7 @@ namespace PortProxyGUI
return; return;
} }
} }
PortPorxyUtil.ParamChange(); Util.ParamChange();
} }
private void DisableSelectedProxies() private void DisableSelectedProxies()
@ -111,7 +108,7 @@ namespace PortProxyGUI
try try
{ {
var rule = ParseRule(item); var rule = ParseRule(item);
PortPorxyUtil.DeleteProxy(rule); Util.DeleteProxy(rule);
} }
catch (NotSupportedException ex) catch (NotSupportedException ex)
{ {
@ -119,7 +116,7 @@ namespace PortProxyGUI
return; return;
} }
} }
PortPorxyUtil.ParamChange(); Util.ParamChange();
} }
private void DeleteSelectedProxies() private void DeleteSelectedProxies()
@ -202,7 +199,7 @@ namespace PortProxyGUI
public void RefreshProxyList() public void RefreshProxyList()
{ {
var proxies = PortPorxyUtil.GetProxies(); var proxies = Util.GetProxies();
var rules = Program.Database.Rules.ToArray(); var rules = Program.Database.Rules.ToArray();
foreach (var proxy in proxies) foreach (var proxy in proxies)
{ {
@ -224,6 +221,9 @@ namespace PortProxyGUI
rules = Program.Database.Rules.ToArray(); rules = Program.Database.Rules.ToArray();
InitProxyGroups(rules); InitProxyGroups(rules);
InitProxyItems(rules, proxies); InitProxyItems(rules, proxies);
// CheckServiceStatus
toolStripStatusLabel_ServiceNotRunning.Visible = !Util.IsServiceRunning();
} }
private void contextMenuStrip_RightClick_MouseClick(object sender, MouseEventArgs e) private void contextMenuStrip_RightClick_MouseClick(object sender, MouseEventArgs e)
@ -239,25 +239,30 @@ namespace PortProxyGUI
case ToolStripMenuItem item when item == toolStripMenuItem_Disable: DisableSelectedProxies(); break; case ToolStripMenuItem item when item == toolStripMenuItem_Disable: DisableSelectedProxies(); break;
case ToolStripMenuItem item when item == toolStripMenuItem_New: case ToolStripMenuItem item when item == toolStripMenuItem_New:
if (SetProxyForm == null) SetProxyForm = new SetProxy(this); SetProxyForm ??= new SetProxy(this);
SetProxyForm.UseNormalMode(); SetProxyForm.UseNormalMode();
SetProxyForm.ShowDialog(); SetProxyForm.ShowDialog();
break; break;
case ToolStripMenuItem item when item == toolStripMenuItem_Modify: case ToolStripMenuItem item when item == toolStripMenuItem_Modify:
if (SetProxyForm == null) SetProxyForm = new SetProxy(this); SetProxyForm ??= new SetProxy(this);
SetProxyForUpdate(SetProxyForm); SetProxyForUpdate(SetProxyForm);
SetProxyForm.ShowDialog(); SetProxyForm.ShowDialog();
break; break;
case ToolStripMenuItem item when item == toolStripMenuItem_Refresh: case ToolStripMenuItem item when item == toolStripMenuItem_Refresh:
RefreshProxyList(); RefreshProxyList();
break; toolStripStatusLabel_Status.Text = $"{DateTime.Now} : Refreshed.";
case ToolStripMenuItem item when item == toolStripMenuItem_FlushDnsCache:
DnsUtil.FlushCache();
break; break;
case ToolStripMenuItem item when item == toolStripMenuItem_Delete: DeleteSelectedProxies(); break; case ToolStripMenuItem item when item == toolStripMenuItem_FlushDnsCache:
DnsUtil.FlushCache();
toolStripStatusLabel_Status.Text = $"{DateTime.Now} : DNS cache cleared.";
break;
case ToolStripMenuItem item when item == toolStripMenuItem_Delete:
DeleteSelectedProxies();
break;
case ToolStripMenuItem item when item == toolStripMenuItem_About: case ToolStripMenuItem item when item == toolStripMenuItem_About:
if (AboutForm == null) if (AboutForm == null)
@ -290,7 +295,7 @@ namespace PortProxyGUI
var selectAny = listView.SelectedItems.OfType<ListViewItem>().Any(); var selectAny = listView.SelectedItems.OfType<ListViewItem>().Any();
if (selectAny) if (selectAny)
{ {
if (SetProxyForm == null) SetProxyForm = new SetProxy(this); SetProxyForm ??= new SetProxy(this);
SetProxyForUpdate(SetProxyForm); SetProxyForUpdate(SetProxyForm);
SetProxyForm.ShowDialog(); SetProxyForm.ShowDialog();
} }
@ -394,5 +399,10 @@ namespace PortProxyGUI
AppConfig = new AppConfig(); AppConfig = new AppConfig();
ResetWindowSize(); ResetWindowSize();
} }
private void toolStripStatusLabel_ServiceNotRunning_Click(object sender, EventArgs e)
{
Util.StartService();
toolStripStatusLabel_ServiceNotRunning.Visible = false;
} }
} }

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFrameworks>net6.0-windows;netcoreapp3.1;net35;net451</TargetFrameworks> <TargetFrameworks>net8.0-windows;net6.0-windows;net35;net451</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<ApplicationManifest>app.manifest</ApplicationManifest> <ApplicationManifest>app.manifest</ApplicationManifest>
<Authors>zmjack</Authors> <Authors>zmjack</Authors>
@ -14,9 +14,9 @@
<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.4.0</Version> <Version>1.4.2</Version>
<ApplicationIcon>icon.ico</ApplicationIcon> <ApplicationIcon>icon.ico</ApplicationIcon>
<ApplicationDefaultFont>Microsoft Sans Serif, 8pt</ApplicationDefaultFont> <ApplicationDefaultFont>Arial, 8.25pt</ApplicationDefaultFont>
<AssemblyName>PPGUI</AssemblyName> <AssemblyName>PPGUI</AssemblyName>
<LangVersion>preview</LangVersion> <LangVersion>preview</LangVersion>
</PropertyGroup> </PropertyGroup>

View File

@ -164,6 +164,94 @@
<data name="contextMenuStrip_RightClick.TrayLocation" type="System.Drawing.Point, System.Drawing"> <data name="contextMenuStrip_RightClick.TrayLocation" type="System.Drawing.Point, System.Drawing">
<value>17, 17</value> <value>17, 17</value>
</data> </data>
<data name="contextMenuStrip_RightClick.Size" type="System.Drawing.Size, System.Drawing">
<value>175, 226</value>
</data>
<data name="&gt;&gt;contextMenuStrip_RightClick.Name" xml:space="preserve">
<value>contextMenuStrip_RightClick</value>
</data>
<data name="&gt;&gt;contextMenuStrip_RightClick.Type" xml:space="preserve">
<value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="listViewProxies.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="listViewProxies.Font" type="System.Drawing.Font, System.Drawing">
<value>Microsoft YaHei UI, 9pt</value>
</data>
<data name="listViewProxies.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>
<data name="listViewProxies.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 3, 4, 3</value>
</data>
<data name="listViewProxies.Size" type="System.Drawing.Size, System.Drawing">
<value>704, 461</value>
</data>
<data name="imageListProxies.TrayLocation" type="System.Drawing.Point, System.Drawing">
<value>239, 17</value>
</data>
<data name="imageListProxies.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADc
CAAAAk1TRnQBSQFMAgEBAgEAAdABAQHYAQEBEAEAARABAAT/AQkBEAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm
AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM
AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAAT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Af8DlSIABBcBFgH0Av8B9AEWBBcB/wEADpUB/yEADhcB/wEADpUB/yEAAZQMFwGU
AgABugyVAboiAAH/AZQKFwGUAf8CAAH/AboKlQG6Af80AAH/CPQkAAFCAU0BPgcAAT4DAAEoAwABQAMA
ARADAAEBAQABAQUAAYAXAAP/AQAB4AEHAv8EAAGAAQEBgAEBBAABgAEBAYABAQQAAYABAQGAAQEEAAGA
AQEBgAEBBAABgAEBAYABAQQAAYABAQGAAQEEAAGAAQEBgAEBBAABgAEBAYABAQQAAYABAQGAAQEEAAGA
AQEBgAEBBAABgAEAAYAFAAGAAQABgAUAAYABAQGAAQEEAAGAAQEBgAEBBAAC/wHgAQ8aAAs=
</value>
</data>
<data name="listViewProxies.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;listViewProxies.Name" xml:space="preserve">
<value>listViewProxies</value>
</data>
<data name="&gt;&gt;listViewProxies.Type" xml:space="preserve">
<value>System.Windows.Forms.ListView, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;listViewProxies.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;listViewProxies.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="toolStripMenuItem_Enable.Size" type="System.Drawing.Size, System.Drawing"> <data name="toolStripMenuItem_Enable.Size" type="System.Drawing.Size, System.Drawing">
<value>174, 22</value> <value>174, 22</value>
</data> </data>
@ -218,33 +306,33 @@
<data name="toolStripSeparator1.Size" type="System.Drawing.Size, System.Drawing"> <data name="toolStripSeparator1.Size" type="System.Drawing.Size, System.Drawing">
<value>171, 6</value> <value>171, 6</value>
</data> </data>
<data name="toolStripMenuItem_Import.Size" type="System.Drawing.Size, System.Drawing">
<value>186, 22</value>
</data>
<data name="toolStripMenuItem_Import.Text" xml:space="preserve">
<value>Import</value>
</data>
<data name="toolStripMenuItem_Export.Size" type="System.Drawing.Size, System.Drawing">
<value>186, 22</value>
</data>
<data name="toolStripMenuItem_Export.Text" xml:space="preserve">
<value>Export</value>
</data>
<data name="toolStripSeparator5.Size" type="System.Drawing.Size, System.Drawing">
<value>183, 6</value>
</data>
<data name="toolStripMenuItem_ResetWindowSize.Size" type="System.Drawing.Size, System.Drawing">
<value>186, 22</value>
</data>
<data name="toolStripMenuItem_ResetWindowSize.Text" xml:space="preserve">
<value>Reset Window</value>
</data>
<data name="toolStripMenuItem_More.Size" type="System.Drawing.Size, System.Drawing"> <data name="toolStripMenuItem_More.Size" type="System.Drawing.Size, System.Drawing">
<value>174, 22</value> <value>174, 22</value>
</data> </data>
<data name="toolStripMenuItem_More.Text" xml:space="preserve"> <data name="toolStripMenuItem_More.Text" xml:space="preserve">
<value>More</value> <value>More</value>
</data> </data>
<data name="toolStripMenuItem_Import.Size" type="System.Drawing.Size, System.Drawing">
<value>159, 22</value>
</data>
<data name="toolStripMenuItem_Import.Text" xml:space="preserve">
<value>Import</value>
</data>
<data name="toolStripMenuItem_Export.Size" type="System.Drawing.Size, System.Drawing">
<value>159, 22</value>
</data>
<data name="toolStripMenuItem_Export.Text" xml:space="preserve">
<value>Export</value>
</data>
<data name="toolStripSeparator5.Size" type="System.Drawing.Size, System.Drawing">
<value>156, 6</value>
</data>
<data name="toolStripMenuItem_ResetWindowSize.Size" type="System.Drawing.Size, System.Drawing">
<value>159, 22</value>
</data>
<data name="toolStripMenuItem_ResetWindowSize.Text" xml:space="preserve">
<value>Reset Window</value>
</data>
<data name="toolStripSeparator4.Size" type="System.Drawing.Size, System.Drawing"> <data name="toolStripSeparator4.Size" type="System.Drawing.Size, System.Drawing">
<value>171, 6</value> <value>171, 6</value>
</data> </data>
@ -254,94 +342,6 @@
<data name="toolStripMenuItem_About.Text" xml:space="preserve"> <data name="toolStripMenuItem_About.Text" xml:space="preserve">
<value>About</value> <value>About</value>
</data> </data>
<data name="contextMenuStrip_RightClick.Size" type="System.Drawing.Size, System.Drawing">
<value>175, 226</value>
</data>
<data name="&gt;&gt;contextMenuStrip_RightClick.Name" xml:space="preserve">
<value>contextMenuStrip_RightClick</value>
</data>
<data name="&gt;&gt;contextMenuStrip_RightClick.Type" xml:space="preserve">
<value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="listViewProxies.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="listViewProxies.Font" type="System.Drawing.Font, System.Drawing">
<value>Microsoft YaHei UI, 9pt</value>
</data>
<data name="listViewProxies.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>
<data name="listViewProxies.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 3, 4, 3</value>
</data>
<data name="listViewProxies.Size" type="System.Drawing.Size, System.Drawing">
<value>704, 461</value>
</data>
<data name="imageListProxies.TrayLocation" type="System.Drawing.Point, System.Drawing">
<value>239, 17</value>
</data>
<data name="imageListProxies.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADc
CAAAAk1TRnQBSQFMAgEBAgEAAYwBAQGQAQEBEAEAARABAAT/AQkBEAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAx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8CAAH/AboKlQG6Af8iAAGUDBcBlAIAAboMlQG6IgAOFwIADpUiAAQXARYB9AL/AfQBFgQXAgAOlSIA
AxcBFgH/Ab0BFgGUAfQB/wEWAxcCAAWVArsHlSIAAxcB9AG9AhcBlAH/AvQDFwIABJUBugL/AcEGlSIA
AxcB/wEWARcBlAH/ApQB/wMXAgADlQG6Af8BwQG6Af8BwQWVIgADFwH/ApQB/wGUARcBFgH/AxcCAAOV
Af8BwQKVAboB/wHBBJUiAAMXAvQB/wGUAhcBvQH0AxcCAAiVAboB/wHBA5UiAAMXARYB/wH0AZQBFgG9
Af8BFgMXAgAJlQG6Af8DlSIABBcBFgH0Av8B9AEWBBcB/wEADpUB/yEADhcB/wEADpUB/yEAAZQMFwGU
AgABugyVAboiAAH/AZQKFwGUAf8CAAH/AboKlQG6Af80AAH/CPQkAAFCAU0BPgcAAT4DAAEoAwABQAMA
ARADAAEBAQABAQUAAYAXAAP/AQAB4AEHAv8EAAGAAQEBgAEBBAABgAEBAYABAQQAAYABAQGAAQEEAAGA
AQEBgAEBBAABgAEBAYABAQQAAYABAQGAAQEEAAGAAQEBgAEBBAABgAEBAYABAQQAAYABAQGAAQEEAAGA
AQEBgAEBBAABgAEAAYAFAAGAAQABgAUAAYABAQGAAQEEAAGAAQEBgAEBBAAC/wHgAQ8aAAs=
</value>
</data>
<data name="listViewProxies.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;listViewProxies.Name" xml:space="preserve">
<value>listViewProxies</value>
</data>
<data name="&gt;&gt;listViewProxies.Type" xml:space="preserve">
<value>System.Windows.Forms.ListView, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;listViewProxies.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;listViewProxies.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="saveFileDialog_Export.TrayLocation" type="System.Drawing.Point, System.Drawing"> <data name="saveFileDialog_Export.TrayLocation" type="System.Drawing.Point, System.Drawing">
<value>389, 17</value> <value>389, 17</value>
</data> </data>
@ -354,6 +354,48 @@
<data name="openFileDialog_Import.Filter" xml:space="preserve"> <data name="openFileDialog_Import.Filter" xml:space="preserve">
<value>Database File|*.db</value> <value>Database File|*.db</value>
</data> </data>
<data name="statusStrip_Footer.TrayLocation" type="System.Drawing.Point, System.Drawing">
<value>755, 17</value>
</data>
<data name="statusStrip_Footer.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 439</value>
</data>
<data name="statusStrip_Footer.Size" type="System.Drawing.Size, System.Drawing">
<value>704, 22</value>
</data>
<data name="statusStrip_Footer.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="statusStrip_Footer.Text" xml:space="preserve">
<value>FooterStrip</value>
</data>
<data name="&gt;&gt;statusStrip_Footer.Name" xml:space="preserve">
<value>statusStrip_Footer</value>
</data>
<data name="&gt;&gt;statusStrip_Footer.Type" xml:space="preserve">
<value>System.Windows.Forms.StatusStrip, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;statusStrip_Footer.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;statusStrip_Footer.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="toolStripStatusLabel_Status.Size" type="System.Drawing.Size, System.Drawing">
<value>171, 17</value>
</data>
<data name="toolStripStatusLabel_Status.Text" xml:space="preserve">
<value>Welcome to Port Proxy GUI !</value>
</data>
<data name="toolStripStatusLabel_ServiceNotRunning.Size" type="System.Drawing.Size, System.Drawing">
<value>278, 17</value>
</data>
<data name="toolStripStatusLabel_ServiceNotRunning.Text" xml:space="preserve">
<value>IP Helper service is not running (Click to start)</value>
</data>
<data name="toolStripStatusLabel_ServiceNotRunning.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="$this.Localizable" type="System.Boolean, mscorlib"> <data name="$this.Localizable" type="System.Boolean, mscorlib">
<value>True</value> <value>True</value>
</data> </data>
@ -2650,6 +2692,18 @@
<data name="&gt;&gt;toolStripMenuItem_Export.Type" xml:space="preserve"> <data name="&gt;&gt;toolStripMenuItem_Export.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="&gt;&gt;toolStripSeparator5.Name" xml:space="preserve">
<value>toolStripSeparator5</value>
</data>
<data name="&gt;&gt;toolStripSeparator5.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripSeparator, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;toolStripMenuItem_ResetWindowSize.Name" xml:space="preserve">
<value>toolStripMenuItem_ResetWindowSize</value>
</data>
<data name="&gt;&gt;toolStripMenuItem_ResetWindowSize.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;toolStripSeparator4.Name" xml:space="preserve"> <data name="&gt;&gt;toolStripSeparator4.Name" xml:space="preserve">
<value>toolStripSeparator4</value> <value>toolStripSeparator4</value>
</data> </data>
@ -2680,17 +2734,17 @@
<data name="&gt;&gt;openFileDialog_Import.Type" xml:space="preserve"> <data name="&gt;&gt;openFileDialog_Import.Type" xml:space="preserve">
<value>System.Windows.Forms.OpenFileDialog, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Windows.Forms.OpenFileDialog, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="&gt;&gt;toolStripMenuItem_ResetWindowSize.Name" xml:space="preserve"> <data name="&gt;&gt;toolStripStatusLabel_Status.Name" xml:space="preserve">
<value>toolStripMenuItem_ResetWindowSize</value> <value>toolStripStatusLabel_Status</value>
</data> </data>
<data name="&gt;&gt;toolStripMenuItem_ResetWindowSize.Type" xml:space="preserve"> <data name="&gt;&gt;toolStripStatusLabel_Status.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="&gt;&gt;toolStripSeparator5.Name" xml:space="preserve"> <data name="&gt;&gt;toolStripStatusLabel_ServiceNotRunning.Name" xml:space="preserve">
<value>toolStripSeparator5</value> <value>toolStripStatusLabel_ServiceNotRunning</value>
</data> </data>
<data name="&gt;&gt;toolStripSeparator5.Type" xml:space="preserve"> <data name="&gt;&gt;toolStripStatusLabel_ServiceNotRunning.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripSeparator, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="&gt;&gt;$this.Name" xml:space="preserve"> <data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>PortProxyGUI</value> <value>PortProxyGUI</value>

View File

@ -197,7 +197,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADc ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADc
CAAAAk1TRnQBSQFMAgEBAgEAASABAQEwAQEBEAEAARABAAT/AQkBEAj/AUIBTQE2AQQGAAE2AQQCAAEo CAAAAk1TRnQBSQFMAgEBAgEAASABAQE4AQEBEAEAARABAAT/AQkBEAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
@ -2611,4 +2611,13 @@
<data name="toolStripMenuItem_ResetWindowSize.Text" xml:space="preserve"> <data name="toolStripMenuItem_ResetWindowSize.Text" xml:space="preserve">
<value>重置窗口</value> <value>重置窗口</value>
</data> </data>
<data name="statusStrip_Footer.Text" xml:space="preserve">
<value>FooterStrip</value>
</data>
<data name="toolStripStatusLabel_ServiceNotRunning.Text" xml:space="preserve">
<value>IP Helper 服务未启动(点击启动)</value>
</data>
<data name="toolStripStatusLabel_Status.Text" xml:space="preserve">
<value>欢迎使用 Port Proxy GUI </value>
</data>
</root> </root>

View File

@ -1,15 +1,29 @@
using PortProxyGUI.Data; using PortProxyGUI.Data;
using System; using System;
using System.Globalization;
using System.IO; using System.IO;
using System.Threading; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
namespace PortProxyGUI namespace PortProxyGUI;
static class Program
{ {
static class Program private static string GetPath(params string[] pathes)
{ {
public static readonly ApplicationDbScope Database = ApplicationDbScope.FromFile(ApplicationDbScope.AppDbFile); if (!pathes.Any()) return string.Empty;
#if NET6_0_OR_GREATER || NET451_OR_GREATER
return Path.Combine(pathes);
#else
return pathes.Aggregate(Path.Combine);
#endif
}
public static ApplicationDbScope Database { get; } = ApplicationDbScope.FromFile(GetPath(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
"PortProxyGUI",
"config.db"
));
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
@ -19,6 +33,7 @@ namespace PortProxyGUI
{ {
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
#if NET6_0_OR_GREATER #if NET6_0_OR_GREATER
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
#elif NETCOREAPP3_1_OR_GREATER #elif NETCOREAPP3_1_OR_GREATER
@ -29,7 +44,7 @@ namespace PortProxyGUI
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
#endif #endif
Application.Run(new PortProxyGUI()); Application.Run(new PortProxyGUI());
} }
}
} }

View File

@ -1,7 +1,7 @@
namespace PortProxyGUI namespace PortProxyGUI;
partial class SetProxy
{ {
partial class SetProxy
{
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
@ -180,5 +180,4 @@
private System.Windows.Forms.TextBox textBox_Comment; private System.Windows.Forms.TextBox textBox_Comment;
private System.Windows.Forms.Label label_Group; private System.Windows.Forms.Label label_Group;
private System.Windows.Forms.ComboBox comboBox_Group; private System.Windows.Forms.ComboBox comboBox_Group;
}
} }

View File

@ -2,15 +2,14 @@
using PortProxyGUI.Data; using PortProxyGUI.Data;
using PortProxyGUI.Utils; using PortProxyGUI.Utils;
using System; using System;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
namespace PortProxyGUI namespace PortProxyGUI;
public partial class SetProxy : Form
{ {
public partial class SetProxy : Form
{
public readonly PortProxyGUI ParentWindow; public readonly PortProxyGUI ParentWindow;
private string AutoTypeString { get; } private string AutoTypeString { get; }
@ -23,7 +22,6 @@ namespace PortProxyGUI
ParentWindow = parent; ParentWindow = parent;
InitializeComponent(); InitializeComponent();
Font = InterfaceUtil.UiFont;
AutoTypeString = comboBox_Type.Text = comboBox_Type.Items.OfType<string>().First(); AutoTypeString = comboBox_Type.Text = comboBox_Type.Items.OfType<string>().First();
var groupNames = ( var groupNames = (
@ -117,22 +115,22 @@ namespace PortProxyGUI
if (_updateMode) if (_updateMode)
{ {
var oldRule = Program.Database.GetRule(_itemRule.Type, _itemRule.ListenOn, _itemRule.ListenPort); var oldRule = Program.Database.GetRule(_itemRule.Type, _itemRule.ListenOn, _itemRule.ListenPort);
PortPorxyUtil.DeleteProxy(oldRule); Util.DeleteProxy(oldRule);
Program.Database.Remove(oldRule); Program.Database.Remove(oldRule);
PortPorxyUtil.AddOrUpdateProxy(rule); Util.AddOrUpdateProxy(rule);
Program.Database.Add(rule); Program.Database.Add(rule);
ParentWindow.UpdateListViewItem(_listViewItem, rule, 1); ParentWindow.UpdateListViewItem(_listViewItem, rule, 1);
} }
else else
{ {
PortPorxyUtil.AddOrUpdateProxy(rule); Util.AddOrUpdateProxy(rule);
Program.Database.Add(rule); Program.Database.Add(rule);
ParentWindow.RefreshProxyList(); ParentWindow.RefreshProxyList();
} }
PortPorxyUtil.ParamChange(); Util.ParamChange();
Close(); Close();
} }
@ -148,5 +146,4 @@ namespace PortProxyGUI
ParentWindow.SetProxyForm = null; ParentWindow.SetProxyForm = null;
} }
}
} }

View File

@ -1,10 +1,10 @@
using System.Collections; using System.Collections;
using System.Windows.Forms; using System.Windows.Forms;
namespace PortProxyGUI.UI namespace PortProxyGUI.UI;
public class ListViewColumnSorter : IComparer
{ {
public class ListViewColumnSorter : IComparer
{
/// <summary> /// <summary>
/// Specifies the column to be sorted /// Specifies the column to be sorted
/// </summary> /// </summary>
@ -107,5 +107,4 @@ namespace PortProxyGUI.UI
} }
} }
}
} }

View File

@ -1,18 +1,14 @@
using System; using PortProxyGUI.Native;
using System.Runtime.InteropServices; using System;
namespace PortProxyGUI.Utils namespace PortProxyGUI.Utils;
internal class DnsUtil
{ {
internal class DnsUtil
{
[DllImport("dnsapi.dll", EntryPoint = "DnsFlushResolverCache")]
static extern uint DnsFlushResolverCache();
public static void FlushCache() public static void FlushCache()
{ {
var status = DnsFlushResolverCache(); var status = NativeMethods.DnsFlushResolverCache();
if (status == 0) throw new InvalidOperationException("Flush DNS Cache failed."); if (status == 0) throw new InvalidOperationException("Flush DNS Cache failed.");
} }
}
} }

View File

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
namespace PortProxyGUI.Utils
{
public class InterfaceUtil
{
/// <summary>
/// Compatibility between .NET Framework and .NET Core.
/// <see href="https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms" />
/// </summary>
public static readonly Font UiFont = new(new FontFamily("Microsoft Sans Serif"), 8f);
}
}

View File

@ -1,114 +0,0 @@
using Microsoft.Win32;
using PortProxyGUI.Data;
using PortProxyGUI.Native;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
namespace PortProxyGUI.Utils
{
public static class PortPorxyUtil
{
private static InvalidOperationException InvalidPortProxyType(string type) => new($"Invalid port proxy type ({type}).");
private static readonly string[] ProxyTypes = new[] { "v4tov4", "v4tov6", "v6tov4", "v6tov6" };
private static string GetKeyName(string type)
{
return $@"SYSTEM\CurrentControlSet\Services\PortProxy\{type}\tcp";
}
public static Rule[] GetProxies()
{
var ruleList = new List<Rule>();
foreach (var type in ProxyTypes)
{
var keyName = GetKeyName(type);
var key = Registry.LocalMachine.OpenSubKey(keyName);
if (key is not null)
{
foreach (var name in key.GetValueNames())
{
var listenParts = name.Split('/');
var listenOn = listenParts[0];
if (!int.TryParse(listenParts[1], out var listenPort)) continue;
var connectParts = key.GetValue(name).ToString().Split('/');
var connectTo = connectParts[0];
if (!int.TryParse(connectParts[1], out var connectPort)) continue;
ruleList.Add(new Rule
{
Type = type,
ListenOn = listenOn,
ListenPort = listenPort,
ConnectTo = connectTo,
ConnectPort = connectPort,
});
}
}
}
return ruleList.ToArray();
}
public static void AddOrUpdateProxy(Rule rule)
{
// $"netsh interface portproxy add {rule.Type} listenaddress={rule.ListenOn} listenport={rule.ListenPort} connectaddress={rule.ConnectTo} connectport={rule.ConnectPort}"
if (!ProxyTypes.Contains(rule.Type)) throw InvalidPortProxyType(rule.Type);
var keyName = GetKeyName(rule.Type);
var key = Registry.LocalMachine.OpenSubKey(keyName, true);
var name = $"{rule.ListenOn}/{rule.ListenPort}";
var value = $"{rule.ConnectTo}/{rule.ConnectPort}";
if (key is null) Registry.LocalMachine.CreateSubKey(keyName);
key = Registry.LocalMachine.OpenSubKey(keyName, true);
key?.SetValue(name, value);
}
public static void DeleteProxy(Rule rule)
{
// $"netsh interface portproxy delete {rule.Type} listenaddress={rule.ListenOn} listenport={rule.ListenPort}"
if (!ProxyTypes.Contains(rule.Type)) throw InvalidPortProxyType(rule.Type);
var keyName = GetKeyName(rule.Type);
var key = Registry.LocalMachine.OpenSubKey(keyName, true);
var name = $"{rule.ListenOn}/{rule.ListenPort}";
try
{
key?.DeleteValue(name);
}
catch { }
}
public static void ParamChange()
{
var hManager = NativeMethods.OpenSCManager(null, null, (uint)GenericRights.GENERIC_READ);
if (hManager == IntPtr.Zero) throw new InvalidOperationException("Open SC Manager failed.");
var serviceName = "iphlpsvc";
var hService = NativeMethods.OpenService(hManager, serviceName, ServiceRights.SERVICE_PAUSE_CONTINUE);
if (hService == IntPtr.Zero)
{
NativeMethods.CloseServiceHandle(hManager);
throw new InvalidOperationException($"Open Service ({serviceName}) failed.");
}
var serviceStatus = new ServiceStatus();
var success = NativeMethods.ControlService(hService, ServiceControls.SERVICE_CONTROL_PARAMCHANGE, ref serviceStatus);
NativeMethods.CloseServiceHandle(hService);
NativeMethods.CloseServiceHandle(hManager);
if (!success)
{
throw new InvalidOperationException($"Control Service ({serviceName}) ParamChange failed.");
}
}
}
}

148
PortProxyGUI/Utils/Util.cs Normal file
View File

@ -0,0 +1,148 @@
using Microsoft.Win32;
using PortProxyGUI.Data;
using PortProxyGUI.Native;
using System;
using System.Collections.Generic;
using System.Linq;
namespace PortProxyGUI.Utils;
public static class Util
{
internal static readonly string ServiceName = "iphlpsvc";
internal static readonly string ServiceFriendlyName = "IP Helper";
private static InvalidOperationException InvalidPortProxyType(string type) => new($"Invalid port proxy type ({type}).");
private static readonly string[] ProxyTypes = ["v4tov4", "v4tov6", "v6tov4", "v6tov6"];
private static string GetKeyName(string type)
{
return $@"SYSTEM\CurrentControlSet\Services\PortProxy\{type}\tcp";
}
public static Rule[] GetProxies()
{
var ruleList = new List<Rule>();
foreach (var type in ProxyTypes)
{
var keyName = GetKeyName(type);
var key = Registry.LocalMachine.OpenSubKey(keyName);
if (key is not null)
{
foreach (var name in key.GetValueNames())
{
var listenParts = name.Split('/');
var listenOn = listenParts[0];
if (!int.TryParse(listenParts[1], out var listenPort)) continue;
var connectParts = key.GetValue(name).ToString().Split('/');
var connectTo = connectParts[0];
if (!int.TryParse(connectParts[1], out var connectPort)) continue;
ruleList.Add(new Rule
{
Type = type,
ListenOn = listenOn,
ListenPort = listenPort,
ConnectTo = connectTo,
ConnectPort = connectPort,
});
}
}
}
return [.. ruleList];
}
public static void AddOrUpdateProxy(Rule rule)
{
// $"netsh interface portproxy add {rule.Type} listenaddress={rule.ListenOn} listenport={rule.ListenPort} connectaddress={rule.ConnectTo} connectport={rule.ConnectPort}"
if (!ProxyTypes.Contains(rule.Type)) throw InvalidPortProxyType(rule.Type);
var keyName = GetKeyName(rule.Type);
var key = Registry.LocalMachine.OpenSubKey(keyName, true);
var name = $"{rule.ListenOn}/{rule.ListenPort}";
var value = $"{rule.ConnectTo}/{rule.ConnectPort}";
if (key is null) Registry.LocalMachine.CreateSubKey(keyName);
key = Registry.LocalMachine.OpenSubKey(keyName, true);
key?.SetValue(name, value);
}
public static void DeleteProxy(Rule rule)
{
// $"netsh interface portproxy delete {rule.Type} listenaddress={rule.ListenOn} listenport={rule.ListenPort}"
if (!ProxyTypes.Contains(rule.Type)) throw InvalidPortProxyType(rule.Type);
var keyName = GetKeyName(rule.Type);
var key = Registry.LocalMachine.OpenSubKey(keyName, true);
var name = $"{rule.ListenOn}/{rule.ListenPort}";
try
{
key?.DeleteValue(name);
}
catch { }
}
public static bool IsServiceRunning()
{
var hManager = NativeMethods.OpenSCManager(null, null, (uint)GenericRights.GENERIC_READ);
if (hManager == IntPtr.Zero) throw new InvalidOperationException("Open SC Manager failed.");
var hService = NativeMethods.OpenService(hManager, ServiceName, ServiceRights.SERVICE_QUERY_STATUS);
if (hService == IntPtr.Zero)
{
NativeMethods.CloseServiceHandle(hManager);
throw new InvalidOperationException($"Open Service ({ServiceName}) failed.");
}
var status = new ServiceStatus();
NativeMethods.QueryServiceStatus(hService, ref status);
NativeMethods.CloseServiceHandle(hService);
NativeMethods.CloseServiceHandle(hManager);
return status.dwCurrentState == ServiceState.SERVICE_RUNNING;
}
public static void StartService()
{
var hManager = NativeMethods.OpenSCManager(null, null, (uint)GenericRights.GENERIC_READ | (uint)ScmRights.SC_MANAGER_CONNECT);
if (hManager == IntPtr.Zero) throw new InvalidOperationException("Open SC Manager failed.");
var hService = NativeMethods.OpenService(hManager, ServiceName, ServiceRights.SERVICE_START);
if (hService == IntPtr.Zero)
{
NativeMethods.CloseServiceHandle(hManager);
throw new InvalidOperationException($"Open Service ({ServiceName}) failed.");
}
NativeMethods.StartService(hService, 0, null);
NativeMethods.CloseServiceHandle(hService);
NativeMethods.CloseServiceHandle(hManager);
}
public static void ParamChange()
{
var hManager = NativeMethods.OpenSCManager(null, null, (uint)GenericRights.GENERIC_READ);
if (hManager == IntPtr.Zero) throw new InvalidOperationException("Open SC Manager failed.");
var hService = NativeMethods.OpenService(hManager, ServiceName, ServiceRights.SERVICE_PAUSE_CONTINUE);
if (hService == IntPtr.Zero)
{
NativeMethods.CloseServiceHandle(hManager);
throw new InvalidOperationException($"Open Service ({ServiceName}) failed.");
}
var status = new ServiceStatus();
NativeMethods.ControlService(hService, ServiceControls.SERVICE_CONTROL_PARAMCHANGE, ref status);
NativeMethods.CloseServiceHandle(hService);
NativeMethods.CloseServiceHandle(hManager);
}
}

21
PortProxyGUI/publish.ps1 Normal file
View File

@ -0,0 +1,21 @@
Remove-Item -Path ".\bin\publish" -Recurse
dotnet publish -c Release -f "net8.0-windows" /p:PublishProfile="net8-x64"
dotnet publish -c Release -f "net8.0-windows" /p:PublishProfile="net8-x86"
dotnet publish -c Release -f "net6.0-windows" /p:PublishProfile="net6-x64"
dotnet publish -c Release -f "net6.0-windows" /p:PublishProfile="net6-x86"
Copy-Item -Path ".\bin\Release\net451\" ".\bin\Publish\" -Recurse -Force
Copy-Item -Path ".\bin\Release\net35\" ".\bin\Publish\" -Recurse -Force
$ver = "1.4.2"
Compress-Archive -Path ".\bin\publish\net8-x64\*" -DestinationPath ".\bin\publish\ppgui-net8-x64-$ver.zip" -Force
Compress-Archive -Path ".\bin\publish\net8-x86\*" -DestinationPath ".\bin\publish\ppgui-net8-x86-$ver.zip" -Force
Compress-Archive -Path ".\bin\publish\net6-x64\*" -DestinationPath ".\bin\publish\ppgui-net6-x64-$ver.zip" -Force
Compress-Archive -Path ".\bin\publish\net6-x86\*" -DestinationPath ".\bin\publish\ppgui-net6-x86-$ver.zip" -Force
Compress-Archive -Path ".\bin\publish\net451\*" -DestinationPath ".\bin\publish\ppgui-net451-$ver.zip" -Force
Compress-Archive -Path ".\bin\publish\net35\*" -DestinationPath ".\bin\publish\ppgui-net35-$ver.zip" -Force

View File

@ -6,12 +6,56 @@ A manager for netsh interface portproxy, which is to evaluate TCP/IP port redire
<br/> <br/>
> [!NOTE]
>
> The software does not configure the firewall.
>
> If necessary, manually configure the firewall.
<br/>
## Runtimes
### .NET
| Target framework | Link |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| ![Static Badge](https://img.shields.io/badge/.NET-8.0-8A2BE2) | [Download .NET 8.0](https://dotnet.microsoft.com/download/dotnet/8.0) |
| ![Static Badge](https://img.shields.io/badge/.NET-6.0-8A2BE2) | [Download .NET 6.0](https://dotnet.microsoft.com/download/dotnet/6.0) |
### .NET Framework
| Icon | Denote |
| ---- | ------------------------------------------------------------ |
| ✔️ | OS versions on which is **installed by default**. |
| | OS versions on which doesn't come installed but **can be installed**. |
| Target framework | Windows | Windows Server | Link |
| ------------------------------------------------------------ | -------------------------- | --------------------------------- | ------------------------------------------------------------ |
| ![Static Badge](https://img.shields.io/badge/.NET_Framework-4.5.1-blue) | ✔️ **8.1 +**<br /> Vista + | ✔️ **2012 R2 +**<br /> 2008 SP2 + | [Download](https://dotnet.microsoft.com/download/dotnet-framework/net451) |
| ![Static Badge](https://img.shields.io/badge/.NET_Framework-3.5-blue) | ✔️ **7 +**<br /> Vista | ✔️ **2008 R2 SP1 +**<br /> 2003 + | [Download](https://dotnet.microsoft.com/download/dotnet-framework/net35-sp1) |
> [!NOTE]
>
> If you're using Windows 8, Windows Server 2008 R2 SP1, or greater.
>
> we recommend [installing .NET Framework 3.5 through the control panel](https://learn.microsoft.com/dotnet/framework/install/dotnet-35-windows-10?WT.mc_id=dotnet-35129-website).
<br/>
## Upgrade ## Upgrade
- **v1.4.2**
- Change the default font from ~~`Microsoft Sans Serif`~~ to **`Arial`**.
- This setting provides better compatibility on operating systems with fewer fonts.
- **v1.4.1**
- Add a status strip at the bottom of the window.
- Add a check of the IP Helper service status, if the service is not running, a prompt will be displayed on the bottom status bar.
- **v1.4.0** - **v1.4.0**
- Command line calls have been removed to provide better performance. - Command line calls have been removed to provide better performance.
- New Feature Added: **Remember Window/Colum Size**. - New Feature Added: **Remember Window/Column Size**.
- New Feature Added: **Flush DNS Cache**. - New Feature Added: **Flush DNS Cache**.
- New Feature Added: **Support import and export configuration database**.
- **v1.3.1 - v1.3.2** - **v1.3.1 - v1.3.2**
- Fix program crash caused by wrong rules. - Fix program crash caused by wrong rules.
- **v1.3.0** - **v1.3.0**

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 19 KiB