Compare commits
39 Commits
Author | SHA1 | Date |
---|---|---|
|
8e36f87205 | |
|
6bee3ea985 | |
|
cf386cefb7 | |
|
ffeffca952 | |
|
eb0d604421 | |
|
ce199ef05b | |
|
8b9199f202 | |
|
fe77568021 | |
|
5bb57e43e9 | |
|
3c5c88354b | |
|
c4694d696d | |
|
ae85166efa | |
|
edfa5e87e3 | |
|
f3bb505cfe | |
|
ff14a3532a | |
|
e8da3c5055 | |
|
751deaaae4 | |
|
f684feb78c | |
|
1756d32c79 | |
|
d77c510423 | |
|
9c189048f1 | |
|
9e3bc5d7eb | |
|
922d0f93ea | |
|
8a5ee63ad3 | |
|
861434fd72 | |
|
b5f2820097 | |
|
1abd0a5691 | |
|
e57ec23521 | |
|
f0e08f50b0 | |
|
16bf3ed339 | |
|
bf44a2bc87 | |
|
194c10d1cc | |
|
8561ab391b | |
|
c695b5c9b7 | |
|
123154b042 | |
|
e3cab74a23 | |
|
52d087efb4 | |
|
e1ac1ef73f | |
|
90150a8318 |
|
@ -1,66 +0,0 @@
|
|||
namespace PortProxyGUI
|
||||
{
|
||||
partial class About
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// linkLabel1
|
||||
//
|
||||
this.linkLabel1.Location = new System.Drawing.Point(12, 22);
|
||||
this.linkLabel1.Name = "linkLabel1";
|
||||
this.linkLabel1.Size = new System.Drawing.Size(321, 23);
|
||||
this.linkLabel1.TabIndex = 0;
|
||||
this.linkLabel1.TabStop = true;
|
||||
this.linkLabel1.Text = "https://github.com/zmjack/PortProxyGUI";
|
||||
this.linkLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.linkLabel1.Click += new System.EventHandler(this.linkLabel1_Click);
|
||||
//
|
||||
// About
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(345, 79);
|
||||
this.Controls.Add(this.linkLabel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "About";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "About";
|
||||
this.TopMost = true;
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.LinkLabel linkLabel1;
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PortProxyGUI
|
||||
{
|
||||
public partial class About : Form
|
||||
{
|
||||
public About()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void linkLabel1_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is LinkLabel _sender)
|
||||
{
|
||||
Process.Start("explorer", _sender.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -1,196 +0,0 @@
|
|||
namespace PortProxyGUI
|
||||
{
|
||||
partial class NewProxy
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.textBox_listenOn = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.textBox_connectTo = new System.Windows.Forms.TextBox();
|
||||
this.textBox_connectPort = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.textBox_listenPort = new System.Windows.Forms.TextBox();
|
||||
this.comboBox_type = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(13, 11);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(59, 12);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Listen on";
|
||||
//
|
||||
// textBox_listenOn
|
||||
//
|
||||
this.textBox_listenOn.Location = new System.Drawing.Point(79, 8);
|
||||
this.textBox_listenOn.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBox_listenOn.Name = "textBox_listenOn";
|
||||
this.textBox_listenOn.Size = new System.Drawing.Size(103, 21);
|
||||
this.textBox_listenOn.TabIndex = 0;
|
||||
this.textBox_listenOn.Text = "*";
|
||||
this.textBox_listenOn.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(13, 35);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(65, 12);
|
||||
this.label2.TabIndex = 0;
|
||||
this.label2.Text = "Connect to";
|
||||
//
|
||||
// textBox_connectTo
|
||||
//
|
||||
this.textBox_connectTo.Location = new System.Drawing.Point(79, 32);
|
||||
this.textBox_connectTo.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBox_connectTo.Name = "textBox_connectTo";
|
||||
this.textBox_connectTo.Size = new System.Drawing.Size(103, 21);
|
||||
this.textBox_connectTo.TabIndex = 3;
|
||||
this.textBox_connectTo.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// textBox_connectPort
|
||||
//
|
||||
this.textBox_connectPort.Location = new System.Drawing.Point(223, 32);
|
||||
this.textBox_connectPort.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBox_connectPort.Name = "textBox_connectPort";
|
||||
this.textBox_connectPort.Size = new System.Drawing.Size(57, 21);
|
||||
this.textBox_connectPort.TabIndex = 4;
|
||||
this.textBox_connectPort.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(189, 35);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(29, 12);
|
||||
this.label3.TabIndex = 0;
|
||||
this.label3.Text = "Port";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(206, 62);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(74, 22);
|
||||
this.button1.TabIndex = 6;
|
||||
this.button1.Text = "Add";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(14, 66);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(29, 12);
|
||||
this.label4.TabIndex = 0;
|
||||
this.label4.Text = "Type";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(189, 11);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(29, 12);
|
||||
this.label5.TabIndex = 0;
|
||||
this.label5.Text = "Port";
|
||||
//
|
||||
// textBox_listenPort
|
||||
//
|
||||
this.textBox_listenPort.Location = new System.Drawing.Point(223, 8);
|
||||
this.textBox_listenPort.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBox_listenPort.Name = "textBox_listenPort";
|
||||
this.textBox_listenPort.Size = new System.Drawing.Size(57, 21);
|
||||
this.textBox_listenPort.TabIndex = 2;
|
||||
this.textBox_listenPort.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// comboBox_type
|
||||
//
|
||||
this.comboBox_type.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
|
||||
this.comboBox_type.FormattingEnabled = true;
|
||||
this.comboBox_type.Items.AddRange(new object[] {
|
||||
"v4tov4",
|
||||
"v4tov6",
|
||||
"v6tov4",
|
||||
"v6tov6"});
|
||||
this.comboBox_type.Location = new System.Drawing.Point(78, 64);
|
||||
this.comboBox_type.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.comboBox_type.Name = "comboBox_type";
|
||||
this.comboBox_type.Size = new System.Drawing.Size(104, 20);
|
||||
this.comboBox_type.TabIndex = 5;
|
||||
//
|
||||
// NewProxy
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(291, 90);
|
||||
this.Controls.Add(this.comboBox_type);
|
||||
this.Controls.Add(this.textBox_listenPort);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.textBox_connectPort);
|
||||
this.Controls.Add(this.textBox_connectTo);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.textBox_listenOn);
|
||||
this.Controls.Add(this.label1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "NewProxy";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "New Proxy";
|
||||
this.TopMost = true;
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.NewProxy_FormClosing);
|
||||
this.Load += new System.EventHandler(this.NewProxy_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox textBox_listenOn;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TextBox textBox_connectTo;
|
||||
private System.Windows.Forms.TextBox textBox_connectPort;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.TextBox textBox_listenPort;
|
||||
private System.Windows.Forms.ComboBox comboBox_type;
|
||||
}
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
using PortProxyGUI._extern.NStandard;
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PortProxyGUI
|
||||
{
|
||||
public partial class NewProxy : Form
|
||||
{
|
||||
public readonly PortProxyGUI PortProxyGUI;
|
||||
|
||||
public NewProxy(PortProxyGUI portProxyGUI)
|
||||
{
|
||||
PortProxyGUI = portProxyGUI;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void AddPortProxy(string type, string listenOn, string listenPort, string connectTo, string connectPort)
|
||||
{
|
||||
var output = CmdRunner.Execute($"netsh interface portproxy add {type} listenaddress={listenOn} listenport={listenPort} connectaddress={connectTo} connectport={connectPort}");
|
||||
Invoke((Action)(() => PortProxyGUI.RefreshProxyList()));
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
var type = comboBox_type.Text;
|
||||
var listenOn = textBox_listenOn.Text;
|
||||
var connectTo = textBox_connectTo.Text;
|
||||
var listenPort = textBox_listenPort.Text;
|
||||
var connectPort = textBox_connectPort.Text;
|
||||
|
||||
if (!int.TryParse(listenPort, out var _listenPort) || _listenPort < 0 || _listenPort > 65535)
|
||||
{
|
||||
MessageBox.Show($"The listen port is invalid.", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(connectPort, out var _connectPort) || _connectPort < 0 || _connectPort > 65535)
|
||||
{
|
||||
MessageBox.Show($"The connect port is invalid.", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
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)
|
||||
{
|
||||
MessageBox.Show($"The address which is connect to is neither IPv4 nor IPv6.", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!connectTo_ipv4 && !connectTo_ipv6)
|
||||
{
|
||||
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;
|
||||
}
|
||||
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";
|
||||
}
|
||||
|
||||
AddPortProxy(type, listenOn, listenPort, connectTo, connectPort);
|
||||
}
|
||||
|
||||
private void NewProxy_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void NewProxy_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
PortProxyGUI.NewProxyForm = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -1,123 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{1B166039-E98C-404A-89A5-C981364B5546}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>PortProxyGUI</RootNamespace>
|
||||
<AssemblyName>PortProxyGUI</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<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>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="About.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="About.Designer.cs">
|
||||
<DependentUpon>About.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="NewProxy.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NewProxy.Designer.cs">
|
||||
<DependentUpon>NewProxy.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="PortProxyGUI.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="PortProxyGUI.Designer.cs">
|
||||
<DependentUpon>PortProxyGUI.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="About.resx">
|
||||
<DependentUpon>About.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="NewProxy.resx">
|
||||
<DependentUpon>NewProxy.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="PortProxyGUI.resx">
|
||||
<DependentUpon>PortProxyGUI.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="app.manifest" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="..\PortProxyGUI.Shared\PortProxyGUI.Shared.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -1,173 +0,0 @@
|
|||
namespace PortProxyGUI
|
||||
{
|
||||
partial class PortProxyGUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.listView1 = new System.Windows.Forms.ListView();
|
||||
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.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.contextMenuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// listView1
|
||||
//
|
||||
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnHeader1,
|
||||
this.columnHeader2,
|
||||
this.columnHeader3,
|
||||
this.columnHeader4,
|
||||
this.columnHeader5});
|
||||
this.listView1.ContextMenuStrip = this.contextMenuStrip1;
|
||||
this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.listView1.FullRowSelect = true;
|
||||
this.listView1.HideSelection = false;
|
||||
this.listView1.Location = new System.Drawing.Point(0, 0);
|
||||
this.listView1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.listView1.Name = "listView1";
|
||||
this.listView1.Size = new System.Drawing.Size(573, 262);
|
||||
this.listView1.TabIndex = 0;
|
||||
this.listView1.UseCompatibleStateImageBehavior = false;
|
||||
this.listView1.View = System.Windows.Forms.View.Details;
|
||||
this.listView1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseUp);
|
||||
//
|
||||
// columnHeader1
|
||||
//
|
||||
this.columnHeader1.Text = "Type";
|
||||
//
|
||||
// columnHeader2
|
||||
//
|
||||
this.columnHeader2.Text = "Listen on";
|
||||
this.columnHeader2.Width = 140;
|
||||
//
|
||||
// columnHeader3
|
||||
//
|
||||
this.columnHeader3.Text = "Listen port";
|
||||
this.columnHeader3.Width = 100;
|
||||
//
|
||||
// columnHeader4
|
||||
//
|
||||
this.columnHeader4.Text = "Connect to";
|
||||
this.columnHeader4.Width = 140;
|
||||
//
|
||||
// contextMenuStrip1
|
||||
//
|
||||
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripMenuItem1,
|
||||
this.toolStripMenuItem2,
|
||||
this.toolStripSeparator1,
|
||||
this.toolStripMenuItem3,
|
||||
this.toolStripSeparator2,
|
||||
this.toolStripMenuItem4});
|
||||
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
||||
this.contextMenuStrip1.Size = new System.Drawing.Size(121, 104);
|
||||
this.contextMenuStrip1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.contextMenuStrip1_MouseClick);
|
||||
//
|
||||
// toolStripMenuItem1
|
||||
//
|
||||
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||
this.toolStripMenuItem1.Size = new System.Drawing.Size(120, 22);
|
||||
this.toolStripMenuItem1.Text = "New";
|
||||
//
|
||||
// toolStripMenuItem2
|
||||
//
|
||||
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
|
||||
this.toolStripMenuItem2.Size = new System.Drawing.Size(120, 22);
|
||||
this.toolStripMenuItem2.Text = "Delete";
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(117, 6);
|
||||
//
|
||||
// toolStripMenuItem3
|
||||
//
|
||||
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
|
||||
this.toolStripMenuItem3.Size = new System.Drawing.Size(120, 22);
|
||||
this.toolStripMenuItem3.Text = "Refresh";
|
||||
//
|
||||
// toolStripSeparator2
|
||||
//
|
||||
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
||||
this.toolStripSeparator2.Size = new System.Drawing.Size(117, 6);
|
||||
//
|
||||
// toolStripMenuItem4
|
||||
//
|
||||
this.toolStripMenuItem4.Name = "toolStripMenuItem4";
|
||||
this.toolStripMenuItem4.Size = new System.Drawing.Size(120, 22);
|
||||
this.toolStripMenuItem4.Text = "About";
|
||||
//
|
||||
// columnHeader5
|
||||
//
|
||||
this.columnHeader5.Text = "Connect port";
|
||||
this.columnHeader5.Width = 100;
|
||||
//
|
||||
// PortProxyGUI
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(573, 262);
|
||||
this.Controls.Add(this.listView1);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "PortProxyGUI";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Port Proxy GUI";
|
||||
this.Load += new System.EventHandler(this.PortProxyGUI_Load);
|
||||
this.contextMenuStrip1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ListView listView1;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader1;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader2;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader3;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader4;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader5;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
using PortProxyGUI._extern.NStandard;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.ListViewItem;
|
||||
|
||||
namespace PortProxyGUI
|
||||
{
|
||||
public partial class PortProxyGUI : Form
|
||||
{
|
||||
public NewProxy NewProxyForm;
|
||||
public About AboutForm;
|
||||
|
||||
public PortProxyGUI()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void PortProxyGUI_Load(object sender, EventArgs e)
|
||||
{
|
||||
RefreshProxyList();
|
||||
}
|
||||
|
||||
private void DeleteSelectedProxies()
|
||||
{
|
||||
var items = listView1.SelectedItems.OfType<ListViewItem>();
|
||||
foreach (var item in items)
|
||||
{
|
||||
var subItems = item.SubItems.OfType<ListViewSubItem>().ToArray();
|
||||
var type = subItems[0].Text;
|
||||
var listenOn= subItems[1].Text;
|
||||
var listenPort = subItems[2].Text;
|
||||
var output = CmdRunner.Execute($"netsh interface portproxy delete {type} listenaddress={listenOn} listenport={listenPort}");
|
||||
}
|
||||
|
||||
RefreshProxyList();
|
||||
}
|
||||
|
||||
public void RefreshProxyList()
|
||||
{
|
||||
var output = CmdRunner.Execute("netsh interface portproxy show all");
|
||||
var types = new[]
|
||||
{
|
||||
new ProxyType("ipv4", "ipv4"),
|
||||
new ProxyType("ipv4", "ipv6"),
|
||||
new ProxyType("ipv6", "ipv4"),
|
||||
new ProxyType("ipv6", "ipv6"),
|
||||
};
|
||||
|
||||
var proxies = types.SelectMany(type =>
|
||||
{
|
||||
var typeProxies = output
|
||||
.Project(new Regex($@"{type.From}:[^\n]+?{type.To}:\r\n\r\n.+?\r\n--------------- ---------- --------------- ----------\r\n(.+?)\r\n\r\n", RegexOptions.Singleline))
|
||||
?.Split(new[] { Environment.NewLine }, StringSplitOptions.None)
|
||||
.Select(line =>
|
||||
{
|
||||
var parts = line.Resolve(new Regex(@"^([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)$"));
|
||||
return new PortProxy
|
||||
{
|
||||
Type = type.Type,
|
||||
ListenOn = parts[1].FirstOrDefault(),
|
||||
ListenPort = parts[2].FirstOrDefault(),
|
||||
ConnectTo = parts[3].FirstOrDefault(),
|
||||
ConnectPort = parts[4].FirstOrDefault(),
|
||||
};
|
||||
});
|
||||
return typeProxies ?? new PortProxy[0];
|
||||
});
|
||||
|
||||
listView1.Items.Clear();
|
||||
foreach (var proxy in proxies)
|
||||
{
|
||||
listView1.Items.Add(new ListViewItem(proxy.Type).Then(vitem =>
|
||||
{
|
||||
vitem.SubItems.AddRange(new[] { proxy.ListenOn, proxy.ListenPort, proxy.ConnectTo, proxy.ConnectPort });
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private void contextMenuStrip1_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender is ContextMenuStrip _sender)
|
||||
{
|
||||
var selected = _sender.Items.OfType<ToolStripItem>().Where(x => x.Selected).FirstOrDefault();
|
||||
if (selected is null || !selected.Enabled) return;
|
||||
|
||||
switch (selected.Text)
|
||||
{
|
||||
case "New":
|
||||
if (NewProxyForm == null)
|
||||
{
|
||||
NewProxyForm = new NewProxy(this);
|
||||
NewProxyForm.Show();
|
||||
}
|
||||
else NewProxyForm.Show();
|
||||
break;
|
||||
|
||||
case "Refresh": RefreshProxyList(); break;
|
||||
case "Delete": DeleteSelectedProxies(); break;
|
||||
|
||||
case "About":
|
||||
if (AboutForm == null)
|
||||
{
|
||||
AboutForm = new About();
|
||||
AboutForm.Show();
|
||||
}
|
||||
else AboutForm.Show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void listView1_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender is ListView _sender)
|
||||
{
|
||||
if (e.Button == MouseButtons.Right && _sender.SelectedItems.OfType<ListViewItem>().Any())
|
||||
toolStripMenuItem2.Enabled = true;
|
||||
else toolStripMenuItem2.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
|
@ -1,19 +0,0 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PortProxyGUI
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new PortProxyGUI());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
using System.Reflection;
|
||||
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: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("PortProxyGUI - FW")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("1b166039-e98c-404a-89a5-c981364b5546")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// 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.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -1,63 +0,0 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace PortProxyGUI.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PortProxyGUI.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -1,26 +0,0 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace PortProxyGUI.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.6.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
|
@ -1,76 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<!-- UAC Manifest Options
|
||||
If you want to change the Windows User Account Control level replace the
|
||||
requestedExecutionLevel node with one of the following.
|
||||
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
|
||||
|
||||
Specifying requestedExecutionLevel element will disable file and registry virtualization.
|
||||
Remove this element if your application requires this virtualization for backwards
|
||||
compatibility.
|
||||
-->
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- A list of the Windows versions that this application has been tested on
|
||||
and is designed to work with. Uncomment the appropriate elements
|
||||
and Windows will automatically select the most compatible environment. -->
|
||||
|
||||
<!-- Windows Vista -->
|
||||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
|
||||
|
||||
<!-- Windows 7 -->
|
||||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
|
||||
|
||||
<!-- Windows 8 -->
|
||||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
|
||||
|
||||
<!-- Windows 8.1 -->
|
||||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
|
||||
|
||||
<!-- Windows 10 -->
|
||||
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
|
||||
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
|
||||
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
|
||||
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
|
||||
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
|
||||
<!--
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
-->
|
||||
|
||||
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
|
||||
<!--
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
</assembly>
|
|
@ -1,25 +0,0 @@
|
|||
using System.Diagnostics;
|
||||
|
||||
namespace PortProxyGUI
|
||||
{
|
||||
public static class CmdRunner
|
||||
{
|
||||
public static string Execute(string cmd)
|
||||
{
|
||||
var proc = Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "cmd",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardInput = true,
|
||||
RedirectStandardOutput = true,
|
||||
CreateNoWindow = true,
|
||||
});
|
||||
proc.Start();
|
||||
|
||||
proc.StandardInput.WriteLine($"{cmd} & exit");
|
||||
var output = proc.StandardOutput.ReadToEnd();
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
namespace PortProxyGUI
|
||||
{
|
||||
public class PortProxy
|
||||
{
|
||||
public string Type { get; set; }
|
||||
|
||||
public string ListenOn { get; set; }
|
||||
public string ListenPort { get; set; }
|
||||
|
||||
public string ConnectTo { get; set; }
|
||||
public string ConnectPort { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
<HasSharedItems>true</HasSharedItems>
|
||||
<SharedGUID>b38ef2b9-e38d-4d6d-bf0d-7c1934d6cfdc</SharedGUID>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration">
|
||||
<Import_RootNamespace>PortProxyGUI.Shared</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)CmdRunner.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)PortProxy.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ProxyType.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)~extern\NStandard\XString.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)~extern\NStandard\XObject.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>b38ef2b9-e38d-4d6d-bf0d-7c1934d6cfdc</ProjectGuid>
|
||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
|
||||
<PropertyGroup />
|
||||
<Import Project="PortProxyGUI.Shared.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
|
||||
</Project>
|
|
@ -1,28 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace PortProxyGUI
|
||||
{
|
||||
public class ProxyType
|
||||
{
|
||||
public ProxyType(string from, string to)
|
||||
{
|
||||
From = from;
|
||||
To = to;
|
||||
}
|
||||
|
||||
public string From { get; set; }
|
||||
public string To { get; set; }
|
||||
public string Type
|
||||
{
|
||||
get
|
||||
{
|
||||
if (From == "ipv4" && To == "ipv4") return "v4tov4";
|
||||
if (From == "ipv4" && To == "ipv6") return "v4tov6";
|
||||
if (From == "ipv6" && To == "ipv4") return "v6tov4";
|
||||
if (From == "ipv6" && To == "ipv6") return "v6tov6";
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace PortProxyGUI._extern.NStandard
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static class XObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Do a task for itself, then return itself.
|
||||
/// </summary>
|
||||
/// <typeparam name="TSelf"></typeparam>
|
||||
/// <param name="this"></param>
|
||||
/// <param name="task"></param>
|
||||
/// <returns></returns>
|
||||
public static TSelf Then<TSelf>(this TSelf @this, Action<TSelf> task)
|
||||
{
|
||||
task(@this);
|
||||
return @this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace PortProxyGUI._extern.NStandard
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static class XString
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates whether the string matches the specified regular expression.
|
||||
/// </summary>
|
||||
/// <param name="this"></param>
|
||||
/// <param name="regex"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsMatch(this string @this, Regex regex) => regex.Match(@this).Success;
|
||||
|
||||
/// <summary>
|
||||
/// Projects the specified string to a new string by using regular expressions.
|
||||
/// If there is no match, this method returns null.
|
||||
/// </summary>
|
||||
/// <param name="this"></param>
|
||||
/// <param name="regex"></param>
|
||||
/// <param name="target"></param>
|
||||
/// <returns></returns>
|
||||
public static string Project(this string @this, Regex regex, string target = null)
|
||||
{
|
||||
var match = regex.Match(@this);
|
||||
if (match.Success)
|
||||
{
|
||||
if (target is null)
|
||||
return string.Join("", match.Groups.OfType<Group>().Skip(1).Select(g => g.Value).ToArray());
|
||||
else return regex.Replace(match.Groups[0].Value, target);
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Projects the specified string to an array by using regular expressions.
|
||||
/// </summary>
|
||||
/// <param name="this"></param>
|
||||
/// <param name="regex"></param>
|
||||
/// <returns></returns>
|
||||
public static string[][] Resolve(this string @this, Regex regex)
|
||||
{
|
||||
if (TryResolve(@this, regex, out var ret)) return ret;
|
||||
else throw new ArgumentNullException("Can not match the sepecifed Regex.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Projects the specified string to an array by using regular expressions.
|
||||
/// </summary>
|
||||
/// <param name="this"></param>
|
||||
/// <param name="regex"></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryResolve(this string @this, Regex regex, out string[][] ret)
|
||||
{
|
||||
var match = regex.Match(@this);
|
||||
if (match.Success)
|
||||
{
|
||||
ret = match.Groups.OfType<Group>()
|
||||
.Select(g => g.Captures.OfType<Capture>().Select(c => c.Value).ToArray()).ToArray();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,20 +1,21 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.1.32210.238
|
||||
MinimumVisualStudioVersion = 15.0.26124.0
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PortProxyGUI", "PortProxyGUI\PortProxyGUI.csproj", "{7459E9F4-8B98-42D6-92CF-E90961E05C90}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortProxyGUI - FW", "PortProxyGUI - FW\PortProxyGUI - FW.csproj", "{1B166039-E98C-404A-89A5-C981364B5546}"
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{E48EF63C-74A5-42B5-BFC5-20652E856B1F}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
docs\ui.png = docs\ui.png
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "PortProxyGUI.Shared", "PortProxyGUI.Shared\PortProxyGUI.Shared.shproj", "{B38EF2B9-E38D-4D6D-BF0D-7C1934D6CFDC}"
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{444021F3-829E-4682-ACD5-B57FA46CC534}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
README.md = README.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
PortProxyGUI.Shared\PortProxyGUI.Shared.projitems*{1b166039-e98c-404a-89a5-c981364b5546}*SharedItemsImports = 4
|
||||
PortProxyGUI.Shared\PortProxyGUI.Shared.projitems*{7459e9f4-8b98-42d6-92cf-e90961e05c90}*SharedItemsImports = 5
|
||||
PortProxyGUI.Shared\PortProxyGUI.Shared.projitems*{b38ef2b9-e38d-4d6d-bf0d-7c1934d6cfdc}*SharedItemsImports = 13
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
|
@ -36,18 +37,6 @@ Global
|
|||
{7459E9F4-8B98-42D6-92CF-E90961E05C90}.Release|x64.Build.0 = Release|Any CPU
|
||||
{7459E9F4-8B98-42D6-92CF-E90961E05C90}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{7459E9F4-8B98-42D6-92CF-E90961E05C90}.Release|x86.Build.0 = Release|Any CPU
|
||||
{1B166039-E98C-404A-89A5-C981364B5546}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1B166039-E98C-404A-89A5-C981364B5546}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1B166039-E98C-404A-89A5-C981364B5546}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{1B166039-E98C-404A-89A5-C981364B5546}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{1B166039-E98C-404A-89A5-C981364B5546}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{1B166039-E98C-404A-89A5-C981364B5546}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{1B166039-E98C-404A-89A5-C981364B5546}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1B166039-E98C-404A-89A5-C981364B5546}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1B166039-E98C-404A-89A5-C981364B5546}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{1B166039-E98C-404A-89A5-C981364B5546}.Release|x64.Build.0 = Release|Any CPU
|
||||
{1B166039-E98C-404A-89A5-C981364B5546}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{1B166039-E98C-404A-89A5-C981364B5546}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -1,66 +1,84 @@
|
|||
namespace PortProxyGUI
|
||||
namespace PortProxyGUI;
|
||||
|
||||
partial class About
|
||||
{
|
||||
partial class About
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
components.Dispose();
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// linkLabel1
|
||||
//
|
||||
this.linkLabel1.Location = new System.Drawing.Point(12, 22);
|
||||
this.linkLabel1.Name = "linkLabel1";
|
||||
this.linkLabel1.Size = new System.Drawing.Size(321, 23);
|
||||
this.linkLabel1.TabIndex = 0;
|
||||
this.linkLabel1.TabStop = true;
|
||||
this.linkLabel1.Text = "https://github.com/zmjack/PortProxyGUI";
|
||||
this.linkLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.linkLabel1.Click += new System.EventHandler(this.linkLabel1_Click);
|
||||
//
|
||||
// About
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(345, 79);
|
||||
this.Controls.Add(this.linkLabel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "About";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "About";
|
||||
this.TopMost = true;
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.LinkLabel linkLabel1;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(About));
|
||||
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label_version = new System.Windows.Forms.Label();
|
||||
this.label_Star = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// linkLabel1
|
||||
//
|
||||
resources.ApplyResources(this.linkLabel1, "linkLabel1");
|
||||
this.linkLabel1.Name = "linkLabel1";
|
||||
this.linkLabel1.TabStop = true;
|
||||
this.linkLabel1.Click += new System.EventHandler(this.linkLabel1_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
resources.ApplyResources(this.label1, "label1");
|
||||
this.label1.Name = "label1";
|
||||
//
|
||||
// label_version
|
||||
//
|
||||
resources.ApplyResources(this.label_version, "label_version");
|
||||
this.label_version.Name = "label_version";
|
||||
//
|
||||
// label_Star
|
||||
//
|
||||
resources.ApplyResources(this.label_Star, "label_Star");
|
||||
this.label_Star.Name = "label_Star";
|
||||
//
|
||||
// About
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.label_Star);
|
||||
this.Controls.Add(this.label_version);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.linkLabel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "About";
|
||||
this.TopMost = true;
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.About_FormClosing);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.LinkLabel linkLabel1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label_version;
|
||||
private System.Windows.Forms.Label label_Star;
|
||||
}
|
|
@ -2,21 +2,30 @@
|
|||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PortProxyGUI
|
||||
{
|
||||
public partial class About : Form
|
||||
{
|
||||
public About()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
namespace PortProxyGUI;
|
||||
|
||||
private void linkLabel1_Click(object sender, EventArgs e)
|
||||
public partial class About : Form
|
||||
{
|
||||
public readonly PortProxyGUI PortProxyGUI;
|
||||
|
||||
public About(PortProxyGUI portProxyGUI)
|
||||
{
|
||||
PortProxyGUI = portProxyGUI;
|
||||
|
||||
InitializeComponent();
|
||||
label_version.Text = label_version.Text + " v" + Application.ProductVersion;
|
||||
}
|
||||
|
||||
private void linkLabel1_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is LinkLabel _sender)
|
||||
{
|
||||
if (sender is LinkLabel _sender)
|
||||
{
|
||||
Process.Start("explorer", _sender.Text);
|
||||
}
|
||||
Process.Start("explorer", _sender.Text);
|
||||
}
|
||||
}
|
||||
|
||||
private void About_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
PortProxyGUI.AboutForm = null;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,52 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace PortProxyGUI.Data;
|
||||
|
||||
public class AppConfig
|
||||
{
|
||||
public Size MainWindowSize = new(720, 500);
|
||||
public int[] PortProxyColumnWidths = [24, 64, 140, 100, 140, 100, 100];
|
||||
|
||||
private readonly Regex _intArrayRegex = new(@"^\[\s*(\d+)(?:\s*,\s*(\d+))*\s*\]$");
|
||||
|
||||
public AppConfig() { }
|
||||
public AppConfig(Config[] rows)
|
||||
{
|
||||
{
|
||||
var item = rows.Where(x => x.Item == "MainWindow");
|
||||
if (int.TryParse(item.FirstOrDefault(x => x.Key == "Width")?.Value, out var width)
|
||||
&& int.TryParse(item.FirstOrDefault(x => x.Key == "Height")?.Value, out var height))
|
||||
{
|
||||
MainWindowSize = new Size(width, height);
|
||||
}
|
||||
else MainWindowSize = new Size(720, 500);
|
||||
}
|
||||
|
||||
{
|
||||
var item = rows.Where(x => x.Item == "PortProxy");
|
||||
var s_ColumnWidths = item.FirstOrDefault(x => x.Key == "ColumnWidths").Value;
|
||||
var match = _intArrayRegex.Match(s_ColumnWidths);
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
PortProxyColumnWidths = match.Groups
|
||||
.OfType<Group>().Skip(1)
|
||||
.SelectMany(x => x.Captures.OfType<Capture>())
|
||||
.Select(x => int.Parse(x.Value))
|
||||
.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
#if NETCOREAPP3_0_OR_GREATER
|
||||
PortProxyColumnWidths = Array.Empty<int>();
|
||||
#else
|
||||
PortProxyColumnWidths = [];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
using NStandard;
|
||||
using SQLib.Sqlite;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace PortProxyGUI.Data;
|
||||
|
||||
public class ApplicationDbScope : SqliteScope<ApplicationDbScope>
|
||||
{
|
||||
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 ApplicationDbScope FromFile(string file)
|
||||
{
|
||||
var dir = Path.GetDirectoryName(file);
|
||||
|
||||
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
|
||||
if (!File.Exists(file))
|
||||
{
|
||||
#if NETCOREAPP3_0_OR_GREATER
|
||||
#else
|
||||
System.Data.SQLite.SQLiteConnection.CreateFile(file);
|
||||
#endif
|
||||
}
|
||||
|
||||
var scope = new ApplicationDbScope($"Data Source=\"{file}\"");
|
||||
scope.Migrate();
|
||||
return scope;
|
||||
}
|
||||
|
||||
public ApplicationDbScope(string connectionString) : base(connectionString)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void Migrate() => new MigrationUtil(this).MigrateToLast();
|
||||
|
||||
public Migration GetLastMigration()
|
||||
{
|
||||
return SqlQuery<Migration>($"SELECT * FROM __history ORDER BY MigrationId DESC LIMIT 1;").First();
|
||||
}
|
||||
|
||||
public IEnumerable<Rule> Rules => SqlQuery<Rule>($"SELECT * FROM Rules;");
|
||||
|
||||
public Rule GetRule(string type, string listenOn, int listenPort)
|
||||
{
|
||||
return SqlQuery<Rule>($"SELECT * FROM Rules WHERE Type={type} AND ListenOn={listenOn} AND ListenPort={listenPort} LIMIT 1;").FirstOrDefault();
|
||||
}
|
||||
|
||||
public void Add<T>(T obj) where T : class
|
||||
{
|
||||
var newid = Guid.NewGuid().ToString();
|
||||
if (obj is Rule rule)
|
||||
{
|
||||
Sql($"INSERT INTO Rules (Id, Type, ListenOn, ListenPort, ConnectTo, ConnectPort, Comment, `Group`) VALUES ({newid}, {rule.Type}, {rule.ListenOn}, {rule.ListenPort}, {rule.ConnectTo}, {rule.ConnectPort}, {rule.Comment ?? ""}, {rule.Group ?? ""});");
|
||||
rule.Id = newid;
|
||||
}
|
||||
else throw new NotSupportedException($"Adding {obj.GetType().FullName} is not supported.");
|
||||
}
|
||||
public void AddRange<T>(IEnumerable<T> objs) where T : class
|
||||
{
|
||||
foreach (var obj in objs) Add(obj);
|
||||
}
|
||||
|
||||
public void Update<T>(T obj) where T : class
|
||||
{
|
||||
if (obj is Rule rule)
|
||||
{
|
||||
Sql($"UPDATE Rules SET Type={rule.Type}, ListenOn={rule.ListenOn}, ListenPort={rule.ListenPort}, ConnectTo={rule.ConnectTo}, ConnectPort={rule.ConnectPort} WHERE Id={rule.Id};");
|
||||
}
|
||||
else throw new NotSupportedException($"Updating {obj.GetType().FullName} is not supported.");
|
||||
}
|
||||
public void UpdateRange<T>(IEnumerable<T> objs) where T : class
|
||||
{
|
||||
foreach (var obj in objs) Update(obj);
|
||||
}
|
||||
|
||||
public void Remove<T>(T obj) where T : class
|
||||
{
|
||||
if (obj is Rule rule)
|
||||
{
|
||||
Sql($"DELETE FROM Rules WHERE Id={rule.Id};");
|
||||
}
|
||||
else throw new NotSupportedException($"Removing {obj.GetType().FullName} is not supported.");
|
||||
}
|
||||
public void RemoveRange<T>(IEnumerable<T> objs) where T : class
|
||||
{
|
||||
foreach (var obj in objs) Remove(obj);
|
||||
}
|
||||
|
||||
public AppConfig GetAppConfig()
|
||||
{
|
||||
var configRows = SqlQuery<Config>($"SELECT * FROM Configs;");
|
||||
var appConfig = new AppConfig(configRows);
|
||||
return appConfig;
|
||||
}
|
||||
|
||||
public void SaveAppConfig(AppConfig appConfig)
|
||||
{
|
||||
Sql($"UPDATE Configs SET Value = {appConfig.MainWindowSize.Width} WHERE Item = 'MainWindow' AND `Key` = 'Width';");
|
||||
Sql($"UPDATE Configs SET Value = {appConfig.MainWindowSize.Height} WHERE Item = 'MainWindow' AND `Key` = 'Height';");
|
||||
|
||||
var s_portProxyColumnWidths = $"[{appConfig.PortProxyColumnWidths.Select(x => x.ToString()).Join(", ")}]";
|
||||
Sql($"UPDATE Configs SET Value = {s_portProxyColumnWidths} WHERE Item = 'PortProxy' AND `Key` = 'ColumnWidths';");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
namespace PortProxyGUI.Data;
|
||||
|
||||
public class Config
|
||||
{
|
||||
public string Item { get; set; }
|
||||
public string Key { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace PortProxyGUI.Data;
|
||||
|
||||
public class Migration
|
||||
{
|
||||
public string MigrationId { get; set; }
|
||||
public string ProductVersion { get; set; }
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace PortProxyGUI.Data;
|
||||
|
||||
public struct MigrationKey
|
||||
{
|
||||
public string MigrationId { get; set; }
|
||||
public string ProductVersion { get; set; }
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PortProxyGUI.Data;
|
||||
|
||||
public class MigrationUtil
|
||||
{
|
||||
public ApplicationDbScope DbScope { get; private set; }
|
||||
|
||||
public MigrationUtil(ApplicationDbScope context)
|
||||
{
|
||||
DbScope = context;
|
||||
EnsureHistoryTable();
|
||||
EnsureUpdateVersion();
|
||||
}
|
||||
|
||||
public void EnsureHistoryTable()
|
||||
{
|
||||
if (!DbScope.SqlQuery($"SELECT * FROM sqlite_master WHERE type = 'table' AND name = '__history';").Any())
|
||||
{
|
||||
DbScope.UnsafeSql(@"CREATE TABLE __history ( MigrationId text PRIMARY KEY, ProductVersion text);");
|
||||
DbScope.UnsafeSql($"INSERT INTO __history (MigrationId, ProductVersion) VALUES ('000000000000', '0.0');");
|
||||
}
|
||||
}
|
||||
|
||||
public void EnsureUpdateVersion()
|
||||
{
|
||||
var migration = DbScope.GetLastMigration();
|
||||
var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
|
||||
if (new Version(migration.ProductVersion) > assemblyVersion)
|
||||
{
|
||||
if (MessageBox.Show(@"The current software version cannot use the configuration.
|
||||
|
||||
You need to use a newer version of PortProxyGUI.
|
||||
|
||||
Would you like to download it now?", "Upgrade", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
|
||||
{
|
||||
Process.Start("explorer.exe", "https://github.com/zmjack/PortProxyGUI/releases");
|
||||
}
|
||||
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void MigrateToLast()
|
||||
{
|
||||
var migration = DbScope.GetLastMigration();
|
||||
var migrationId = migration.MigrationId;
|
||||
var pendingMigrations = migrationId != "000000000000"
|
||||
? History.SkipWhile(pair => pair.Key.MigrationId != migrationId).Skip(1)
|
||||
: History;
|
||||
|
||||
foreach (var pendingMigration in pendingMigrations)
|
||||
{
|
||||
foreach (var sql in pendingMigration.Value)
|
||||
{
|
||||
DbScope.UnsafeSql(sql);
|
||||
}
|
||||
DbScope.Sql($"INSERT INTO __history (MigrationId, ProductVersion) VALUES ({pendingMigration.Key.MigrationId}, {pendingMigration.Key.ProductVersion});");
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<MigrationKey, string[]> History = new Dictionary<MigrationKey, string[]>
|
||||
{
|
||||
[new MigrationKey { MigrationId = "202103021542", ProductVersion = "1.1.0" }] =
|
||||
[
|
||||
@"CREATE TABLE rules
|
||||
(
|
||||
Id text PRIMARY KEY,
|
||||
Type text,
|
||||
ListenOn text,
|
||||
ListenPort integer,
|
||||
ConnectTo text,
|
||||
ConnectPort integer
|
||||
);",
|
||||
"CREATE UNIQUE INDEX IX_Rules_Type_ListenOn_ListenPort ON Rules(Type, ListenOn, ListenPort);",
|
||||
],
|
||||
|
||||
[new MigrationKey { MigrationId = "202201172103", ProductVersion = "1.2.0" }] =
|
||||
[
|
||||
"ALTER TABLE rules ADD Note text;",
|
||||
"ALTER TABLE rules ADD `Group` text;",
|
||||
],
|
||||
|
||||
[new MigrationKey { MigrationId = "202202221635", ProductVersion = "1.3.0" }] =
|
||||
[
|
||||
"ALTER TABLE rules RENAME TO rulesOld;",
|
||||
"DROP INDEX IX_Rules_Type_ListenOn_ListenPort;",
|
||||
|
||||
@"CREATE TABLE rules (
|
||||
Id text PRIMARY KEY,
|
||||
Type text,
|
||||
ListenOn text,
|
||||
ListenPort integer,
|
||||
ConnectTo text,
|
||||
ConnectPort integer,
|
||||
Comment text,
|
||||
`Group` text
|
||||
);",
|
||||
"CREATE UNIQUE INDEX IX_Rules_Type_ListenOn_ListenPort ON Rules ( Type, ListenOn, ListenPort );",
|
||||
|
||||
"INSERT INTO rules SELECT Id, Type, ListenOn, ListenPort, ConnectTo, ConnectPort, Note, `Group` FROM rulesOld;",
|
||||
"DROP TABLE rulesOld;",
|
||||
],
|
||||
|
||||
[new MigrationKey { MigrationId = "202303092024", ProductVersion = "1.4.0" }] =
|
||||
[
|
||||
@"CREATE TABLE configs (
|
||||
Item text,
|
||||
`Key` text,
|
||||
Value text
|
||||
);",
|
||||
|
||||
"CREATE UNIQUE INDEX IX_Configs_Key ON configs ( Item, `Key` );",
|
||||
|
||||
"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 ( 'PortProxy', 'ColumnWidths', '[24, 64, 140, 100, 140, 100, 100]' );",
|
||||
],
|
||||
};
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
|
||||
namespace PortProxyGUI.Data;
|
||||
|
||||
public class Rule : IEquatable<Rule>
|
||||
{
|
||||
public string Id { get; set; }
|
||||
|
||||
public string Type { get; set; }
|
||||
public string ListenOn { get; set; }
|
||||
public int ListenPort { get; set; }
|
||||
public string ConnectTo { get; set; }
|
||||
public int ConnectPort { get; set; }
|
||||
public string Comment { get; set; }
|
||||
public string Group { get; set; }
|
||||
|
||||
public bool Valid => ListenPort > 0 && ConnectPort > 0;
|
||||
|
||||
private string _realListenPort;
|
||||
/// <summary>
|
||||
/// Not mapped
|
||||
/// </summary>
|
||||
public string RealListenPort
|
||||
{
|
||||
get => ListenPort > 0 ? ListenPort.ToString() : _realListenPort;
|
||||
set => _realListenPort = value;
|
||||
}
|
||||
|
||||
private string _realConnectPort;
|
||||
/// <summary>
|
||||
/// Not mapped
|
||||
/// </summary>
|
||||
public string RealConnectPort
|
||||
{
|
||||
get => ConnectPort > 0 ? ConnectPort.ToString() : _realConnectPort;
|
||||
set => _realConnectPort = value;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public bool Equals(Rule other)
|
||||
{
|
||||
return Id == other.Id
|
||||
&& Type == other.Type
|
||||
&& ListenOn == other.ListenOn
|
||||
&& ListenPort == other.ListenPort
|
||||
&& ConnectTo == other.ConnectTo
|
||||
&& ConnectPort == other.ConnectPort
|
||||
&& Comment == other.Comment
|
||||
&& Group == other.Group;
|
||||
}
|
||||
|
||||
public bool EqualsWithKeys(Rule other)
|
||||
{
|
||||
return Type == other.Type
|
||||
&& ListenOn == other.ListenOn
|
||||
&& ListenPort == other.ListenPort;
|
||||
}
|
||||
|
||||
public static int ParsePort(string portString)
|
||||
{
|
||||
if (int.TryParse(portString, out var port) && 0 < port && port < 65536) return port;
|
||||
else throw new NotSupportedException($"Invalid port string. ({portString})");
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return Equals(obj as Rule);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace PortProxyGUI.Native;
|
||||
|
||||
[Flags]
|
||||
internal enum GenericRights : uint
|
||||
{
|
||||
GENERIC_READ = 0x80000000,
|
||||
GENERIC_WRITE = 0x40000000,
|
||||
GENERIC_EXECUTE = 0x20000000,
|
||||
GENERIC_ALL = 0x10000000,
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace PortProxyGUI.Native;
|
||||
|
||||
internal class NativeMethods
|
||||
{
|
||||
[DllImport("advapi32.dll", EntryPoint = "OpenSCManagerW", ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
internal static extern IntPtr OpenSCManager(string machineName, string databaseName, uint dwAccess);
|
||||
|
||||
[DllImport("advapi32.dll", EntryPoint = "OpenServiceW", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
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)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool ControlService(IntPtr hService, ServiceControls dwControl, ref ServiceStatus lpServiceStatus);
|
||||
|
||||
[DllImport("advapi32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
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);
|
||||
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace PortProxyGUI.Native;
|
||||
|
||||
[Flags]
|
||||
internal enum ServiceControls : uint
|
||||
{
|
||||
SERVICE_CONTROL_PARAMCHANGE = 0x00000006,
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
|
||||
namespace PortProxyGUI.Native;
|
||||
|
||||
[Flags]
|
||||
internal enum ServiceRights : uint
|
||||
{
|
||||
SERVICE_QUERY_CONFIG = 0x0001,
|
||||
SERVICE_CHANGE_CONFIG = 0x0002,
|
||||
SERVICE_QUERY_STATUS = 0x0004,
|
||||
SERVICE_ENUMERATE_DEPENDENTS = 0x0008,
|
||||
SERVICE_START = 0x0010,
|
||||
SERVICE_STOP = 0x0020,
|
||||
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
|
||||
}
|
|
@ -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,
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace PortProxyGUI.Native;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct ServiceStatus
|
||||
{
|
||||
public uint dwServiceType;
|
||||
public ServiceState dwCurrentState;
|
||||
public uint dwControlsAccepted;
|
||||
public uint dwWin32ExitCode;
|
||||
public uint dwServiceSpecificExitCode;
|
||||
public uint dwCheckPoint;
|
||||
public uint dwWaitHint;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
namespace PortProxyGUI.Native;
|
||||
|
||||
internal enum StandardRights : uint
|
||||
{
|
||||
STANDARD_RIGHTS_REQUIRED = 0x000F0000,
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
namespace PortProxyGUI
|
||||
{
|
||||
partial class NewProxy
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.textBox_listenOn = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.textBox_connectTo = new System.Windows.Forms.TextBox();
|
||||
this.textBox_connectPort = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.textBox_listenPort = new System.Windows.Forms.TextBox();
|
||||
this.comboBox_type = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(13, 11);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(59, 12);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Listen on";
|
||||
//
|
||||
// textBox_listenOn
|
||||
//
|
||||
this.textBox_listenOn.Location = new System.Drawing.Point(79, 8);
|
||||
this.textBox_listenOn.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBox_listenOn.Name = "textBox_listenOn";
|
||||
this.textBox_listenOn.Size = new System.Drawing.Size(103, 21);
|
||||
this.textBox_listenOn.TabIndex = 0;
|
||||
this.textBox_listenOn.Text = "*";
|
||||
this.textBox_listenOn.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(13, 35);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(65, 12);
|
||||
this.label2.TabIndex = 0;
|
||||
this.label2.Text = "Connect to";
|
||||
//
|
||||
// textBox_connectTo
|
||||
//
|
||||
this.textBox_connectTo.Location = new System.Drawing.Point(79, 32);
|
||||
this.textBox_connectTo.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBox_connectTo.Name = "textBox_connectTo";
|
||||
this.textBox_connectTo.Size = new System.Drawing.Size(103, 21);
|
||||
this.textBox_connectTo.TabIndex = 3;
|
||||
this.textBox_connectTo.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// textBox_connectPort
|
||||
//
|
||||
this.textBox_connectPort.Location = new System.Drawing.Point(223, 32);
|
||||
this.textBox_connectPort.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBox_connectPort.Name = "textBox_connectPort";
|
||||
this.textBox_connectPort.Size = new System.Drawing.Size(57, 21);
|
||||
this.textBox_connectPort.TabIndex = 4;
|
||||
this.textBox_connectPort.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(189, 35);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(29, 12);
|
||||
this.label3.TabIndex = 0;
|
||||
this.label3.Text = "Port";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(206, 62);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(74, 22);
|
||||
this.button1.TabIndex = 6;
|
||||
this.button1.Text = "Add";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(14, 66);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(29, 12);
|
||||
this.label4.TabIndex = 0;
|
||||
this.label4.Text = "Type";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(189, 11);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(29, 12);
|
||||
this.label5.TabIndex = 0;
|
||||
this.label5.Text = "Port";
|
||||
//
|
||||
// textBox_listenPort
|
||||
//
|
||||
this.textBox_listenPort.Location = new System.Drawing.Point(223, 8);
|
||||
this.textBox_listenPort.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBox_listenPort.Name = "textBox_listenPort";
|
||||
this.textBox_listenPort.Size = new System.Drawing.Size(57, 21);
|
||||
this.textBox_listenPort.TabIndex = 2;
|
||||
this.textBox_listenPort.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// comboBox_type
|
||||
//
|
||||
this.comboBox_type.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
|
||||
this.comboBox_type.FormattingEnabled = true;
|
||||
this.comboBox_type.Items.AddRange(new object[] {
|
||||
"v4tov4",
|
||||
"v4tov6",
|
||||
"v6tov4",
|
||||
"v6tov6"});
|
||||
this.comboBox_type.Location = new System.Drawing.Point(78, 64);
|
||||
this.comboBox_type.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.comboBox_type.Name = "comboBox_type";
|
||||
this.comboBox_type.Size = new System.Drawing.Size(104, 20);
|
||||
this.comboBox_type.TabIndex = 5;
|
||||
//
|
||||
// NewProxy
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(291, 90);
|
||||
this.Controls.Add(this.comboBox_type);
|
||||
this.Controls.Add(this.textBox_listenPort);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.textBox_connectPort);
|
||||
this.Controls.Add(this.textBox_connectTo);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.textBox_listenOn);
|
||||
this.Controls.Add(this.label1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "NewProxy";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "New Proxy";
|
||||
this.TopMost = true;
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.NewProxy_FormClosing);
|
||||
this.Load += new System.EventHandler(this.NewProxy_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox textBox_listenOn;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TextBox textBox_connectTo;
|
||||
private System.Windows.Forms.TextBox textBox_connectPort;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.TextBox textBox_listenPort;
|
||||
private System.Windows.Forms.ComboBox comboBox_type;
|
||||
}
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
using PortProxyGUI._extern.NStandard;
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PortProxyGUI
|
||||
{
|
||||
public partial class NewProxy : Form
|
||||
{
|
||||
public readonly PortProxyGUI PortProxyGUI;
|
||||
|
||||
public NewProxy(PortProxyGUI portProxyGUI)
|
||||
{
|
||||
PortProxyGUI = portProxyGUI;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void AddPortProxy(string type, string listenOn, string listenPort, string connectTo, string connectPort)
|
||||
{
|
||||
var output = CmdRunner.Execute($"netsh interface portproxy add {type} listenaddress={listenOn} listenport={listenPort} connectaddress={connectTo} connectport={connectPort}");
|
||||
Invoke((Action)(() => PortProxyGUI.RefreshProxyList()));
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
var type = comboBox_type.Text;
|
||||
var listenOn = textBox_listenOn.Text;
|
||||
var connectTo = textBox_connectTo.Text;
|
||||
var listenPort = textBox_listenPort.Text;
|
||||
var connectPort = textBox_connectPort.Text;
|
||||
|
||||
if (!int.TryParse(listenPort, out var _listenPort) || _listenPort < 0 || _listenPort > 65535)
|
||||
{
|
||||
MessageBox.Show($"The listen port is invalid.", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(connectPort, out var _connectPort) || _connectPort < 0 || _connectPort > 65535)
|
||||
{
|
||||
MessageBox.Show($"The connect port is invalid.", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
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)
|
||||
{
|
||||
MessageBox.Show($"The address which is connect to is neither IPv4 nor IPv6.", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!connectTo_ipv4 && !connectTo_ipv6)
|
||||
{
|
||||
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;
|
||||
}
|
||||
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";
|
||||
}
|
||||
|
||||
AddPortProxy(type, listenOn, listenPort, connectTo, connectPort);
|
||||
}
|
||||
|
||||
private void NewProxy_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void NewProxy_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
PortProxyGUI.NewProxyForm = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -1,173 +1,300 @@
|
|||
namespace PortProxyGUI
|
||||
namespace PortProxyGUI;
|
||||
|
||||
partial class PortProxyGUI
|
||||
{
|
||||
partial class PortProxyGUI
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
components.Dispose();
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.listView1 = new System.Windows.Forms.ListView();
|
||||
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.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.contextMenuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// listView1
|
||||
//
|
||||
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnHeader1,
|
||||
this.columnHeader2,
|
||||
this.columnHeader3,
|
||||
this.columnHeader4,
|
||||
this.columnHeader5});
|
||||
this.listView1.ContextMenuStrip = this.contextMenuStrip1;
|
||||
this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.listView1.FullRowSelect = true;
|
||||
this.listView1.HideSelection = false;
|
||||
this.listView1.Location = new System.Drawing.Point(0, 0);
|
||||
this.listView1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.listView1.Name = "listView1";
|
||||
this.listView1.Size = new System.Drawing.Size(573, 262);
|
||||
this.listView1.TabIndex = 0;
|
||||
this.listView1.UseCompatibleStateImageBehavior = false;
|
||||
this.listView1.View = System.Windows.Forms.View.Details;
|
||||
this.listView1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseUp);
|
||||
//
|
||||
// columnHeader1
|
||||
//
|
||||
this.columnHeader1.Text = "Type";
|
||||
//
|
||||
// columnHeader2
|
||||
//
|
||||
this.columnHeader2.Text = "Listen on";
|
||||
this.columnHeader2.Width = 140;
|
||||
//
|
||||
// columnHeader3
|
||||
//
|
||||
this.columnHeader3.Text = "Listen port";
|
||||
this.columnHeader3.Width = 100;
|
||||
//
|
||||
// columnHeader4
|
||||
//
|
||||
this.columnHeader4.Text = "Connect to";
|
||||
this.columnHeader4.Width = 140;
|
||||
//
|
||||
// contextMenuStrip1
|
||||
//
|
||||
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripMenuItem1,
|
||||
this.toolStripMenuItem2,
|
||||
this.toolStripSeparator1,
|
||||
this.toolStripMenuItem3,
|
||||
this.toolStripSeparator2,
|
||||
this.toolStripMenuItem4});
|
||||
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
||||
this.contextMenuStrip1.Size = new System.Drawing.Size(121, 104);
|
||||
this.contextMenuStrip1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.contextMenuStrip1_MouseClick);
|
||||
//
|
||||
// toolStripMenuItem1
|
||||
//
|
||||
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||
this.toolStripMenuItem1.Size = new System.Drawing.Size(120, 22);
|
||||
this.toolStripMenuItem1.Text = "New";
|
||||
//
|
||||
// toolStripMenuItem2
|
||||
//
|
||||
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
|
||||
this.toolStripMenuItem2.Size = new System.Drawing.Size(120, 22);
|
||||
this.toolStripMenuItem2.Text = "Delete";
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(117, 6);
|
||||
//
|
||||
// toolStripMenuItem3
|
||||
//
|
||||
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
|
||||
this.toolStripMenuItem3.Size = new System.Drawing.Size(120, 22);
|
||||
this.toolStripMenuItem3.Text = "Refresh";
|
||||
//
|
||||
// toolStripSeparator2
|
||||
//
|
||||
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
||||
this.toolStripSeparator2.Size = new System.Drawing.Size(117, 6);
|
||||
//
|
||||
// toolStripMenuItem4
|
||||
//
|
||||
this.toolStripMenuItem4.Name = "toolStripMenuItem4";
|
||||
this.toolStripMenuItem4.Size = new System.Drawing.Size(120, 22);
|
||||
this.toolStripMenuItem4.Text = "About";
|
||||
//
|
||||
// columnHeader5
|
||||
//
|
||||
this.columnHeader5.Text = "Connect port";
|
||||
this.columnHeader5.Width = 100;
|
||||
//
|
||||
// PortProxyGUI
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(573, 262);
|
||||
this.Controls.Add(this.listView1);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "PortProxyGUI";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Port Proxy GUI";
|
||||
this.Load += new System.EventHandler(this.PortProxyGUI_Load);
|
||||
this.contextMenuStrip1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ListView listView1;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader1;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader2;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader3;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader4;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader5;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PortProxyGUI));
|
||||
listViewProxies = new System.Windows.Forms.ListView();
|
||||
columnHeader1 = new System.Windows.Forms.ColumnHeader();
|
||||
columnHeader2 = new System.Windows.Forms.ColumnHeader();
|
||||
columnHeader3 = new System.Windows.Forms.ColumnHeader();
|
||||
columnHeader4 = new System.Windows.Forms.ColumnHeader();
|
||||
columnHeader5 = new System.Windows.Forms.ColumnHeader();
|
||||
columnHeader6 = new System.Windows.Forms.ColumnHeader();
|
||||
columnHeader7 = new System.Windows.Forms.ColumnHeader();
|
||||
contextMenuStrip_RightClick = new System.Windows.Forms.ContextMenuStrip(components);
|
||||
toolStripMenuItem_Enable = new System.Windows.Forms.ToolStripMenuItem();
|
||||
toolStripMenuItem_Disable = new System.Windows.Forms.ToolStripMenuItem();
|
||||
toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
toolStripMenuItem_Refresh = new System.Windows.Forms.ToolStripMenuItem();
|
||||
toolStripMenuItem_FlushDnsCache = new System.Windows.Forms.ToolStripMenuItem();
|
||||
toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
toolStripMenuItem_New = new System.Windows.Forms.ToolStripMenuItem();
|
||||
toolStripMenuItem_Modify = new System.Windows.Forms.ToolStripMenuItem();
|
||||
toolStripMenuItem_Delete = new System.Windows.Forms.ToolStripMenuItem();
|
||||
toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
toolStripMenuItem_More = new System.Windows.Forms.ToolStripMenuItem();
|
||||
toolStripMenuItem_Import = 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();
|
||||
toolStripMenuItem_About = new System.Windows.Forms.ToolStripMenuItem();
|
||||
imageListProxies = new System.Windows.Forms.ImageList(components);
|
||||
saveFileDialog_Export = new System.Windows.Forms.SaveFileDialog();
|
||||
openFileDialog_Import = new System.Windows.Forms.OpenFileDialog();
|
||||
statusStrip_Footer = new System.Windows.Forms.StatusStrip();
|
||||
toolStripStatusLabel_Status = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
toolStripStatusLabel_ServiceNotRunning = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
contextMenuStrip_RightClick.SuspendLayout();
|
||||
statusStrip_Footer.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// listViewProxies
|
||||
//
|
||||
listViewProxies.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
listViewProxies.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { columnHeader1, columnHeader2, columnHeader3, columnHeader4, columnHeader5, columnHeader6, columnHeader7 });
|
||||
listViewProxies.ContextMenuStrip = contextMenuStrip_RightClick;
|
||||
resources.ApplyResources(listViewProxies, "listViewProxies");
|
||||
listViewProxies.FullRowSelect = true;
|
||||
listViewProxies.Name = "listViewProxies";
|
||||
listViewProxies.SmallImageList = imageListProxies;
|
||||
listViewProxies.UseCompatibleStateImageBehavior = false;
|
||||
listViewProxies.View = System.Windows.Forms.View.Details;
|
||||
listViewProxies.ColumnClick += listView1_ColumnClick;
|
||||
listViewProxies.ColumnWidthChanged += listViewProxies_ColumnWidthChanged;
|
||||
listViewProxies.DoubleClick += listView1_DoubleClick;
|
||||
listViewProxies.KeyUp += listViewProxies_KeyUp;
|
||||
listViewProxies.MouseUp += listView1_MouseUp;
|
||||
//
|
||||
// columnHeader1
|
||||
//
|
||||
resources.ApplyResources(columnHeader1, "columnHeader1");
|
||||
//
|
||||
// columnHeader2
|
||||
//
|
||||
resources.ApplyResources(columnHeader2, "columnHeader2");
|
||||
//
|
||||
// columnHeader3
|
||||
//
|
||||
resources.ApplyResources(columnHeader3, "columnHeader3");
|
||||
//
|
||||
// columnHeader4
|
||||
//
|
||||
columnHeader4.Tag = "";
|
||||
resources.ApplyResources(columnHeader4, "columnHeader4");
|
||||
//
|
||||
// columnHeader5
|
||||
//
|
||||
resources.ApplyResources(columnHeader5, "columnHeader5");
|
||||
//
|
||||
// columnHeader6
|
||||
//
|
||||
columnHeader6.Tag = "";
|
||||
resources.ApplyResources(columnHeader6, "columnHeader6");
|
||||
//
|
||||
// columnHeader7
|
||||
//
|
||||
resources.ApplyResources(columnHeader7, "columnHeader7");
|
||||
//
|
||||
// contextMenuStrip_RightClick
|
||||
//
|
||||
contextMenuStrip_RightClick.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripMenuItem_Enable, toolStripMenuItem_Disable, toolStripSeparator3, toolStripMenuItem_Refresh, toolStripMenuItem_FlushDnsCache, toolStripSeparator2, toolStripMenuItem_New, toolStripMenuItem_Modify, toolStripMenuItem_Delete, toolStripSeparator1, toolStripMenuItem_More, toolStripSeparator4, toolStripMenuItem_About });
|
||||
contextMenuStrip_RightClick.Name = "contextMenuStrip1";
|
||||
resources.ApplyResources(contextMenuStrip_RightClick, "contextMenuStrip_RightClick");
|
||||
contextMenuStrip_RightClick.MouseClick += contextMenuStrip_RightClick_MouseClick;
|
||||
//
|
||||
// toolStripMenuItem_Enable
|
||||
//
|
||||
toolStripMenuItem_Enable.Name = "toolStripMenuItem_Enable";
|
||||
resources.ApplyResources(toolStripMenuItem_Enable, "toolStripMenuItem_Enable");
|
||||
//
|
||||
// toolStripMenuItem_Disable
|
||||
//
|
||||
toolStripMenuItem_Disable.Name = "toolStripMenuItem_Disable";
|
||||
resources.ApplyResources(toolStripMenuItem_Disable, "toolStripMenuItem_Disable");
|
||||
//
|
||||
// toolStripSeparator3
|
||||
//
|
||||
toolStripSeparator3.Name = "toolStripSeparator3";
|
||||
resources.ApplyResources(toolStripSeparator3, "toolStripSeparator3");
|
||||
//
|
||||
// toolStripMenuItem_Refresh
|
||||
//
|
||||
toolStripMenuItem_Refresh.Name = "toolStripMenuItem_Refresh";
|
||||
resources.ApplyResources(toolStripMenuItem_Refresh, "toolStripMenuItem_Refresh");
|
||||
//
|
||||
// toolStripMenuItem_FlushDnsCache
|
||||
//
|
||||
toolStripMenuItem_FlushDnsCache.Name = "toolStripMenuItem_FlushDnsCache";
|
||||
resources.ApplyResources(toolStripMenuItem_FlushDnsCache, "toolStripMenuItem_FlushDnsCache");
|
||||
//
|
||||
// toolStripSeparator2
|
||||
//
|
||||
toolStripSeparator2.Name = "toolStripSeparator2";
|
||||
resources.ApplyResources(toolStripSeparator2, "toolStripSeparator2");
|
||||
//
|
||||
// toolStripMenuItem_New
|
||||
//
|
||||
toolStripMenuItem_New.Name = "toolStripMenuItem_New";
|
||||
resources.ApplyResources(toolStripMenuItem_New, "toolStripMenuItem_New");
|
||||
//
|
||||
// toolStripMenuItem_Modify
|
||||
//
|
||||
toolStripMenuItem_Modify.Name = "toolStripMenuItem_Modify";
|
||||
resources.ApplyResources(toolStripMenuItem_Modify, "toolStripMenuItem_Modify");
|
||||
//
|
||||
// toolStripMenuItem_Delete
|
||||
//
|
||||
toolStripMenuItem_Delete.Name = "toolStripMenuItem_Delete";
|
||||
resources.ApplyResources(toolStripMenuItem_Delete, "toolStripMenuItem_Delete");
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
resources.ApplyResources(toolStripSeparator1, "toolStripSeparator1");
|
||||
//
|
||||
// toolStripMenuItem_More
|
||||
//
|
||||
toolStripMenuItem_More.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripMenuItem_Import, toolStripMenuItem_Export, toolStripSeparator5, toolStripMenuItem_ResetWindowSize });
|
||||
toolStripMenuItem_More.Name = "toolStripMenuItem_More";
|
||||
resources.ApplyResources(toolStripMenuItem_More, "toolStripMenuItem_More");
|
||||
//
|
||||
// toolStripMenuItem_Import
|
||||
//
|
||||
toolStripMenuItem_Import.Name = "toolStripMenuItem_Import";
|
||||
resources.ApplyResources(toolStripMenuItem_Import, "toolStripMenuItem_Import");
|
||||
toolStripMenuItem_Import.Click += toolStripMenuItem_Import_Click;
|
||||
//
|
||||
// toolStripMenuItem_Export
|
||||
//
|
||||
toolStripMenuItem_Export.Name = "toolStripMenuItem_Export";
|
||||
resources.ApplyResources(toolStripMenuItem_Export, "toolStripMenuItem_Export");
|
||||
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.Name = "toolStripSeparator4";
|
||||
resources.ApplyResources(toolStripSeparator4, "toolStripSeparator4");
|
||||
//
|
||||
// toolStripMenuItem_About
|
||||
//
|
||||
toolStripMenuItem_About.Name = "toolStripMenuItem_About";
|
||||
resources.ApplyResources(toolStripMenuItem_About, "toolStripMenuItem_About");
|
||||
//
|
||||
// imageListProxies
|
||||
//
|
||||
imageListProxies.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
|
||||
imageListProxies.ImageStream = (System.Windows.Forms.ImageListStreamer)resources.GetObject("imageListProxies.ImageStream");
|
||||
imageListProxies.TransparentColor = System.Drawing.Color.Transparent;
|
||||
imageListProxies.Images.SetKeyName(0, "disable.png");
|
||||
imageListProxies.Images.SetKeyName(1, "enable.png");
|
||||
//
|
||||
// saveFileDialog_Export
|
||||
//
|
||||
resources.ApplyResources(saveFileDialog_Export, "saveFileDialog_Export");
|
||||
//
|
||||
// openFileDialog_Import
|
||||
//
|
||||
openFileDialog_Import.FileName = "openFileDialog1";
|
||||
resources.ApplyResources(openFileDialog_Import, "openFileDialog_Import");
|
||||
//
|
||||
// statusStrip_Footer
|
||||
//
|
||||
statusStrip_Footer.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripStatusLabel_Status, toolStripStatusLabel_ServiceNotRunning });
|
||||
resources.ApplyResources(statusStrip_Footer, "statusStrip_Footer");
|
||||
statusStrip_Footer.Name = "statusStrip_Footer";
|
||||
//
|
||||
// toolStripStatusLabel_Status
|
||||
//
|
||||
toolStripStatusLabel_Status.Name = "toolStripStatusLabel_Status";
|
||||
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
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
Controls.Add(statusStrip_Footer);
|
||||
Controls.Add(listViewProxies);
|
||||
Name = "PortProxyGUI";
|
||||
FormClosing += PortProxyGUI_FormClosing;
|
||||
Load += PortProxyGUI_Load;
|
||||
Shown += PortProxyGUI_Shown;
|
||||
Resize += PortProxyGUI_Resize;
|
||||
contextMenuStrip_RightClick.ResumeLayout(false);
|
||||
statusStrip_Footer.ResumeLayout(false);
|
||||
statusStrip_Footer.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.ColumnHeader columnHeader2;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader3;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStrip_RightClick;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_New;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_Delete;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader4;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_Refresh;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader5;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_About;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader6;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_Modify;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader1;
|
||||
private System.Windows.Forms.ImageList imageListProxies;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_Enable;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_Disable;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader7;
|
||||
internal System.Windows.Forms.ListView listViewProxies;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_FlushDnsCache;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_More;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_Export;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_Import;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
|
||||
private System.Windows.Forms.SaveFileDialog saveFileDialog_Export;
|
||||
private System.Windows.Forms.OpenFileDialog openFileDialog_Import;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator5;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,125 +1,408 @@
|
|||
using PortProxyGUI._extern.NStandard;
|
||||
using NStandard;
|
||||
using PortProxyGUI.Data;
|
||||
using PortProxyGUI.UI;
|
||||
using PortProxyGUI.Utils;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
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();
|
||||
|
||||
public SetProxy SetProxyForm;
|
||||
public About AboutForm;
|
||||
private AppConfig AppConfig;
|
||||
|
||||
public PortProxyGUI()
|
||||
{
|
||||
public NewProxy NewProxyForm;
|
||||
public About AboutForm;
|
||||
InitializeComponent();
|
||||
listViewProxies.ListViewItemSorter = lvwColumnSorter;
|
||||
}
|
||||
|
||||
public PortProxyGUI()
|
||||
private void PortProxyGUI_Load(object sender, EventArgs e)
|
||||
{
|
||||
AppConfig = Program.Database.GetAppConfig();
|
||||
|
||||
var size = AppConfig.MainWindowSize;
|
||||
Left -= (size.Width - Width) / 2;
|
||||
Top -= (size.Height - Height) / 2;
|
||||
|
||||
ResetWindowSize();
|
||||
}
|
||||
|
||||
private void PortProxyGUI_Shown(object sender, EventArgs e)
|
||||
{
|
||||
RefreshProxyList();
|
||||
}
|
||||
|
||||
private void ResetWindowSize()
|
||||
{
|
||||
Size = AppConfig.MainWindowSize;
|
||||
|
||||
if (AppConfig.PortProxyColumnWidths.Length != listViewProxies.Columns.Count)
|
||||
{
|
||||
InitializeComponent();
|
||||
Any.ReDim(ref AppConfig.PortProxyColumnWidths, listViewProxies.Columns.Count);
|
||||
}
|
||||
|
||||
private void PortProxyGUI_Load(object sender, EventArgs e)
|
||||
foreach (var (column, configWidth) in Any.Zip(listViewProxies.Columns.OfType<ColumnHeader>(), AppConfig.PortProxyColumnWidths))
|
||||
{
|
||||
RefreshProxyList();
|
||||
column.Width = configWidth;
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteSelectedProxies()
|
||||
private Data.Rule ParseRule(ListViewItem item)
|
||||
{
|
||||
var subItems = item.SubItems.OfType<ListViewSubItem>().ToArray();
|
||||
int listenPort, connectPort;
|
||||
|
||||
listenPort = Data.Rule.ParsePort(subItems[3].Text);
|
||||
connectPort = Data.Rule.ParsePort(subItems[5].Text);
|
||||
|
||||
var rule = new Data.Rule
|
||||
{
|
||||
var items = listView1.SelectedItems.OfType<ListViewItem>();
|
||||
foreach (var item in items)
|
||||
Type = subItems[1].Text.Trim(),
|
||||
ListenOn = subItems[2].Text.Trim(),
|
||||
ListenPort = listenPort,
|
||||
ConnectTo = subItems[4].Text.Trim(),
|
||||
ConnectPort = connectPort,
|
||||
Comment = subItems[6].Text.Trim(),
|
||||
Group = item.Group?.Header.Trim(),
|
||||
};
|
||||
return rule;
|
||||
}
|
||||
|
||||
private void EnableSelectedProxies()
|
||||
{
|
||||
var items = listViewProxies.SelectedItems.OfType<ListViewItem>();
|
||||
foreach (var item in items)
|
||||
{
|
||||
item.ImageIndex = 1;
|
||||
|
||||
try
|
||||
{
|
||||
var subItems = item.SubItems.OfType<ListViewSubItem>().ToArray();
|
||||
var type = subItems[0].Text;
|
||||
var listenOn= subItems[1].Text;
|
||||
var listenPort = subItems[2].Text;
|
||||
var output = CmdRunner.Execute($"netsh interface portproxy delete {type} listenaddress={listenOn} listenport={listenPort}");
|
||||
var rule = ParseRule(item);
|
||||
Util.AddOrUpdateProxy(rule);
|
||||
}
|
||||
catch (NotSupportedException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Exclamation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Util.ParamChange();
|
||||
}
|
||||
|
||||
RefreshProxyList();
|
||||
private void DisableSelectedProxies()
|
||||
{
|
||||
var items = listViewProxies.SelectedItems.OfType<ListViewItem>();
|
||||
foreach (var item in items)
|
||||
{
|
||||
item.ImageIndex = 0;
|
||||
|
||||
try
|
||||
{
|
||||
var rule = ParseRule(item);
|
||||
Util.DeleteProxy(rule);
|
||||
}
|
||||
catch (NotSupportedException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Exclamation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Util.ParamChange();
|
||||
}
|
||||
|
||||
private void DeleteSelectedProxies()
|
||||
{
|
||||
var items = listViewProxies.SelectedItems.OfType<ListViewItem>();
|
||||
DisableSelectedProxies();
|
||||
Program.Database.RemoveRange(items.Select(x => new Data.Rule { Id = x.Tag.ToString() }));
|
||||
foreach (var item in items) listViewProxies.Items.Remove(item);
|
||||
}
|
||||
|
||||
private void SetProxyForUpdate(SetProxy form)
|
||||
{
|
||||
var item = listViewProxies.SelectedItems.OfType<ListViewItem>().FirstOrDefault();
|
||||
try
|
||||
{
|
||||
var rule = ParseRule(item);
|
||||
form.UseUpdateMode(item, rule);
|
||||
}
|
||||
catch (NotSupportedException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Exclamation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitProxyGroups(Data.Rule[] rules)
|
||||
{
|
||||
listViewProxies.Groups.Clear();
|
||||
var groups = (
|
||||
from g in rules.GroupBy(x => x.Group)
|
||||
let name = g.Key
|
||||
where !name.IsNullOrWhiteSpace()
|
||||
orderby name
|
||||
select new ListViewGroup(name)
|
||||
).ToArray();
|
||||
listViewProxies.Groups.AddRange(groups);
|
||||
}
|
||||
|
||||
private void InitProxyItems(Data.Rule[] rules, Data.Rule[] proxies)
|
||||
{
|
||||
listViewProxies.Items.Clear();
|
||||
foreach (var rule in rules)
|
||||
{
|
||||
var imageIndex = proxies.Any(p => p.EqualsWithKeys(rule)) ? 1 : 0;
|
||||
var group = listViewProxies.Groups.OfType<ListViewGroup>().FirstOrDefault(x => x.Header == rule.Group);
|
||||
|
||||
var item = new ListViewItem();
|
||||
UpdateListViewItem(item, rule, imageIndex);
|
||||
listViewProxies.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateListViewItem(ListViewItem item, Data.Rule rule, int imageIndex)
|
||||
{
|
||||
item.ImageIndex = imageIndex;
|
||||
item.Tag = rule.Id;
|
||||
item.SubItems.Clear();
|
||||
item.SubItems.AddRange(new[]
|
||||
{
|
||||
new ListViewSubItem(item, rule.Type),
|
||||
new ListViewSubItem(item, rule.ListenOn),
|
||||
new ListViewSubItem(item, rule.ListenPort.ToString()) { Tag = "Number" },
|
||||
new ListViewSubItem(item, rule.ConnectTo),
|
||||
new ListViewSubItem(item, rule.ConnectPort.ToString ()) { Tag = "Number" },
|
||||
new ListViewSubItem(item, rule.Comment ?? ""),
|
||||
});
|
||||
|
||||
if (rule.Group.IsNullOrWhiteSpace()) item.Group = null;
|
||||
else
|
||||
{
|
||||
var group = listViewProxies.Groups.OfType<ListViewGroup>().FirstOrDefault(x => x.Header == rule.Group);
|
||||
if (group == null)
|
||||
{
|
||||
group = new ListViewGroup(rule.Group);
|
||||
listViewProxies.Groups.Add(group);
|
||||
}
|
||||
item.Group = group;
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshProxyList()
|
||||
{
|
||||
var proxies = Util.GetProxies();
|
||||
var rules = Program.Database.Rules.ToArray();
|
||||
foreach (var proxy in proxies)
|
||||
{
|
||||
var matchedRule = rules.FirstOrDefault(r => r.EqualsWithKeys(proxy));
|
||||
proxy.Id = matchedRule?.Id;
|
||||
}
|
||||
|
||||
public void RefreshProxyList()
|
||||
{
|
||||
var output = CmdRunner.Execute("netsh interface portproxy show all");
|
||||
var types = new[]
|
||||
{
|
||||
new ProxyType("ipv4", "ipv4"),
|
||||
new ProxyType("ipv4", "ipv6"),
|
||||
new ProxyType("ipv6", "ipv4"),
|
||||
new ProxyType("ipv6", "ipv6"),
|
||||
};
|
||||
var pendingAdds = proxies.Where(x => x.Valid && x.Id == null);
|
||||
var pendingUpdates =
|
||||
from proxy in proxies
|
||||
let exsist = rules.FirstOrDefault(r => r.Id == proxy.Id)
|
||||
where exsist is not null
|
||||
where proxy.Valid && proxy.Id is not null
|
||||
select proxy;
|
||||
|
||||
var proxies = types.SelectMany(type =>
|
||||
Program.Database.AddRange(pendingAdds);
|
||||
Program.Database.UpdateRange(pendingUpdates);
|
||||
|
||||
rules = Program.Database.Rules.ToArray();
|
||||
InitProxyGroups(rules);
|
||||
InitProxyItems(rules, proxies);
|
||||
|
||||
// CheckServiceStatus
|
||||
toolStripStatusLabel_ServiceNotRunning.Visible = !Util.IsServiceRunning();
|
||||
}
|
||||
|
||||
private void contextMenuStrip_RightClick_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender is ContextMenuStrip strip)
|
||||
{
|
||||
var selected = strip.Items.OfType<ToolStripMenuItem>().Where(x => x.Selected).FirstOrDefault();
|
||||
if (selected is null || !selected.Enabled) return;
|
||||
|
||||
switch (selected)
|
||||
{
|
||||
var typeProxies = output
|
||||
.Project(new Regex($@"{type.From}:[^\n]+?{type.To}:\r\n\r\n.+?\r\n--------------- ---------- --------------- ----------\r\n(.+?)\r\n\r\n", RegexOptions.Singleline))
|
||||
?.Split(new[] { Environment.NewLine }, StringSplitOptions.None)
|
||||
.Select(line =>
|
||||
case ToolStripMenuItem item when item == toolStripMenuItem_Enable: EnableSelectedProxies(); break;
|
||||
case ToolStripMenuItem item when item == toolStripMenuItem_Disable: DisableSelectedProxies(); break;
|
||||
|
||||
case ToolStripMenuItem item when item == toolStripMenuItem_New:
|
||||
SetProxyForm ??= new SetProxy(this);
|
||||
SetProxyForm.UseNormalMode();
|
||||
SetProxyForm.ShowDialog();
|
||||
break;
|
||||
|
||||
case ToolStripMenuItem item when item == toolStripMenuItem_Modify:
|
||||
SetProxyForm ??= new SetProxy(this);
|
||||
SetProxyForUpdate(SetProxyForm);
|
||||
SetProxyForm.ShowDialog();
|
||||
break;
|
||||
|
||||
case ToolStripMenuItem item when item == toolStripMenuItem_Refresh:
|
||||
RefreshProxyList();
|
||||
toolStripStatusLabel_Status.Text = $"{DateTime.Now} : Refreshed.";
|
||||
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:
|
||||
if (AboutForm == null)
|
||||
{
|
||||
var parts = line.Resolve(new Regex(@"^([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)$"));
|
||||
return new PortProxy
|
||||
{
|
||||
Type = type.Type,
|
||||
ListenOn = parts[1].FirstOrDefault(),
|
||||
ListenPort = parts[2].FirstOrDefault(),
|
||||
ConnectTo = parts[3].FirstOrDefault(),
|
||||
ConnectPort = parts[4].FirstOrDefault(),
|
||||
};
|
||||
});
|
||||
return typeProxies ?? new PortProxy[0];
|
||||
});
|
||||
|
||||
listView1.Items.Clear();
|
||||
foreach (var proxy in proxies)
|
||||
{
|
||||
listView1.Items.Add(new ListViewItem(proxy.Type).Then(vitem =>
|
||||
{
|
||||
vitem.SubItems.AddRange(new[] { proxy.ListenOn, proxy.ListenPort, proxy.ConnectTo, proxy.ConnectPort });
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private void contextMenuStrip1_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender is ContextMenuStrip _sender)
|
||||
{
|
||||
var selected = _sender.Items.OfType<ToolStripItem>().Where(x => x.Selected).FirstOrDefault();
|
||||
if (selected is null || !selected.Enabled) return;
|
||||
|
||||
switch (selected.Text)
|
||||
{
|
||||
case "New":
|
||||
if (NewProxyForm == null)
|
||||
{
|
||||
NewProxyForm = new NewProxy(this);
|
||||
NewProxyForm.Show();
|
||||
}
|
||||
else NewProxyForm.Show();
|
||||
break;
|
||||
|
||||
case "Refresh": RefreshProxyList(); break;
|
||||
case "Delete": DeleteSelectedProxies(); break;
|
||||
|
||||
case "About":
|
||||
if (AboutForm == null)
|
||||
{
|
||||
AboutForm = new About();
|
||||
AboutForm.Show();
|
||||
}
|
||||
else AboutForm.Show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void listView1_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender is ListView _sender)
|
||||
{
|
||||
if (e.Button == MouseButtons.Right && _sender.SelectedItems.OfType<ListViewItem>().Any())
|
||||
toolStripMenuItem2.Enabled = true;
|
||||
else toolStripMenuItem2.Enabled = false;
|
||||
AboutForm = new About(this);
|
||||
AboutForm.Show();
|
||||
}
|
||||
else AboutForm.Show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void listView1_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender is ListView listView)
|
||||
{
|
||||
toolStripMenuItem_Enable.Enabled = e.Button == MouseButtons.Right && listView.SelectedItems.OfType<ListViewItem>().Any(x => x.ImageIndex == 0);
|
||||
toolStripMenuItem_Disable.Enabled = e.Button == MouseButtons.Right && listView.SelectedItems.OfType<ListViewItem>().Any(x => x.ImageIndex == 1);
|
||||
|
||||
toolStripMenuItem_Delete.Enabled = e.Button == MouseButtons.Right && listView.SelectedItems.OfType<ListViewItem>().Any();
|
||||
toolStripMenuItem_Modify.Enabled = e.Button == MouseButtons.Right && listView.SelectedItems.OfType<ListViewItem>().Count() == 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void listView1_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is ListView listView)
|
||||
{
|
||||
var selectAny = listView.SelectedItems.OfType<ListViewItem>().Any();
|
||||
if (selectAny)
|
||||
{
|
||||
SetProxyForm ??= new SetProxy(this);
|
||||
SetProxyForUpdate(SetProxyForm);
|
||||
SetProxyForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void listView1_ColumnClick(object sender, ColumnClickEventArgs e)
|
||||
{
|
||||
// Determine if clicked column is already the column that is being sorted.
|
||||
if (e.Column == lvwColumnSorter.SortColumn)
|
||||
{
|
||||
// Reverse the current sort direction for this column.
|
||||
if (lvwColumnSorter.Order == SortOrder.Ascending)
|
||||
{
|
||||
lvwColumnSorter.Order = SortOrder.Descending;
|
||||
}
|
||||
else
|
||||
{
|
||||
lvwColumnSorter.Order = SortOrder.Ascending;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the column number that is to be sorted; default to ascending.
|
||||
lvwColumnSorter.SortColumn = e.Column;
|
||||
lvwColumnSorter.Order = SortOrder.Ascending;
|
||||
}
|
||||
|
||||
// Perform the sort with these new sort options.
|
||||
listViewProxies.Sort();
|
||||
}
|
||||
|
||||
private void listViewProxies_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (sender is ListView)
|
||||
{
|
||||
if (e.KeyCode == Keys.Delete) DeleteSelectedProxies();
|
||||
}
|
||||
}
|
||||
|
||||
private void listViewProxies_ColumnWidthChanged(object sender, ColumnWidthChangedEventArgs e)
|
||||
{
|
||||
if (AppConfig is not null && sender is ListView listView)
|
||||
{
|
||||
AppConfig.PortProxyColumnWidths[e.ColumnIndex] = listView.Columns[e.ColumnIndex].Width;
|
||||
}
|
||||
}
|
||||
|
||||
private void PortProxyGUI_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
Program.Database.SaveAppConfig(AppConfig);
|
||||
}
|
||||
|
||||
private void PortProxyGUI_Resize(object sender, EventArgs e)
|
||||
{
|
||||
if (AppConfig is not null && sender is Form form)
|
||||
{
|
||||
AppConfig.MainWindowSize = form.Size;
|
||||
}
|
||||
}
|
||||
|
||||
private void toolStripMenuItem_Export_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = saveFileDialog_Export;
|
||||
|
||||
var result = dialog.ShowDialog();
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
var fileName = dialog.FileName;
|
||||
File.Copy(ApplicationDbScope.AppDbFile, fileName, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void toolStripMenuItem_Import_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = openFileDialog_Import;
|
||||
|
||||
var result = dialog.ShowDialog();
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
var fileName = dialog.FileName;
|
||||
using (var scope = ApplicationDbScope.FromFile(fileName))
|
||||
{
|
||||
foreach (var rule in scope.Rules)
|
||||
{
|
||||
var exsist = Program.Database.GetRule(rule.Type, rule.ListenOn, rule.ListenPort);
|
||||
if (exsist is null)
|
||||
{
|
||||
rule.Id = Guid.NewGuid().ToString();
|
||||
Program.Database.Add(rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RefreshProxyList();
|
||||
}
|
||||
}
|
||||
|
||||
private void toolStripMenuItem_ResetWindowSize_Click(object sender, EventArgs e)
|
||||
{
|
||||
AppConfig = new AppConfig();
|
||||
ResetWindowSize();
|
||||
}
|
||||
|
||||
private void toolStripStatusLabel_ServiceNotRunning_Click(object sender, EventArgs e)
|
||||
{
|
||||
Util.StartService();
|
||||
toolStripStatusLabel_ServiceNotRunning.Visible = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFrameworks>net8.0-windows;net6.0-windows;net35;net451</TargetFrameworks>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<Authors>zmjack</Authors>
|
||||
|
@ -14,11 +14,21 @@
|
|||
<PackageTags>portproxy TCP/IP redirector</PackageTags>
|
||||
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
|
||||
<Copyright>Copyright © nstandard.net 2020</Copyright>
|
||||
<Version>1.4.2</Version>
|
||||
<ApplicationIcon>icon.ico</ApplicationIcon>
|
||||
<ApplicationDefaultFont>Arial, 8.25pt</ApplicationDefaultFont>
|
||||
<AssemblyName>PPGUI</AssemblyName>
|
||||
<LangVersion>preview</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DebugType>none</DebugType>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -29,38 +39,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="About.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="About.Designer.cs">
|
||||
<DependentUpon>About.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="NewProxy.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="NewProxy.Designer.cs">
|
||||
<DependentUpon>NewProxy.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="PortProxyGUI.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="PortProxyGUI.Designer.cs">
|
||||
<DependentUpon>PortProxyGUI.cs</DependentUpon>
|
||||
</Compile>
|
||||
<PackageReference Include="SQLib.Sqlite" Version="0.11.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="About.resx">
|
||||
<DependentUpon>About.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="NewProxy.resx">
|
||||
<DependentUpon>NewProxy.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="PortProxyGUI.resx">
|
||||
<DependentUpon>PortProxyGUI.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\PortProxyGUI.Shared\PortProxyGUI.Shared.projitems" Label="Shared" />
|
||||
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,20 +1,50 @@
|
|||
using PortProxyGUI.Data;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PortProxyGUI
|
||||
namespace PortProxyGUI;
|
||||
|
||||
static class Program
|
||||
{
|
||||
static class Program
|
||||
private static string GetPath(params string[] pathes)
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new PortProxyGUI());
|
||||
}
|
||||
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>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
ApplicationConfiguration.Initialize();
|
||||
#elif NETCOREAPP3_1_OR_GREATER
|
||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
#else
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
#endif
|
||||
|
||||
Application.Run(new PortProxyGUI());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,183 @@
|
|||
namespace PortProxyGUI;
|
||||
|
||||
partial class SetProxy
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SetProxy));
|
||||
this.label_ListenOn = new System.Windows.Forms.Label();
|
||||
this.textBox_ListenOn = new System.Windows.Forms.TextBox();
|
||||
this.label_ConnectTo = new System.Windows.Forms.Label();
|
||||
this.textBox_ConnectTo = new System.Windows.Forms.TextBox();
|
||||
this.textBox_ConnectPort = new System.Windows.Forms.TextBox();
|
||||
this.label_ConnectPort = new System.Windows.Forms.Label();
|
||||
this.button_Set = new System.Windows.Forms.Button();
|
||||
this.label_Type = new System.Windows.Forms.Label();
|
||||
this.label_ListenPort = new System.Windows.Forms.Label();
|
||||
this.textBox_ListenPort = new System.Windows.Forms.TextBox();
|
||||
this.comboBox_Type = new System.Windows.Forms.ComboBox();
|
||||
this.label_Comment = new System.Windows.Forms.Label();
|
||||
this.textBox_Comment = new System.Windows.Forms.TextBox();
|
||||
this.label_Group = new System.Windows.Forms.Label();
|
||||
this.comboBox_Group = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label_ListenOn
|
||||
//
|
||||
resources.ApplyResources(this.label_ListenOn, "label_ListenOn");
|
||||
this.label_ListenOn.Name = "label_ListenOn";
|
||||
//
|
||||
// textBox_ListenOn
|
||||
//
|
||||
resources.ApplyResources(this.textBox_ListenOn, "textBox_ListenOn");
|
||||
this.textBox_ListenOn.Name = "textBox_ListenOn";
|
||||
//
|
||||
// label_ConnectTo
|
||||
//
|
||||
resources.ApplyResources(this.label_ConnectTo, "label_ConnectTo");
|
||||
this.label_ConnectTo.Name = "label_ConnectTo";
|
||||
//
|
||||
// textBox_ConnectTo
|
||||
//
|
||||
resources.ApplyResources(this.textBox_ConnectTo, "textBox_ConnectTo");
|
||||
this.textBox_ConnectTo.Name = "textBox_ConnectTo";
|
||||
//
|
||||
// textBox_ConnectPort
|
||||
//
|
||||
resources.ApplyResources(this.textBox_ConnectPort, "textBox_ConnectPort");
|
||||
this.textBox_ConnectPort.Name = "textBox_ConnectPort";
|
||||
//
|
||||
// label_ConnectPort
|
||||
//
|
||||
resources.ApplyResources(this.label_ConnectPort, "label_ConnectPort");
|
||||
this.label_ConnectPort.Name = "label_ConnectPort";
|
||||
//
|
||||
// button_Set
|
||||
//
|
||||
resources.ApplyResources(this.button_Set, "button_Set");
|
||||
this.button_Set.Name = "button_Set";
|
||||
this.button_Set.UseVisualStyleBackColor = true;
|
||||
this.button_Set.Click += new System.EventHandler(this.button_Set_Click);
|
||||
//
|
||||
// label_Type
|
||||
//
|
||||
resources.ApplyResources(this.label_Type, "label_Type");
|
||||
this.label_Type.Name = "label_Type";
|
||||
//
|
||||
// label_ListenPort
|
||||
//
|
||||
resources.ApplyResources(this.label_ListenPort, "label_ListenPort");
|
||||
this.label_ListenPort.Name = "label_ListenPort";
|
||||
//
|
||||
// textBox_ListenPort
|
||||
//
|
||||
resources.ApplyResources(this.textBox_ListenPort, "textBox_ListenPort");
|
||||
this.textBox_ListenPort.Name = "textBox_ListenPort";
|
||||
//
|
||||
// comboBox_Type
|
||||
//
|
||||
resources.ApplyResources(this.comboBox_Type, "comboBox_Type");
|
||||
this.comboBox_Type.FormattingEnabled = true;
|
||||
this.comboBox_Type.Items.AddRange(new object[] {
|
||||
resources.GetString("comboBox_Type.Items"),
|
||||
resources.GetString("comboBox_Type.Items1"),
|
||||
resources.GetString("comboBox_Type.Items2"),
|
||||
resources.GetString("comboBox_Type.Items3"),
|
||||
resources.GetString("comboBox_Type.Items4")});
|
||||
this.comboBox_Type.Name = "comboBox_Type";
|
||||
//
|
||||
// label_Comment
|
||||
//
|
||||
resources.ApplyResources(this.label_Comment, "label_Comment");
|
||||
this.label_Comment.Name = "label_Comment";
|
||||
//
|
||||
// textBox_Comment
|
||||
//
|
||||
resources.ApplyResources(this.textBox_Comment, "textBox_Comment");
|
||||
this.textBox_Comment.Name = "textBox_Comment";
|
||||
//
|
||||
// label_Group
|
||||
//
|
||||
resources.ApplyResources(this.label_Group, "label_Group");
|
||||
this.label_Group.Name = "label_Group";
|
||||
//
|
||||
// comboBox_Group
|
||||
//
|
||||
resources.ApplyResources(this.comboBox_Group, "comboBox_Group");
|
||||
this.comboBox_Group.FormattingEnabled = true;
|
||||
this.comboBox_Group.Name = "comboBox_Group";
|
||||
//
|
||||
// SetProxy
|
||||
//
|
||||
this.AcceptButton = this.button_Set;
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.comboBox_Group);
|
||||
this.Controls.Add(this.label_Group);
|
||||
this.Controls.Add(this.textBox_Comment);
|
||||
this.Controls.Add(this.label_Comment);
|
||||
this.Controls.Add(this.comboBox_Type);
|
||||
this.Controls.Add(this.textBox_ListenPort);
|
||||
this.Controls.Add(this.label_ListenPort);
|
||||
this.Controls.Add(this.label_Type);
|
||||
this.Controls.Add(this.button_Set);
|
||||
this.Controls.Add(this.label_ConnectPort);
|
||||
this.Controls.Add(this.textBox_ConnectPort);
|
||||
this.Controls.Add(this.textBox_ConnectTo);
|
||||
this.Controls.Add(this.label_ConnectTo);
|
||||
this.Controls.Add(this.textBox_ListenOn);
|
||||
this.Controls.Add(this.label_ListenOn);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "SetProxy";
|
||||
this.TopMost = true;
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SetProxyForm_FormClosing);
|
||||
this.Load += new System.EventHandler(this.SetProxyForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label_ListenOn;
|
||||
private System.Windows.Forms.TextBox textBox_ListenOn;
|
||||
private System.Windows.Forms.Label label_ConnectTo;
|
||||
private System.Windows.Forms.TextBox textBox_ConnectTo;
|
||||
private System.Windows.Forms.TextBox textBox_ConnectPort;
|
||||
private System.Windows.Forms.Label label_ConnectPort;
|
||||
private System.Windows.Forms.Button button_Set;
|
||||
private System.Windows.Forms.Label label_Type;
|
||||
private System.Windows.Forms.Label label_ListenPort;
|
||||
private System.Windows.Forms.TextBox textBox_ListenPort;
|
||||
private System.Windows.Forms.ComboBox comboBox_Type;
|
||||
private System.Windows.Forms.Label label_Comment;
|
||||
private System.Windows.Forms.TextBox textBox_Comment;
|
||||
private System.Windows.Forms.Label label_Group;
|
||||
private System.Windows.Forms.ComboBox comboBox_Group;
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
using NStandard;
|
||||
using PortProxyGUI.Data;
|
||||
using PortProxyGUI.Utils;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PortProxyGUI;
|
||||
|
||||
public partial class SetProxy : Form
|
||||
{
|
||||
public readonly PortProxyGUI ParentWindow;
|
||||
private string AutoTypeString { get; }
|
||||
|
||||
private bool _updateMode;
|
||||
private ListViewItem _listViewItem;
|
||||
private Rule _itemRule;
|
||||
|
||||
public SetProxy(PortProxyGUI parent)
|
||||
{
|
||||
ParentWindow = parent;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
AutoTypeString = comboBox_Type.Text = comboBox_Type.Items.OfType<string>().First();
|
||||
var groupNames = (
|
||||
from g in parent.listViewProxies.Groups.OfType<ListViewGroup>()
|
||||
let header = g.Header
|
||||
where !header.IsNullOrWhiteSpace()
|
||||
select header
|
||||
).ToArray();
|
||||
comboBox_Group.Items.AddRange(groupNames);
|
||||
}
|
||||
|
||||
public void UseNormalMode()
|
||||
{
|
||||
_updateMode = false;
|
||||
_listViewItem = null;
|
||||
_itemRule = null;
|
||||
|
||||
comboBox_Type.Text = AutoTypeString;
|
||||
comboBox_Group.Text = "";
|
||||
|
||||
textBox_ListenOn.Text = "*";
|
||||
textBox_ListenPort.Text = "";
|
||||
textBox_ConnectTo.Text = "";
|
||||
textBox_ConnectPort.Text = "";
|
||||
textBox_Comment.Text = "";
|
||||
}
|
||||
|
||||
public void UseUpdateMode(ListViewItem item, Rule rule)
|
||||
{
|
||||
_updateMode = true;
|
||||
_listViewItem = item;
|
||||
|
||||
_itemRule = rule;
|
||||
|
||||
comboBox_Type.Text = rule.Type;
|
||||
comboBox_Group.Text = rule.Group;
|
||||
|
||||
textBox_ListenOn.Text = rule.ListenOn;
|
||||
textBox_ListenPort.Text = rule.ListenPort.ToString();
|
||||
textBox_ConnectTo.Text = rule.ConnectTo;
|
||||
textBox_ConnectPort.Text = rule.ConnectPort.ToString();
|
||||
textBox_Comment.Text = rule.Comment;
|
||||
}
|
||||
|
||||
private bool IsIPv6(string ip)
|
||||
{
|
||||
return ip.IsMatch(new Regex(@"^[\dABCDEF]{2}(?::(?:[\dABCDEF]{2})){5}$"));
|
||||
}
|
||||
|
||||
private string GetPassType(string listenOn, string connectTo)
|
||||
{
|
||||
var from = IsIPv6(listenOn) ? "v6" : "v4";
|
||||
var to = IsIPv6(connectTo) ? "v6" : "v4";
|
||||
return $"{from}to{to}";
|
||||
}
|
||||
|
||||
private void button_Set_Click(object sender, EventArgs e)
|
||||
{
|
||||
int listenPort, connectPort;
|
||||
|
||||
try
|
||||
{
|
||||
listenPort = Rule.ParsePort(textBox_ListenPort.Text);
|
||||
connectPort = Rule.ParsePort(textBox_ConnectPort.Text);
|
||||
}
|
||||
catch (NotSupportedException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Invalid port", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
var rule = new Rule
|
||||
{
|
||||
Type = comboBox_Type.Text.Trim(),
|
||||
ListenOn = textBox_ListenOn.Text.Trim(),
|
||||
ListenPort = listenPort,
|
||||
ConnectTo = textBox_ConnectTo.Text.Trim(),
|
||||
ConnectPort = connectPort,
|
||||
Comment = textBox_Comment.Text.Trim(),
|
||||
Group = comboBox_Group.Text.Trim(),
|
||||
};
|
||||
|
||||
if (rule.Type == AutoTypeString) rule.Type = GetPassType(rule.ListenOn, rule.ConnectTo);
|
||||
|
||||
if (!new[] { "v4tov4", "v4tov6", "v6tov4", "v6tov6" }.Contains(rule.Type))
|
||||
{
|
||||
MessageBox.Show($"Unknow type for ({rule.ListenOn} -> {rule.ConnectTo}).", "Exclamation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_updateMode)
|
||||
{
|
||||
var oldRule = Program.Database.GetRule(_itemRule.Type, _itemRule.ListenOn, _itemRule.ListenPort);
|
||||
Util.DeleteProxy(oldRule);
|
||||
Program.Database.Remove(oldRule);
|
||||
|
||||
Util.AddOrUpdateProxy(rule);
|
||||
Program.Database.Add(rule);
|
||||
|
||||
ParentWindow.UpdateListViewItem(_listViewItem, rule, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Util.AddOrUpdateProxy(rule);
|
||||
Program.Database.Add(rule);
|
||||
|
||||
ParentWindow.RefreshProxyList();
|
||||
}
|
||||
Util.ParamChange();
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
private void SetProxyForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
Top = ParentWindow.Top + (ParentWindow.Height - Height) / 2;
|
||||
Left = ParentWindow.Left + (ParentWindow.Width - Width) / 2;
|
||||
}
|
||||
|
||||
private void SetProxyForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
ParentWindow.SetProxyForm = null;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,110 @@
|
|||
using System.Collections;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PortProxyGUI.UI;
|
||||
|
||||
public class ListViewColumnSorter : IComparer
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the column to be sorted
|
||||
/// </summary>
|
||||
private int ColumnToSort;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the order in which to sort (i.e. 'Ascending').
|
||||
/// </summary>
|
||||
private SortOrder OrderOfSort;
|
||||
|
||||
/// <summary>
|
||||
/// Case insensitive comparer object
|
||||
/// </summary>
|
||||
private CaseInsensitiveComparer ObjectCompare;
|
||||
|
||||
/// <summary>
|
||||
/// Class constructor. Initializes various elements
|
||||
/// </summary>
|
||||
public ListViewColumnSorter()
|
||||
{
|
||||
// Initialize the column to '0'
|
||||
ColumnToSort = 0;
|
||||
|
||||
// Initialize the sort order to 'none'
|
||||
OrderOfSort = SortOrder.None;
|
||||
|
||||
// Initialize the CaseInsensitiveComparer object
|
||||
ObjectCompare = new CaseInsensitiveComparer();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is inherited from the IComparer interface. It compares the two objects passed using a case insensitive comparison.
|
||||
/// </summary>
|
||||
/// <param name="x">First object to be compared</param>
|
||||
/// <param name="y">Second object to be compared</param>
|
||||
/// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
|
||||
public int Compare(object x, object y)
|
||||
{
|
||||
int compareResult;
|
||||
ListViewItem listviewX, listviewY;
|
||||
|
||||
// Cast the objects to be compared to ListViewItem objects
|
||||
listviewX = (ListViewItem)x;
|
||||
listviewY = (ListViewItem)y;
|
||||
|
||||
// Compare the two items
|
||||
if (listviewX.SubItems[ColumnToSort].Tag?.ToString() == "Number" && listviewY.SubItems[ColumnToSort].Tag?.ToString() == "Number")
|
||||
{
|
||||
int.TryParse(listviewX.SubItems[ColumnToSort].Text, out var xint);
|
||||
int.TryParse(listviewY.SubItems[ColumnToSort].Text, out var yint);
|
||||
compareResult = ObjectCompare.Compare(xint, yint);
|
||||
}
|
||||
else compareResult = ObjectCompare.Compare(listviewX.SubItems[ColumnToSort].Text, listviewY.SubItems[ColumnToSort].Text);
|
||||
|
||||
// Calculate correct return value based on object comparison
|
||||
if (OrderOfSort == SortOrder.Ascending)
|
||||
{
|
||||
// Ascending sort is selected, return normal result of compare operation
|
||||
return compareResult;
|
||||
}
|
||||
else if (OrderOfSort == SortOrder.Descending)
|
||||
{
|
||||
// Descending sort is selected, return negative result of compare operation
|
||||
return -compareResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Return '0' to indicate they are equal
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of the column to which to apply the sorting operation (Defaults to '0').
|
||||
/// </summary>
|
||||
public int SortColumn
|
||||
{
|
||||
set
|
||||
{
|
||||
ColumnToSort = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
return ColumnToSort;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the order of sorting to apply (for example, 'Ascending' or 'Descending').
|
||||
/// </summary>
|
||||
public SortOrder Order
|
||||
{
|
||||
set
|
||||
{
|
||||
OrderOfSort = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
return OrderOfSort;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
using PortProxyGUI.Native;
|
||||
using System;
|
||||
|
||||
namespace PortProxyGUI.Utils;
|
||||
|
||||
internal class DnsUtil
|
||||
{
|
||||
public static void FlushCache()
|
||||
{
|
||||
var status = NativeMethods.DnsFlushResolverCache();
|
||||
if (status == 0) throw new InvalidOperationException("Flush DNS Cache failed.");
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 126 KiB |
|
@ -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
|
|
@ -0,0 +1,76 @@
|
|||
# PortProxyGUI
|
||||
|
||||
A manager for netsh interface portproxy, which is to evaluate TCP/IP port redirect on windows.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> The software does not configure the firewall.
|
||||
>
|
||||
> If necessary, manually configure the firewall.
|
||||
|
||||
<br/>
|
||||
|
||||
## Runtimes
|
||||
|
||||
### .NET
|
||||
|
||||
| Target framework | Link |
|
||||
| ------------------------------------------------------------ | ------------------------------------------------------------ |
|
||||
|  | [Download .NET 8.0](https://dotnet.microsoft.com/download/dotnet/8.0) |
|
||||
|  | [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 |
|
||||
| ------------------------------------------------------------ | -------------------------- | --------------------------------- | ------------------------------------------------------------ |
|
||||
|  | ✔️ **8.1 +**<br />➕ Vista + | ✔️ **2012 R2 +**<br />➕ 2008 SP2 + | [Download](https://dotnet.microsoft.com/download/dotnet-framework/net451) |
|
||||
|  | ✔️ **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
|
||||
|
||||
- **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**
|
||||
- Command line calls have been removed to provide better performance.
|
||||
- New Feature Added: **Remember Window/Column Size**.
|
||||
- New Feature Added: **Flush DNS Cache**.
|
||||
- New Feature Added: **Support import and export configuration database**.
|
||||
- **v1.3.1 - v1.3.2**
|
||||
- Fix program crash caused by wrong rules.
|
||||
- **v1.3.0**
|
||||
- Update display, provide comments and grouping.
|
||||
- Fix the problem that the window size is not the same in different runtimes.
|
||||
|
||||
<br/>
|
||||
|
||||
## Information
|
||||
|
||||
The configuration file will be generated at:
|
||||
|
||||
```
|
||||
[MyDocuments]\PortProxyGUI\config.db
|
||||
```
|
||||
|
||||
The configuration database will be migrated **automatically** if the newer version software is used.
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
Binary file not shown.
After Width: | Height: | Size: 348 B |
Binary file not shown.
After Width: | Height: | Size: 290 B |
Loading…
Reference in New Issue