diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c9ef429 --- /dev/null +++ b/.gitignore @@ -0,0 +1,262 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc +/Forwarder/res/Thumbs.db diff --git a/Forwarder/Forwarder.sln b/Forwarder/Forwarder.sln new file mode 100644 index 0000000..6192cfc --- /dev/null +++ b/Forwarder/Forwarder.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.9 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Forwarder", "Forwarder\Forwarder.csproj", "{F6FF0173-BA2C-43BA-8A42-7961810DA2C2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F6FF0173-BA2C-43BA-8A42-7961810DA2C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6FF0173-BA2C-43BA-8A42-7961810DA2C2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6FF0173-BA2C-43BA-8A42-7961810DA2C2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6FF0173-BA2C-43BA-8A42-7961810DA2C2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Forwarder/Forwarder/App.config b/Forwarder/Forwarder/App.config new file mode 100644 index 0000000..d1428ad --- /dev/null +++ b/Forwarder/Forwarder/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/Forwarder/Forwarder/Extension.cs b/Forwarder/Forwarder/Extension.cs new file mode 100644 index 0000000..514f4e3 --- /dev/null +++ b/Forwarder/Forwarder/Extension.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Sockets; +using System.Text; +using System.Threading.Tasks; + +namespace Forwarder +{ + static class SocketExtensions + { + public static bool IsConnected(this Socket socket) + { + try + { + return !(socket.Poll(1, SelectMode.SelectRead) && socket.Available == 0); + } + catch (SocketException) { return false; } + } + } +} diff --git a/Forwarder/Forwarder/FAbout.Designer.cs b/Forwarder/Forwarder/FAbout.Designer.cs new file mode 100644 index 0000000..140b363 --- /dev/null +++ b/Forwarder/Forwarder/FAbout.Designer.cs @@ -0,0 +1,137 @@ +namespace Forwarder +{ + partial class FAbout + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FAbout)); + this.lbTitle = new System.Windows.Forms.Label(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.lbText = new System.Windows.Forms.Label(); + this.llbAuthor = new System.Windows.Forms.LinkLabel(); + this.btOk = new System.Windows.Forms.Button(); + this.lbVer = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // lbTitle + // + this.lbTitle.AutoSize = true; + this.lbTitle.Font = new System.Drawing.Font("Lucida Sans Unicode", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbTitle.Location = new System.Drawing.Point(66, 12); + this.lbTitle.Name = "lbTitle"; + this.lbTitle.Size = new System.Drawing.Size(183, 28); + this.lbTitle.TabIndex = 0; + this.lbTitle.Text = "TCP Forwarder"; + // + // pictureBox1 + // + this.pictureBox1.Image = global::Forwarder.Properties.Resources.TcpForwarder; + this.pictureBox1.Location = new System.Drawing.Point(12, 12); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(48, 48); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.pictureBox1.TabIndex = 1; + this.pictureBox1.TabStop = false; + // + // lbText + // + this.lbText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lbText.Location = new System.Drawing.Point(12, 74); + this.lbText.Name = "lbText"; + this.lbText.Size = new System.Drawing.Size(270, 207); + this.lbText.TabIndex = 2; + this.lbText.Text = resources.GetString("lbText.Text"); + // + // llbAuthor + // + this.llbAuthor.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.llbAuthor.AutoSize = true; + this.llbAuthor.Location = new System.Drawing.Point(172, 47); + this.llbAuthor.Name = "llbAuthor"; + this.llbAuthor.Size = new System.Drawing.Size(90, 13); + this.llbAuthor.TabIndex = 3; + this.llbAuthor.TabStop = true; + this.llbAuthor.Text = "by XWolfOverride"; + this.llbAuthor.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llbAuthor_LinkClicked); + // + // btOk + // + this.btOk.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.btOk.Location = new System.Drawing.Point(288, 12); + this.btOk.Name = "btOk"; + this.btOk.Size = new System.Drawing.Size(33, 269); + this.btOk.TabIndex = 4; + this.btOk.Text = "Ok"; + this.btOk.UseVisualStyleBackColor = true; + this.btOk.Click += new System.EventHandler(this.btOk_Click); + // + // lbVer + // + this.lbVer.AutoSize = true; + this.lbVer.Location = new System.Drawing.Point(240, 27); + this.lbVer.Name = "lbVer"; + this.lbVer.Size = new System.Drawing.Size(22, 13); + this.lbVer.TabIndex = 5; + this.lbVer.Text = "1.0"; + // + // FAbout + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(330, 293); + this.Controls.Add(this.lbVer); + this.Controls.Add(this.btOk); + this.Controls.Add(this.llbAuthor); + this.Controls.Add(this.lbText); + this.Controls.Add(this.pictureBox1); + this.Controls.Add(this.lbTitle); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "FAbout"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "About TCP Forwarder"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lbTitle; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.Label lbText; + private System.Windows.Forms.LinkLabel llbAuthor; + private System.Windows.Forms.Button btOk; + private System.Windows.Forms.Label lbVer; + } +} \ No newline at end of file diff --git a/Forwarder/Forwarder/FAbout.cs b/Forwarder/Forwarder/FAbout.cs new file mode 100644 index 0000000..c37289c --- /dev/null +++ b/Forwarder/Forwarder/FAbout.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Forwarder +{ + public partial class FAbout : Form + { + private FAbout() + { + InitializeComponent(); + } + + public static void Execute() + { + using (FAbout f = new FAbout()) + { + f.ShowDialog(); + } + } + + private void llbAuthor_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + Process.Start("https://xwolf.es/2018/02/171/"); + } + + private void btOk_Click(object sender, EventArgs e) + { + Close(); + } + } +} diff --git a/Forwarder/Forwarder/FAbout.resx b/Forwarder/Forwarder/FAbout.resx new file mode 100644 index 0000000..04f6314 --- /dev/null +++ b/Forwarder/Forwarder/FAbout.resx @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + TCP Forwarder is a small tool written on C# that allows some basic TCP forwarding (tunneling). +Adittionaly this application show a list of current connections and transfered bytes. + +At current version TCPForwarder does not treat information in any way, only redirects it and show information. Future advanced information management is planned. + +TCP Forwarder is distributed under terms of zlib license. + +All icons comes from Farm-Fresh icon set (C)TwoCows or modifications of this icon set. + + \ No newline at end of file diff --git a/Forwarder/Forwarder/Form1.Designer.cs b/Forwarder/Forwarder/Form1.Designer.cs new file mode 100644 index 0000000..77c62e5 --- /dev/null +++ b/Forwarder/Forwarder/Form1.Designer.cs @@ -0,0 +1,170 @@ +namespace Forwarder +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); + this.panel1 = new System.Windows.Forms.Panel(); + this.lbForwarders = new System.Windows.Forms.ListBox(); + this.panel2 = new System.Windows.Forms.Panel(); + this.splitter1 = new System.Windows.Forms.Splitter(); + this.pFord = new System.Windows.Forms.Panel(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.btAbout = new System.Windows.Forms.Button(); + this.btDel = new System.Windows.Forms.Button(); + this.btAdd = new System.Windows.Forms.Button(); + this.panel1.SuspendLayout(); + this.panel2.SuspendLayout(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Controls.Add(this.lbForwarders); + this.panel1.Controls.Add(this.panel2); + this.panel1.Dock = System.Windows.Forms.DockStyle.Left; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Margin = new System.Windows.Forms.Padding(5); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(200, 372); + this.panel1.TabIndex = 2; + // + // lbForwarders + // + this.lbForwarders.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbForwarders.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; + this.lbForwarders.FormattingEnabled = true; + this.lbForwarders.IntegralHeight = false; + this.lbForwarders.ItemHeight = 40; + this.lbForwarders.Location = new System.Drawing.Point(0, 0); + this.lbForwarders.Name = "lbForwarders"; + this.lbForwarders.Size = new System.Drawing.Size(200, 335); + this.lbForwarders.TabIndex = 1; + this.lbForwarders.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lbForwarders_DrawItem); + this.lbForwarders.SelectedIndexChanged += new System.EventHandler(this.lbForwarders_SelectedIndexChanged); + // + // panel2 + // + this.panel2.Controls.Add(this.btAbout); + this.panel2.Controls.Add(this.btDel); + this.panel2.Controls.Add(this.btAdd); + this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel2.Location = new System.Drawing.Point(0, 335); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(200, 37); + this.panel2.TabIndex = 2; + // + // splitter1 + // + this.splitter1.Location = new System.Drawing.Point(200, 0); + this.splitter1.Name = "splitter1"; + this.splitter1.Size = new System.Drawing.Size(3, 372); + this.splitter1.TabIndex = 3; + this.splitter1.TabStop = false; + // + // pFord + // + this.pFord.Dock = System.Windows.Forms.DockStyle.Fill; + this.pFord.Location = new System.Drawing.Point(203, 0); + this.pFord.MinimumSize = new System.Drawing.Size(300, 0); + this.pFord.Name = "pFord"; + this.pFord.Size = new System.Drawing.Size(501, 372); + this.pFord.TabIndex = 4; + // + // btAbout + // + this.btAbout.Image = global::Forwarder.Properties.Resources.help; + this.btAbout.Location = new System.Drawing.Point(3, 6); + this.btAbout.Name = "btAbout"; + this.btAbout.Size = new System.Drawing.Size(26, 26); + this.btAbout.TabIndex = 2; + this.toolTip1.SetToolTip(this.btAbout, "About TCP Forwarder"); + this.btAbout.UseVisualStyleBackColor = true; + this.btAbout.Click += new System.EventHandler(this.btAbout_Click); + // + // btDel + // + this.btDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btDel.Image = global::Forwarder.Properties.Resources.world_delete; + this.btDel.Location = new System.Drawing.Point(132, 6); + this.btDel.Name = "btDel"; + this.btDel.Size = new System.Drawing.Size(68, 26); + this.btDel.TabIndex = 1; + this.btDel.Text = "Delete"; + this.btDel.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.toolTip1.SetToolTip(this.btDel, "Delete selected forwarder"); + this.btDel.UseVisualStyleBackColor = true; + this.btDel.Click += new System.EventHandler(this.btDel_Click); + // + // btAdd + // + this.btAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btAdd.Image = global::Forwarder.Properties.Resources.world_add; + this.btAdd.Location = new System.Drawing.Point(61, 6); + this.btAdd.Name = "btAdd"; + this.btAdd.Size = new System.Drawing.Size(65, 26); + this.btAdd.TabIndex = 0; + this.btAdd.Text = "Add"; + this.btAdd.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.toolTip1.SetToolTip(this.btAdd, "Add a forwarder"); + this.btAdd.UseVisualStyleBackColor = true; + this.btAdd.Click += new System.EventHandler(this.btAdd_Click); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(704, 372); + this.Controls.Add(this.pFord); + this.Controls.Add(this.splitter1); + this.Controls.Add(this.panel1); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MinimumSize = new System.Drawing.Size(650, 200); + this.Name = "Form1"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "TCP Forwarder"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed); + this.panel1.ResumeLayout(false); + this.panel2.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Button btAdd; + private System.Windows.Forms.Splitter splitter1; + private System.Windows.Forms.ListBox lbForwarders; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.Panel pFord; + private System.Windows.Forms.Button btDel; + public System.Windows.Forms.ToolTip toolTip1; + private System.Windows.Forms.Button btAbout; + } +} + diff --git a/Forwarder/Forwarder/Form1.cs b/Forwarder/Forwarder/Form1.cs new file mode 100644 index 0000000..34e3c1b --- /dev/null +++ b/Forwarder/Forwarder/Form1.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Forwarder +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + btAdd_Click(null, null); + LookupUI(); + } + + private void LookupUI() + { + btDel.Enabled = lbForwarders.SelectedItem != null; + } + + private void ForwarderChagned() + { + lbForwarders.Invalidate(); + } + + private void button2_Click(object sender, EventArgs e) + { + Forwarder fw = new Forwarder(); + fw.SetLocal("0.0.0.0", "8088"); + fw.SetRemote("tmed01.dlab.siemens.lab", "8000"); + fw.Activate(); + } + + private void btAdd_Click(object sender, EventArgs e) + { + ForwarderControl fc = new ForwarderControl(); + fc.WhenChanged = ForwarderChagned; + lbForwarders.SelectedIndex = lbForwarders.Items.Add(fc); + } + + private void lbForwarders_SelectedIndexChanged(object sender, EventArgs e) + { + LookupUI(); + ForwarderControl fc = lbForwarders.SelectedItem as ForwarderControl; + if (fc == null) + return; + pFord.Controls.Clear(); + pFord.Controls.Add(fc); + fc.Dock = DockStyle.Fill; + } + + private void btDel_Click(object sender, EventArgs e) + { + ForwarderControl fc = lbForwarders.SelectedItem as ForwarderControl; + if (fc == null) + return; + fc.StopForwarder(); + lbForwarders.Items.Remove(fc); + fc.Dispose(); + LookupUI(); + } + + private void lbForwarders_DrawItem(object sender, DrawItemEventArgs e) + { + e.DrawBackground(); + if (e.Index >= 0 && e.Index < lbForwarders.Items.Count) + { + ForwarderControl fc = lbForwarders.Items[e.Index] as ForwarderControl; + if (fc != null) + { + e.Graphics.DrawImage(Properties.Resources.world, 2, e.Bounds.Top + 2); + e.Graphics.DrawImage(fc.Active ? Properties.Resources.link_go : Properties.Resources.cross, 8, e.Bounds.Top + 6); + if (fc.SourceLocal) + e.Graphics.DrawImage(Properties.Resources.computer, e.Bounds.Right - 18, e.Bounds.Top + 2); + Brush br = new SolidBrush(e.ForeColor); + e.Graphics.DrawString(fc.SourcePort, lbForwarders.Font, br, 36, e.Bounds.Top + 2); + e.Graphics.DrawString(fc.DestinationHost, lbForwarders.Font, br, 40, e.Bounds.Top + 20); + e.Graphics.DrawString(fc.DestinationPort, lbForwarders.Font, br, e.Bounds.Right - (2 + e.Graphics.MeasureString(fc.DestinationPort, lbForwarders.Font).Width), e.Bounds.Top + 20); + } + } + e.DrawFocusRectangle(); + } + + private void Form1_FormClosed(object sender, FormClosedEventArgs e) + { + while (lbForwarders.Items.Count>0) + { + lbForwarders.SelectedIndex = 0; + btDel_Click(sender, e); + } + } + + private void btAbout_Click(object sender, EventArgs e) + { + FAbout.Execute(); + } + } +} diff --git a/Forwarder/Forwarder/Form1.resx b/Forwarder/Forwarder/Form1.resx new file mode 100644 index 0000000..25ba22f --- /dev/null +++ b/Forwarder/Forwarder/Form1.resx @@ -0,0 +1,380 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + + AAABAAMAEBAAAAEAIABoBAAANgAAACAgAAABACAAqBAAAJ4EAAAwMAAAAQAgAKglAABGFQAAKAAAABAA + AAAgAAAAAQAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJS6WnSWdlp0lmpad + JZqWnSWakZcjnJadJZqWnSWalp0lmpGYG5qFjQKVk5whPAAAAAAAAAAAAAAAAAAAAACWnSVjlp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5CYGf/f4r7//////7i8a/+TnCE8AAAAAAAAAAAAAAAAlp0lYpad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+yt2D/////////////////hY0ClQAAAAAAAAAAAAAAAJad + JWKWnSX/lp0l/5adJf+WnSX/lp0l/5SbIP+qsE//8/Tm////////////3+K+/5GYG5oAAAAOAAAAIgAA + ACJrcBp3gogg/4KIIP+CiCD/gIYf/3uBFv+usHz/3d3d/9TVy/+Vmk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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACWnSURlp0lNpad + JTSWnSU0lp0lNJadJTSWnSU0lp0lNJadJTSWnSU0cXYbQZadJTSWnSU0lp0lNJadJTSWnSU0lp0lNJad + JTSWnSU0lp0lM5adJSWWnSUGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJad + JbiWnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5OaHv+Plxf/kZga95WdJNiWnSUzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAlp0ly5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5WcJP+fpjn/1Nen///////n6c7/rrNX/5adJf+WnSUzAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAACWnSXLlp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lZwk//r69f//////////////////////rrNX/5WdJNiWnSUGAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJcuWnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5SbIv/KzpP////////////////////////////n6c7/kZga95ad + JSUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlp0ly5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/k5oe/+Xmyf////////////////////////////// + //+Plxf/lp0lMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACWnSXLlp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lZwk/5mgLP/CxoD//Pz4//////////////////// + ////////1Nen/5OaHv+WnSU0AAAABAAAAA4AAAAVAAAAFgAAABYAAAAWAAAAFoaMIc+JjyH/iY8h/4mP + If+JjyH/iY8h/4mPIf+JjyH/iY8h/4mPIf+JjyH/iY8h/4eNHf+YnkL/09S9/+np6f/p6en/6enp/+np + 6f/p6en/6enp/+Tk3/+RmDT/jpQj/4uRIjcAAAAOAAAALQAAAEAAAABDAAAAQwAAAEMAAABDZ2wZ2W5z + G/9ucxv/bnMb/25zG/9ucxv/bnMb/2twGv9rcBr/a3Aa/2twGf9ucxz/iYxS/7m5t/+8vLz/vLy8/7y8 + vP+mqI//jI9Z/6ipk/+Ul2z/bXMa/3B1G/98gh7/dnwdPgAAABWioqLUqqqq/6ioqP+oqKj/qKio/6io + qP+oqKj/qKio/6ioqP+oqKj/qKio/6moqP+qqaj/q6qq/6uqqv+rqqr/ra2t/6mpqf+oqKj/qKio/6io + qP+oqKj/qKio/6ioqP+oqKj/qKio/6ioqP+oqKj/qqqq/5qcgP9obRlFAAAAFqqqqv////////////// + //////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////qqqq/2ZrGUYAAAAWqamp//// + ///4+Pj/+Pj4//j4+P/5+fn/+fn5//j4+P/4+Pj/+Pj4//j4+P/5+fn/+fn5//j4+P/4+Pj/+Pj4//j4 + +P/5+fn/+fn5//j4+P/4+Pj/+Pj4//j4+P/5+fn/+fn5//j4+P/4+Pj/+Pj4//////+pqan/ZmsZRgAA + ABapqan//Pz8//Ly8f/y8/H/9/f2//39/P/9/fz/9/f2//Pz8f/z8/H/9/f2//39/P/9/fz/9/f2//Pz + 8f/z8/H/9/f2//39/P/9/fz/9/f2//Pz8f/z8/H/9/f2//39/P/9/fz/9/f2//Lz8f/y8vH//Pz8/6mp + qf9maxlGAAAAFqmpqf/6+vr/7ezs//Hw8P///v7/Liwq/y4sKv///v7/8vHx//Lx8f///v7/Liwq/y4s + Kv///v7/8vHx//Lx8f///v7/Liwq/y4sKv///v7/8vHx//Lx8f///v7/Liwq/y4sKv///v7/8fDw/+3s + 7P/6+vr/qamp/2ZrGUYAAAAWqamq//n5+P/p6Of/8vLw/0RAP/9TUE//U1BP/0RAP//09PL/9PTy/0RA + P/9TUE//U1BP/0RAP//09PL/9PTy/0RAP/9TUE//U1BP/0RAP//09PL/9PTy/0RAP/9TUE//U1BP/0RA + P//y8vD/6ejn//n5+P+pqar/ZmsZRgAAABaqqqr/+fj4/+Pi4v/v7u7/Ozg3/0hGRf9IRkX/Ozg3//Hx + 8f/x8fH/Ozg3/0hGRf9IRkX/Ozg3//Hx8f/x8fH/Ozg3/0hGRf9IRkX/Ozg3//Hx8f/x8fH/Ozg3/0hG + Rf9IRkX/Ozg3/+/u7v/j4uL/+fj4/6qqqv9maxlGAAAAFqqqqv/6+vr/3dva/+fm5f8kJCP/Li0s/y4t + LP8kJCP/6enn/+np5/8kJCP/Li0s/y4tLP8kJCP/6enn/+np5/8kJCP/Li0s/y4tLP8kJCP/6enn/+np + 5/8kJCP/Li0s/y4tLP8kJCP/5+bl/93b2v/6+vr/qqqq/2ZrGUYAAAAWqqqq//39/P/V09L/2tjX/+Lg + 3//m5OP/5uTj/+Lg3//c2tn/3NrZ/+Lg3//m5OP/5uTj/+Lg3//c2tn/3NrZ/+Lg3//m5OP/5uTj/+Lg + 3//c2tn/3NrZ/+Lg3//m5OP/5uTj/+Lg3//a2Nf/1dPS//39/P+qqqr/ZmsZRgAAABWqqqr//////8zL + yv/Ozcz/z87N/9DPzv/Qz87/z87N/87NzP/Ozcz/z87N/9DPzv/Qz87/z87N/87NzP/Ozcz/z87N/9DP + zv/Qz87/z87N/87NzP/Ozcz/z87N/9DPzv/Qz87/z87N/87NzP/My8r//////6qqqv9obRlFAAAADaur + q/////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////q6ur/3Z8 + HT4AAAAEqqqqtKurq/+qqqr/qamp/6mpqf+pqan/qamp/6mpqf+pqan/qamp/6mpqf+pqan/qamp/6mp + qf+pqan/qamp/6mpqf+pqan/qamp/6mpqf+pqan/qamp/6mpqf+pqan/qamp/6mpqf+pqan/qqqq/6ur + q/+kpoL/i5EiNwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACWnSXLlp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+VnCT/rLJT//Dx4f/////////////////V2Kn/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSU0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJcuWnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+VnCP/m6Ew/+Hkw//////////////////h4sH/oac9/5Wc + Iv+UmyD/lJsi/5adJf+WnSX/lp0l/5adJTQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlp0ly5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnST/l54n/8rOkv////////////// + ///z9Of/zM+W/+Pmx//KzpP/lZwk/5WcJP+WnSX/lp0lNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AACWnSXLlp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lZwj/8DE + fP/6+vT////////////////////////////6+vX/n6Y5/5adJf+WnSU0AAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAJadJcuWnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lZwj/6asRv/v8N/////////////////////////////U16f/k5oe/5adJTQAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAlp0ly5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/k5of/+Plxf////////////////////////////////+Plxf/lp0lMwAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACWnSXLlp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+UmyL/ys6T////////////////////////////5+nO/5GY + GveWnSUlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJcuWnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+VnCT/+vr1//////////////////// + //+us1f/lZ0k2JadJQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlp0ly5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5WcJP+fpjn/1Nen//// + ///n6c7/rrNX/5adJf+WnSUzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACWnSW4lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+Tmh7/j5cX/5GYGveVnSTYlp0lMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJad + JRGWnSU2lp0lNJadJTSWnSU0lp0lNJadJTSWnSU0lp0lNJadJTSWnSU0lp0lNJadJTSWnSU0lp0lNJad + JTSWnSU0lp0lNJadJTSWnSUzlp0lJZadJQYAAAAAAAAAAAAAAAD+AAAH/gAAA/4AAAH+AAAA/gAAAP4A + AAD+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAD+AAAA/gAAAP4AAAD+AAAA/gAAAP4AAAD+AAAA/gAAAP4AAAH+AAAD/gAABygAAAAwAAAAYAAAAAEA + I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ad + Jf+WnSUnAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+1umb///////////////////////// + ////////tbpm/5adJf+WnSXtlp0lAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAJadJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/6KoP/////////////// + /////////////////////////////6KoP/+WnSX/lp0lSQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/9DT + n////////////////////////////////////////////9DTn/+WnSX/lp0lqwAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l//X27P////////////////////////////////////////////X27P+WnSX/lp0l7wAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+MkyL/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/m6Ew//r69P////////////////////////////////////////////X2 + 7P+WnSX/lp0l/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+nrUn/2921//////////////////////////////////// + /////////////9DTn/+WnSX/lp0l/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAJadJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/m6Ew/73Bdv/v8N7///////////////////////// + /////////////////////////////6KoP/+WnSX/lp0l/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+nrUn/2duw//v7+P////////////// + ////////////////////////////////////////tbpm/5adJf+WnSX/lp0l/wAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/7W6Zv/u79z///////// + ///////////////////6+/b/zdCX/9LVo//19uz/9fbs/9DTn/+iqD//lp0l/5adJf+WnSX/lp0l/wAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+boTD/xsmJ//r6 + 9f///////////////////////////+7v3P+1umb/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/6et + Sf/b3bX////////////////////////////7+/j/2duw/6etSP+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/wAAAAAAAAAAAAAABAAAAA4AAAAVAAAAFgAAABYAAAAWAAAAFgAA + ABYAAAAWAAAAFomPIf+JjyH/iY8h/4mPIf+JjyH/iY8h/4mPIf+JjyH/iY8h/4mPIf+JjyH/iY8h/4mP + If+Nkyv/rLBr/9rbyv/p6en/6enp/+np6f/q6ur/8vLy/+vs2v+8wXX/mqEv/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/wAAAAAAAAAAAAAADgAAAC0AAABAAAAAQwAA + AEMAAABDAAAAQwAAAEMAAABDAAAAQ25zG/9ucxv/bnMb/25zG/9rcBr/a3Aa/2twGv9rcBr/bnMb/25z + G/9ucxv/bnMb/3t/Nf+foYH/ubm2/7y8vP+8vLz/vLy8/7y8vP/AwMD/treW/56kRP+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/wAAAAAAAAAAAAAAFaKi + otSqqqr/qKio/6ioqP+oqKj/qKio/6ioqP+oqKj/qKio/6ioqP+oqKj/qaio/6qpqP+rqqr/q6qq/6uq + qv+tra3/qamp/6ioqP+oqKj/qKio/6ioqP+oqKj/qKio/6ioqP+oqKj/qKio/6ioqP+qqqr/m52C/4mQ + If+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/wAA + AAAAAAAAAAAAFqqqqv////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// + ////////qqqq/4mPIf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/wAAAAAAAAAAAAAAFqmpqf//////+Pj4//j4+P/4+Pj/+fn5//n5+f/4+Pj/+Pj4//j4 + +P/4+Pj/+fn5//n5+f/4+Pj/+Pj4//j4+P/4+Pj/+fn5//n5+f/4+Pj/+Pj4//j4+P/4+Pj/+fn5//n5 + +f/4+Pj/+Pj4//j4+P//////qamp/4mPIf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/wAAAAAAAAAAAAAAFqmpqf/8/Pz/8vLx//Lz8f/39/b//f38//39 + /P/39/b/8/Px//Pz8f/39/b//f38//39/P/39/b/8/Px//Pz8f/39/b//f38//39/P/39/b/8/Px//Pz + 8f/39/b//f38//39/P/39/b/8vPx//Ly8f/8/Pz/qamp/4mPIf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/wAAAAAAAAAAAAAAFqmpqf/6+vr/7ezs//Hw + 8P///v7/Liwq/y4sKv///v7/8vHx//Lx8f///v7/Liwq/y4sKv///v7/8vHx//Lx8f///v7/Liwq/y4s + Kv///v7/8vHx//Lx8f///v7/Liwq/y4sKv///v7/8fDw/+3s7P/6+vr/qamp/4mPIf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/w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Pzs3/0M/O/9DPzv/Pzs3/zs3M/87NzP/Pzs3/0M/O/9DPzv/Pzs3/zs3M/87NzP/Pzs3/0M/O/9DP + zv/Pzs3/zs3M/87NzP/Pzs3/0M/O/9DPzv/Pzs3/zs3M/8zLyv//////qqqq/4mQIf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/wAAAAAAAAAAAAAADaur + q/////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////q6ur/46U + I/+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/wAA + AAAAAAAAAAAABKqqqrSrq6v/qqqq/6mpqf+pqan/qamp/6mpqf+pqan/qamp/6mpqf+pqan/qamp/6mp + qf+pqan/qamp/6mpqf+pqan/qamp/6mpqf+pqan/qamp/6mpqf+pqan/qamp/6mpqf+pqan/qamp/6qq + qv+rq6v/pKaC/5OaJP+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/mqEv/8bJif/6+/b///////// + //////////////r69f/GyYn/m6Ew/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAJadJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+1umb/8PHg////////////////////////////2921/6etSf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/rrRY/+rr1P///////////////////////////+rr1P+utFj/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/wAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/6etSP/b3bX///////////////////////// + ///w8eD/tbpm/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/wAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+aoS//xsmJ//r7 + 9v//////////////////////+vr1/8bJif+boTD/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/7W6Zv/w8eD////////////////////////////b3bX/p61J/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAJadJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+utFj/6uvU////////////////////////////7O7Z/9vd + tf/19uz/9fbs/9DTn/+iqD//lp0l/5adJf+WnSX/lp0l/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/p61I/9vdtf////////////// + ////////////////////////////////////////tbpm/5adJf+WnSX/lp0l/wAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5qh + L//GyYn/+vv2/////////////////////////////////////////////////6KoP/+WnSX/lp0l/wAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/tbpm//j48f///////////////////////////////////////////9DT + n/+WnSX/lp0l/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l//j48P////////////////////////////// + //////////////X27P+WnSX/lp0l/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAJadJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l//X27P////////////// + //////////////////////////////X27P+WnSX/lp0l7wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/9DT + n////////////////////////////////////////////9DTn/+WnSX/lp0lqwAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/6KoP////////////////////////////////////////////6KoP/+WnSX/lp0lSQAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJadJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+WnSX/lp0l/5ad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+1umb/////////////////////////////////tbpm/5ad + Jf+WnSXtlp0lAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJad + Jf+WnSX/lp0l/5adJf+WnSX/lp0l/5adJf+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/+AAAAABAAD/4AAAAAEAAP/gAAAAAQAA/+AAAAAB + AACAAAAAAAEAAIAAAAAAAQAAgAAAAAABAACAAAAAAAEAAIAAAAAAAQAAgAAAAAABAACAAAAAAAEAAIAA + AAAAAQAAgAAAAAABAACAAAAAAAEAAIAAAAAAAQAAgAAAAAABAACAAAAAAAEAAIAAAAAAAQAA/+AAAAAB + AAD/4AAAAAEAAP/gAAAAAQAA/+AAAAABAAD/4AAAAAEAAP/gAAAAAQAA/+AAAAABAAD/4AAAAAEAAP/g + AAAAAQAA/+AAAAABAAD/4AAAAAEAAP/gAAAAAQAA/+AAAAABAAD/4AAAAAEAAP/gAAAAAQAA/+AAAAAD + AAD/4AAAAAcAAP/gAAAADwAA////////AAA= + + + \ No newline at end of file diff --git a/Forwarder/Forwarder/Forwarder.cs b/Forwarder/Forwarder/Forwarder.cs new file mode 100644 index 0000000..420b8dc --- /dev/null +++ b/Forwarder/Forwarder/Forwarder.cs @@ -0,0 +1,352 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace Forwarder +{ + public class Forwarder + { + private bool stop = false; + private int currentConections; + private int totalConnections; + private IPEndPoint local; + private IPEndPoint remote; + private Thread listenerThread; + + #region Management + public void Activate() + { + if (listenerThread != null) + return; + lock (this) + { + stop = false; + } + listenerThread = new Thread(Listen); + listenerThread.Start(); + } + + public void Deactivate() + { + if (listenerThread == null) + return; + lock (this) + { + stop = true; + } + listenerThread.Join(); + Message(ForwarderMessage.FromDeactivation()); + listenerThread = null; + } + + public void SetLocal(string host, string port) + { + Local = new IPEndPoint(GetAddress(host), int.Parse(port)); + } + + public void SetRemote(string host, string port) + { + Remote = new IPEndPoint(GetAddress(host), int.Parse(port)); + } + + public static IPAddress GetAddress(string host) + { + IPAddress address; + if (!IPAddress.TryParse(host, out address)) + { + IPHostEntry dest = Dns.GetHostEntry(host); + if (dest.AddressList.Length > 0) + { + foreach (IPAddress ip in dest.AddressList) + if (ip.AddressFamily == AddressFamily.InterNetwork) + { + address = ip; + break; + } + if (address == null) + address = dest.AddressList[0]; + } + else + throw new Exception("Can't resolve '" + host + "'"); + } + return address; + } + + private void Message(ForwarderMessage msg) + { + WhenMessage?.Invoke(this, msg); + } + + #endregion + + #region Listener + + private void Listen() + { + Thread.CurrentThread.Name = "Listener on " + local; + bool running = true; + TcpListener listener = new TcpListener(local); + try + { + listener.Start(); + } + catch (SocketException ex) + { + running = false; + Message(ForwarderMessage.FromException(ex)); + } + Message(ForwarderMessage.FromActivation()); + while (running) + { + if (!listener.Pending()) + Thread.Sleep(100); + else + (new Thread(new ParameterizedThreadStart(ProcessLauncher))).Start(listener.AcceptTcpClient()); + lock (this) + { + running = !stop; + } + } + listener.Stop(); + lock (this) + { + listenerThread = null; + } + } + + private void ProcessLauncher(object o) + { + Transmission trans = null; + lock (this) + { + currentConections++; + totalConnections++; + } + try + { + using (TcpClient c = (TcpClient)o) + { + TcpProcess prc = new TcpProcess(this, c.Client, remote); + prc.Process(); + trans = prc.Transmission; + } + } + finally + { + lock (this) + { + currentConections--; + } + if (trans != null) + Message(ForwarderMessage.FromEndTransmission(trans)); + } + } + + #endregion + + #region TCP processor + + private class TcpProcess + { + private Forwarder fw; + private Socket scksrc; + private Socket sckdst; + private Transmission trans; + + public TcpProcess(Forwarder forwarder, Socket source, IPEndPoint remote) + { + try + { + fw = forwarder; + scksrc = source; + sckdst = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + trans = new Transmission(scksrc.RemoteEndPoint as IPEndPoint, sckdst.RemoteEndPoint as IPEndPoint); + forwarder.Message(ForwarderMessage.FromNewTransmission(trans)); + sckdst.Connect(remote); + } + catch (Exception ex) + { + forwarder.Message(ForwarderMessage.FromException(ex)); + } + } + + public void Process() + { + bool alive = true; + int attl = 0; + Thread.CurrentThread.Name = "Process " + scksrc.LocalEndPoint + " <-> " + sckdst.RemoteEndPoint + " at " + DateTime.Now; + try + { + while (alive) + { + bool afetch = false; + if (scksrc.Available > 0) + { + afetch = true; + trans.uploaded += dump(scksrc, sckdst); + fw.Message(ForwarderMessage.FromSendTransmission(trans)); + } + if (sckdst.Available > 0) + { + afetch = true; + trans.downloaded += dump(sckdst, scksrc); + fw.Message(ForwarderMessage.FromReceiveTransmission(trans)); + } + if (!afetch) + Thread.Sleep(50); + alive = fw.Active; + if (attl++ > 20) + { + alive = alive && scksrc.IsConnected() && sckdst.IsConnected(); + attl = 0; + } + } + } + catch (Exception ex) + { + fw.Message(ForwarderMessage.FromException(ex)); + } + } + + private static int dump(Socket sfrom, Socket sto) + { + int result; + byte[] buf = new byte[result = sfrom.Available]; + sfrom.Receive(buf); + sto.Send(buf); + return result; + } + + public Transmission Transmission => trans; + } + + #endregion + + public void ResetCounter() + { + totalConnections = 0; + } + + public override string ToString() + { + return local + " -> " + remote; + } + + public bool Active { get { return listenerThread != null; } set { if (value) Activate(); else Deactivate(); } } + public IPEndPoint Local { get { return local; } set { if (Active) throw new Exception("Can't set when active"); local = value; } } + public IPEndPoint Remote { get { return remote; } set { if (Active) throw new Exception("Can't set when active"); remote = value; } } + public int CurrentConnections { get { return currentConections; } } + public int TotalConnections { get { return totalConnections; } } + public ForwarderMessageDelegate WhenMessage { get; set; } + } + + public delegate void ForwarderMessageDelegate(Forwarder sender, ForwarderMessage msg); + + public enum ForwarderMessageType + { + ERROR, ACTIVATED, DEACTIVATED, TSTART, TSEND, TRECV, TEND + } + + public class ForwarderMessage + { + private ForwarderMessageType type; + private string message; + private Exception exception; + private DateTime time = DateTime.Now; + private Transmission trans; + + private ForwarderMessage() + { + + } + + public static ForwarderMessage FromException(Exception ex) + { + ForwarderMessage fw = new ForwarderMessage(); + fw.type = ForwarderMessageType.ERROR; + fw.message = ex.GetType().Name + ": " + ex.Message; + fw.exception = ex; + return fw; + } + + public static ForwarderMessage FromActivation() + { + ForwarderMessage fw = new ForwarderMessage(); + fw.type = ForwarderMessageType.ACTIVATED; + fw.message = "Listener enabled"; + return fw; + } + + public static ForwarderMessage FromDeactivation() + { + ForwarderMessage fw = new ForwarderMessage(); + fw.type = ForwarderMessageType.DEACTIVATED; + fw.message = "Listener disabled"; + return fw; + } + + public static ForwarderMessage FromNewTransmission(Transmission trans) + { + ForwarderMessage fw = new ForwarderMessage(); + fw.type = ForwarderMessageType.TSTART; + fw.trans = trans; + fw.message = "Transmission from " + trans.SourceIP; + return fw; + } + + public static ForwarderMessage FromSendTransmission(Transmission trans) + { + ForwarderMessage fw = new ForwarderMessage(); + fw.type = ForwarderMessageType.TSEND; + fw.trans = trans; + return fw; + } + + public static ForwarderMessage FromReceiveTransmission(Transmission trans) + { + ForwarderMessage fw = new ForwarderMessage(); + fw.type = ForwarderMessageType.TRECV; + fw.trans = trans; + return fw; + } + + public static ForwarderMessage FromEndTransmission(Transmission trans) + { + ForwarderMessage fw = new ForwarderMessage(); + fw.type = ForwarderMessageType.TEND; + fw.trans = trans; + return fw; + } + + public ForwarderMessageType Type => type; + public string Message => message; + public DateTime TimeStamp => time; + public Exception Exception => exception; + public Transmission Transmission => trans; + } + + public class Transmission + { + private IPEndPoint src; + private IPEndPoint dst; + internal int uploaded; + internal int downloaded; + + public Transmission(IPEndPoint src, IPEndPoint dst) + { + this.src = src; + this.dst = dst; + } + + public IPEndPoint SourceIP => src; + public IPEndPoint DestinationIP => dst; + public object Tag { get; set; } + public int Uploaded => uploaded; + public int Downloaded => downloaded; + } +} diff --git a/Forwarder/Forwarder/Forwarder.csproj b/Forwarder/Forwarder/Forwarder.csproj new file mode 100644 index 0000000..601e82c --- /dev/null +++ b/Forwarder/Forwarder/Forwarder.csproj @@ -0,0 +1,121 @@ + + + + + Debug + AnyCPU + {F6FF0173-BA2C-43BA-8A42-7961810DA2C2} + WinExe + Forwarder + Forwarder + v4.5 + 512 + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + TcpFordwarder.ico + + + + + + + + + + + + + + + + + + Form + + + FAbout.cs + + + Form + + + Form1.cs + + + + UserControl + + + ForwarderControl.cs + + + + + FAbout.cs + + + Form1.cs + + + ForwarderControl.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Forwarder/Forwarder/ForwarderControl.Designer.cs b/Forwarder/Forwarder/ForwarderControl.Designer.cs new file mode 100644 index 0000000..667fb9b --- /dev/null +++ b/Forwarder/Forwarder/ForwarderControl.Designer.cs @@ -0,0 +1,282 @@ +namespace Forwarder +{ + partial class ForwarderControl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ForwarderControl)); + this.pConf = new System.Windows.Forms.Panel(); + this.btStart = new System.Windows.Forms.Button(); + this.tbDestPort = new System.Windows.Forms.TextBox(); + this.lbDestPort = new System.Windows.Forms.Label(); + this.tbDestHost = new System.Windows.Forms.TextBox(); + this.lbDestHost = new System.Windows.Forms.Label(); + this.cbLocal = new System.Windows.Forms.CheckBox(); + this.tbSrcPort = new System.Windows.Forms.TextBox(); + this.lbSrc = new System.Windows.Forms.Label(); + this.lvHistory = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.ilMsg = new System.Windows.Forms.ImageList(this.components); + this.lbInfo = new System.Windows.Forms.Label(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.btClear = new System.Windows.Forms.Button(); + this.rbFollow = new System.Windows.Forms.RadioButton(); + this.cbCapture = new System.Windows.Forms.CheckBox(); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.pConf.SuspendLayout(); + this.SuspendLayout(); + // + // pConf + // + this.pConf.Controls.Add(this.cbCapture); + this.pConf.Controls.Add(this.rbFollow); + this.pConf.Controls.Add(this.lbInfo); + this.pConf.Controls.Add(this.btClear); + this.pConf.Controls.Add(this.btStart); + this.pConf.Controls.Add(this.tbDestPort); + this.pConf.Controls.Add(this.lbDestPort); + this.pConf.Controls.Add(this.tbDestHost); + this.pConf.Controls.Add(this.lbDestHost); + this.pConf.Controls.Add(this.cbLocal); + this.pConf.Controls.Add(this.tbSrcPort); + this.pConf.Controls.Add(this.lbSrc); + this.pConf.Dock = System.Windows.Forms.DockStyle.Top; + this.pConf.Location = new System.Drawing.Point(0, 0); + this.pConf.Name = "pConf"; + this.pConf.Size = new System.Drawing.Size(424, 80); + this.pConf.TabIndex = 0; + // + // btStart + // + this.btStart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btStart.Location = new System.Drawing.Point(360, 25); + this.btStart.Name = "btStart"; + this.btStart.Size = new System.Drawing.Size(61, 23); + this.btStart.TabIndex = 17; + this.btStart.Text = "Start"; + this.btStart.UseVisualStyleBackColor = true; + this.btStart.Click += new System.EventHandler(this.btStart_Click); + // + // tbDestPort + // + this.tbDestPort.Location = new System.Drawing.Point(306, 28); + this.tbDestPort.Name = "tbDestPort"; + this.tbDestPort.Size = new System.Drawing.Size(48, 20); + this.tbDestPort.TabIndex = 16; + this.tbDestPort.Text = "8088"; + this.tbDestPort.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.tbDestPort.TextChanged += new System.EventHandler(this.ConfChanged); + // + // lbDestPort + // + this.lbDestPort.AutoSize = true; + this.lbDestPort.Location = new System.Drawing.Point(271, 31); + this.lbDestPort.Name = "lbDestPort"; + this.lbDestPort.Size = new System.Drawing.Size(29, 13); + this.lbDestPort.TabIndex = 15; + this.lbDestPort.Text = "Port:"; + // + // tbDestHost + // + this.tbDestHost.Location = new System.Drawing.Point(76, 29); + this.tbDestHost.Name = "tbDestHost"; + this.tbDestHost.Size = new System.Drawing.Size(185, 20); + this.tbDestHost.TabIndex = 14; + this.tbDestHost.TextChanged += new System.EventHandler(this.ConfChanged); + // + // lbDestHost + // + this.lbDestHost.AutoSize = true; + this.lbDestHost.Location = new System.Drawing.Point(7, 32); + this.lbDestHost.Name = "lbDestHost"; + this.lbDestHost.Size = new System.Drawing.Size(63, 13); + this.lbDestHost.TabIndex = 13; + this.lbDestHost.Text = "Destination:"; + // + // cbLocal + // + this.cbLocal.AutoSize = true; + this.cbLocal.Location = new System.Drawing.Point(130, 5); + this.cbLocal.Name = "cbLocal"; + this.cbLocal.Size = new System.Drawing.Size(131, 17); + this.cbLocal.TabIndex = 12; + this.cbLocal.Text = "only local connections"; + this.cbLocal.UseVisualStyleBackColor = true; + this.cbLocal.CheckedChanged += new System.EventHandler(this.ConfChanged); + // + // tbSrcPort + // + this.tbSrcPort.Location = new System.Drawing.Point(76, 3); + this.tbSrcPort.Name = "tbSrcPort"; + this.tbSrcPort.Size = new System.Drawing.Size(48, 20); + this.tbSrcPort.TabIndex = 11; + this.tbSrcPort.Text = "8088"; + this.tbSrcPort.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.tbSrcPort.TextChanged += new System.EventHandler(this.ConfChanged); + // + // lbSrc + // + this.lbSrc.AutoSize = true; + this.lbSrc.Location = new System.Drawing.Point(4, 6); + this.lbSrc.Name = "lbSrc"; + this.lbSrc.Size = new System.Drawing.Size(66, 13); + this.lbSrc.TabIndex = 10; + this.lbSrc.Text = "Source Port:"; + // + // lvHistory + // + this.lvHistory.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2, + this.columnHeader3}); + this.lvHistory.Dock = System.Windows.Forms.DockStyle.Fill; + this.lvHistory.FullRowSelect = true; + this.lvHistory.GridLines = true; + this.lvHistory.HideSelection = false; + this.lvHistory.Location = new System.Drawing.Point(0, 80); + this.lvHistory.MultiSelect = false; + this.lvHistory.Name = "lvHistory"; + this.lvHistory.Size = new System.Drawing.Size(424, 342); + this.lvHistory.SmallImageList = this.ilMsg; + this.lvHistory.TabIndex = 1; + this.lvHistory.UseCompatibleStateImageBehavior = false; + this.lvHistory.View = System.Windows.Forms.View.Details; + this.lvHistory.Resize += new System.EventHandler(this.lvHistory_Resize); + // + // columnHeader1 + // + this.columnHeader1.Text = "Events"; + this.columnHeader1.Width = 300; + // + // ilMsg + // + this.ilMsg.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("ilMsg.ImageStream"))); + this.ilMsg.TransparentColor = System.Drawing.Color.Transparent; + this.ilMsg.Images.SetKeyName(0, "msg_info.png"); + this.ilMsg.Images.SetKeyName(1, "msg_error.png"); + this.ilMsg.Images.SetKeyName(2, "msg_connect.png"); + this.ilMsg.Images.SetKeyName(3, "msg_go.png"); + this.ilMsg.Images.SetKeyName(4, "msg_come.png"); + this.ilMsg.Images.SetKeyName(5, "msg_finish.png"); + // + // lbInfo + // + this.lbInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.lbInfo.Location = new System.Drawing.Point(274, 59); + this.lbInfo.Name = "lbInfo"; + this.lbInfo.Size = new System.Drawing.Size(147, 16); + this.lbInfo.TabIndex = 19; + this.lbInfo.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // btClear + // + this.btClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btClear.Image = global::Forwarder.Properties.Resources.list_clear; + this.btClear.Location = new System.Drawing.Point(1, 52); + this.btClear.Name = "btClear"; + this.btClear.Size = new System.Drawing.Size(25, 25); + this.btClear.TabIndex = 18; + this.toolTip1.SetToolTip(this.btClear, "Clear event list"); + this.btClear.UseVisualStyleBackColor = true; + this.btClear.Click += new System.EventHandler(this.btClear_Click); + // + // rbFollow + // + this.rbFollow.Appearance = System.Windows.Forms.Appearance.Button; + this.rbFollow.Checked = true; + this.rbFollow.Image = global::Forwarder.Properties.Resources.list_follow; + this.rbFollow.Location = new System.Drawing.Point(28, 52); + this.rbFollow.Name = "rbFollow"; + this.rbFollow.Size = new System.Drawing.Size(25, 25); + this.rbFollow.TabIndex = 21; + this.rbFollow.TabStop = true; + this.toolTip1.SetToolTip(this.rbFollow, "Follow events"); + this.rbFollow.UseVisualStyleBackColor = true; + // + // cbCapture + // + this.cbCapture.AutoSize = true; + this.cbCapture.Enabled = false; + this.cbCapture.Location = new System.Drawing.Point(59, 57); + this.cbCapture.Name = "cbCapture"; + this.cbCapture.Size = new System.Drawing.Size(87, 17); + this.cbCapture.TabIndex = 22; + this.cbCapture.Text = "Capture data"; + this.toolTip1.SetToolTip(this.cbCapture, "Capture traffic data for later analysis"); + this.cbCapture.UseVisualStyleBackColor = true; + // + // columnHeader2 + // + this.columnHeader2.Text = "Send"; + this.columnHeader2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.columnHeader2.Width = 70; + // + // columnHeader3 + // + this.columnHeader3.Text = "Recv."; + this.columnHeader3.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.columnHeader3.Width = 70; + // + // ForwarderControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lvHistory); + this.Controls.Add(this.pConf); + this.Name = "ForwarderControl"; + this.Size = new System.Drawing.Size(424, 422); + this.pConf.ResumeLayout(false); + this.pConf.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel pConf; + private System.Windows.Forms.Button btStart; + private System.Windows.Forms.TextBox tbDestPort; + private System.Windows.Forms.Label lbDestPort; + private System.Windows.Forms.TextBox tbDestHost; + private System.Windows.Forms.Label lbDestHost; + private System.Windows.Forms.CheckBox cbLocal; + private System.Windows.Forms.TextBox tbSrcPort; + private System.Windows.Forms.Label lbSrc; + private System.Windows.Forms.ListView lvHistory; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ImageList ilMsg; + private System.Windows.Forms.Button btClear; + private System.Windows.Forms.Label lbInfo; + private System.Windows.Forms.ToolTip toolTip1; + private System.Windows.Forms.RadioButton rbFollow; + private System.Windows.Forms.CheckBox cbCapture; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.ColumnHeader columnHeader3; + } +} diff --git a/Forwarder/Forwarder/ForwarderControl.cs b/Forwarder/Forwarder/ForwarderControl.cs new file mode 100644 index 0000000..2060483 --- /dev/null +++ b/Forwarder/Forwarder/ForwarderControl.cs @@ -0,0 +1,244 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Net.Sockets; + +namespace Forwarder +{ + public partial class ForwarderControl : UserControl + { + public ForwarderChanged WhenChanged; + + Forwarder fw = new Forwarder(); + + public ForwarderControl() + { + InitializeComponent(); + fw.WhenMessage = FMessage; + lvHistory_Resize(null, null); + FMessage(fw, null); + } + + private int FMessageIcon(ForwarderMessageType t) + { + switch (t) + { + case ForwarderMessageType.ACTIVATED: + case ForwarderMessageType.DEACTIVATED: + return 0; + case ForwarderMessageType.ERROR: + return 1; + case ForwarderMessageType.TSTART: + return 2; + case ForwarderMessageType.TSEND: + return 3; + case ForwarderMessageType.TRECV: + return 4; + case ForwarderMessageType.TEND: + return 5; + default: + return 1; + } + } + + private void FMessage(Forwarder sender, ForwarderMessage msg) + { + if (InvokeRequired) + { + try + { + Invoke(new MethodInvoker(() => FMessage(sender, msg))); + } + catch { } + return; + } + ListViewItem lvi = null; + if (msg != null) + switch (msg.Type) + { + case ForwarderMessageType.ACTIVATED: + case ForwarderMessageType.DEACTIVATED: + lvi = lvHistory.Items.Add(msg.Message); + lvi.ImageIndex = 0; + break; + case ForwarderMessageType.ERROR: + lvi = lvHistory.Items.Add(msg.Message); + lvi.ImageIndex = 1; + break; + case ForwarderMessageType.TSTART: + lvi = lvHistory.Items.Add(msg.Message); + lvi.ImageIndex = 2; + msg.Transmission.Tag = lvi; + lvi.SubItems.Add("0"); + lvi.SubItems.Add("0"); + break; + case ForwarderMessageType.TEND: + case ForwarderMessageType.TRECV: + case ForwarderMessageType.TSEND: + lvi = msg.Transmission.Tag as ListViewItem; + if (lvi == null) + { + lvi = lvHistory.Items.Add("<<< Lost transmission >>>"); + lvi.ImageIndex = 1; + msg.Transmission.Tag = lvi; + } + else + { + lvi.ImageIndex = FMessageIcon(msg.Type); + lvi.SubItems[1].Text = FBytes(msg.Transmission.Uploaded); + lvi.SubItems[2].Text = FBytes(msg.Transmission.Downloaded); + } + break; + default: + lvi = lvHistory.Items.Add("[??] " + msg.Message); + lvi.ImageIndex = 1; + break; + } + if (lvi != null) + { + if (rbFollow.Checked) + lvi.Selected = true; + //lvHistory_Resize(null, null); + } + lbInfo.Text = "Hints: " + sender.TotalConnections + " Alive: " + sender.CurrentConnections; + } + + private string FBytes(int bytes) + { + if (bytes < 1024) + return bytes.ToString(); + string tail = null; + double b = bytes; + if (b > 1024) + { + tail = "Kb"; + b /= 1024; + } + if (b > 1024) + { + tail = "Mb"; + b /= 1024; + } + if (b > 1024) + { + tail = "Gb"; + b /= 1024; + } + return b.ToString("#0.00") + tail; + } + + private bool RefreshForwarder() + { + try + { + fw.SetLocal(cbLocal.Checked ? "127.0.0.1" : "0.0.0.0", tbSrcPort.Text); + tbSrcPort.BackColor = SystemColors.Window; + } + catch (FormatException) + { + tbSrcPort.BackColor = Color.LightPink; + return false; + } + try + { + fw.SetRemote(tbDestHost.Text, tbDestPort.Text); + tbDestHost.BackColor = SystemColors.Window; + tbDestPort.BackColor = SystemColors.Window; + } + catch (FormatException) + { + tbDestPort.BackColor = Color.LightPink; + return false; + } + catch (SocketException) + { + tbDestHost.BackColor = Color.LightPink; + return false; + } + return true; + } + + public void StopForwarder() + { + fw.Deactivate(); + } + + public override string ToString() + { + return fw.ToString(); + } + + public string SourcePort => tbSrcPort.Text; + public bool SourceLocal => cbLocal.Checked; + public string DestinationPort => tbDestPort.Text; + public string DestinationHost => tbDestHost.Text; + public bool Active => fw.Active; + + private void btStart_Click(object sender, EventArgs e) + { + try + { + if (fw.Active) + { + fw.Deactivate(); + tbDestHost.Enabled = true; + tbDestPort.Enabled = true; + tbSrcPort.Enabled = true; + cbLocal.Enabled = true; + btStart.Text = "Start"; + } + else + { + pConf.Enabled = false; + if (!RefreshForwarder()) + { + pConf.Enabled = true; + return; + } + pConf.Enabled = true; + + fw.Activate(); + tbDestHost.Enabled = false; + tbDestPort.Enabled = false; + tbSrcPort.Enabled = false; + cbLocal.Enabled = false; + btStart.Text = "Stop"; + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error); + } + WhenChanged?.Invoke(); + } + + private void ConfChanged(object sender, EventArgs e) + { + WhenChanged?.Invoke(); + } + + private void lvHistory_Resize(object sender, EventArgs e) + { + //lvHistory.Columns[0].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); + int acw = 0; + for (int i = 1; i < lvHistory.Columns.Count; i++) + acw += lvHistory.Columns[i].Width; + //if (lvHistory.Columns[0].Width + acw < lvHistory.ClientRectangle.Width) + lvHistory.Columns[0].Width = lvHistory.ClientRectangle.Width - acw; + } + + private void btClear_Click(object sender, EventArgs e) + { + lvHistory.Items.Clear(); + fw.ResetCounter(); + } + } + + public delegate void ForwarderChanged(); +} diff --git a/Forwarder/Forwarder/ForwarderControl.resx b/Forwarder/Forwarder/ForwarderControl.resx new file mode 100644 index 0000000..9f9c906 --- /dev/null +++ b/Forwarder/Forwarder/ForwarderControl.resx @@ -0,0 +1,251 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADU + GgAAAk1TRnQBSQFMAgEBBgEAARgBAAEYAQABEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA + AwABIAMAAQEBAAEgBgABICYAAwQBBQMMARADDAEQAwQBBhwAAyMBMwMjATMDIwEzxAADBAEFAxMBGgMk + ATUDIQExAw0BERwAATcBgQGsAf8BNgGAAasB/wE3AYEBrAH/wAADAwEEAxIBGAMmATkBHAGAAVIB8QEA + AY4BSwH/AxABFhwAATUBfAGrAf8BaAGyAdQB/wE1AYABqwH/vAADAgEDAxABFQMkATUBIwF5AU8B7AEA + AccBhgH/AQABiwFIAf8DHAEnAxABFgMQARYDEAEWAxABFgMQARYDDAEQAwQBBQE1AXwBqgH/AWYBsAHT + Af8BNQF8AasB/7gAAwIBAwMPARQDIgEyAUIBZgFVAc8BAAHAAYAB/wEAAeUBpgH/AQABiAFFAf8DLgFI + AysBQwMrAUMDKwFDAysBQwMrAUI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ABByUAAYAHAAHABwAB4AF/BgAB8AF/BgAB+AF/AQABEAQAAv8BAAEfBAAB/gE/AgABnwH/ + Af4BHwH8AR8CAAGAAf8B/gEPAfgBDwIAAYABfwH+AQcB8AEHAgABwAE/AQABAwHgAQMCAAHAAT8BAAEB + AcABAQGAAQEBwAEPAgABgAEAAYABAQHAAQcCAAGAAQABwAEDAcABAwIAAYABAAHAAQMB4AEDAgABgAEA + AeABBwHwAQMCAAHAAQEB8AEPAfwBAwEAAQEB4AEDAfABDwH8AQMBAAEDAfABBwH4AR8B/gEBAf4BBwH4 + AQ8B/AE/Af8BAQH+AQ8B/AEfA/8B+QH+AR8B/gE/Bv8L + + + + 98, 17 + + + 98, 17 + + \ No newline at end of file diff --git a/Forwarder/Forwarder/Program.cs b/Forwarder/Forwarder/Program.cs new file mode 100644 index 0000000..cc3f44e --- /dev/null +++ b/Forwarder/Forwarder/Program.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Forwarder +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + Application.Run(new Form1()); + } + + private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + Exception ex = e.ExceptionObject as Exception; + if (ex != null) + MessageBox.Show(ex.Message,"Critical "+ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } +} diff --git a/Forwarder/Forwarder/Properties/AssemblyInfo.cs b/Forwarder/Forwarder/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c50b1d2 --- /dev/null +++ b/Forwarder/Forwarder/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +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("Forwarder")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Forwarder")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[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("f6ff0173-ba2c-43ba-8a42-7961810da2c2")] + +// 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")] diff --git a/Forwarder/Forwarder/Properties/Resources.Designer.cs b/Forwarder/Forwarder/Properties/Resources.Designer.cs new file mode 100644 index 0000000..1feea29 --- /dev/null +++ b/Forwarder/Forwarder/Properties/Resources.Designer.cs @@ -0,0 +1,163 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace Forwarder.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // 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", "15.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() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [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("Forwarder.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap computer { + get { + object obj = ResourceManager.GetObject("computer", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap cross { + get { + object obj = ResourceManager.GetObject("cross", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap help { + get { + object obj = ResourceManager.GetObject("help", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap link_go { + get { + object obj = ResourceManager.GetObject("link_go", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap list_clear { + get { + object obj = ResourceManager.GetObject("list_clear", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap list_follow { + get { + object obj = ResourceManager.GetObject("list_follow", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap TcpForwarder { + get { + object obj = ResourceManager.GetObject("TcpForwarder", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap world { + get { + object obj = ResourceManager.GetObject("world", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap world_add { + get { + object obj = ResourceManager.GetObject("world_add", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap world_delete { + get { + object obj = ResourceManager.GetObject("world_delete", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Forwarder/Forwarder/Properties/Resources.resx b/Forwarder/Forwarder/Properties/Resources.resx new file mode 100644 index 0000000..88143a1 --- /dev/null +++ b/Forwarder/Forwarder/Properties/Resources.resx @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\list_clear.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\list_follow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\world_delete-1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\world.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\cross.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\help.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\world_add-1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\link_go.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\TcpForwarder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\computer.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Forwarder/Forwarder/Properties/Settings.Designer.cs b/Forwarder/Forwarder/Properties/Settings.Designer.cs new file mode 100644 index 0000000..cd4a553 --- /dev/null +++ b/Forwarder/Forwarder/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace Forwarder.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.5.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; + } + } + } +} diff --git a/Forwarder/Forwarder/Properties/Settings.settings b/Forwarder/Forwarder/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Forwarder/Forwarder/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Forwarder/Forwarder/Resources/TcpForwarder.png b/Forwarder/Forwarder/Resources/TcpForwarder.png new file mode 100644 index 0000000..47dc573 --- /dev/null +++ b/Forwarder/Forwarder/Resources/TcpForwarder.png Binary files differ diff --git a/Forwarder/Forwarder/Resources/computer.png b/Forwarder/Forwarder/Resources/computer.png new file mode 100644 index 0000000..b7a72e3 --- /dev/null +++ b/Forwarder/Forwarder/Resources/computer.png Binary files differ diff --git a/Forwarder/Forwarder/Resources/cross.png b/Forwarder/Forwarder/Resources/cross.png new file mode 100644 index 0000000..2a02b36 --- /dev/null +++ b/Forwarder/Forwarder/Resources/cross.png Binary files differ diff --git a/Forwarder/Forwarder/Resources/help.png b/Forwarder/Forwarder/Resources/help.png new file mode 100644 index 0000000..bebaa54 --- /dev/null +++ b/Forwarder/Forwarder/Resources/help.png Binary files differ diff --git a/Forwarder/Forwarder/Resources/link_go.png b/Forwarder/Forwarder/Resources/link_go.png new file mode 100644 index 0000000..3748629 --- /dev/null +++ b/Forwarder/Forwarder/Resources/link_go.png Binary files differ diff --git a/Forwarder/Forwarder/Resources/list_clear.png b/Forwarder/Forwarder/Resources/list_clear.png new file mode 100644 index 0000000..ed48ab1 --- /dev/null +++ b/Forwarder/Forwarder/Resources/list_clear.png Binary files differ diff --git a/Forwarder/Forwarder/Resources/list_follow.png b/Forwarder/Forwarder/Resources/list_follow.png new file mode 100644 index 0000000..a2e7301 --- /dev/null +++ b/Forwarder/Forwarder/Resources/list_follow.png Binary files differ diff --git a/Forwarder/Forwarder/Resources/world.png b/Forwarder/Forwarder/Resources/world.png new file mode 100644 index 0000000..c841a91 --- /dev/null +++ b/Forwarder/Forwarder/Resources/world.png Binary files differ diff --git a/Forwarder/Forwarder/Resources/world_add-1.png b/Forwarder/Forwarder/Resources/world_add-1.png new file mode 100644 index 0000000..04f5a73 --- /dev/null +++ b/Forwarder/Forwarder/Resources/world_add-1.png Binary files differ diff --git a/Forwarder/Forwarder/Resources/world_delete-1.png b/Forwarder/Forwarder/Resources/world_delete-1.png new file mode 100644 index 0000000..0cfbb7d --- /dev/null +++ b/Forwarder/Forwarder/Resources/world_delete-1.png Binary files differ diff --git a/Forwarder/Forwarder/TcpFordwarder.ico b/Forwarder/Forwarder/TcpFordwarder.ico new file mode 100644 index 0000000..1ce4eb2 --- /dev/null +++ b/Forwarder/Forwarder/TcpFordwarder.ico Binary files differ diff --git a/Forwarder/Forwarder/if_network-wired_118859.ico b/Forwarder/Forwarder/if_network-wired_118859.ico new file mode 100644 index 0000000..d5715cd --- /dev/null +++ b/Forwarder/Forwarder/if_network-wired_118859.ico Binary files differ diff --git a/Forwarder/res/cross.png b/Forwarder/res/cross.png new file mode 100644 index 0000000..2a02b36 --- /dev/null +++ b/Forwarder/res/cross.png Binary files differ diff --git a/Forwarder/res/if_network-wired_118859.ico b/Forwarder/res/if_network-wired_118859.ico new file mode 100644 index 0000000..d5715cd --- /dev/null +++ b/Forwarder/res/if_network-wired_118859.ico Binary files differ diff --git a/Forwarder/res/link_go.png b/Forwarder/res/link_go.png new file mode 100644 index 0000000..3748629 --- /dev/null +++ b/Forwarder/res/link_go.png Binary files differ diff --git a/Forwarder/res/list_clear.png b/Forwarder/res/list_clear.png new file mode 100644 index 0000000..ed48ab1 --- /dev/null +++ b/Forwarder/res/list_clear.png Binary files differ diff --git a/Forwarder/res/list_follow.png b/Forwarder/res/list_follow.png new file mode 100644 index 0000000..a2e7301 --- /dev/null +++ b/Forwarder/res/list_follow.png Binary files differ diff --git a/Forwarder/res/msg_come.png b/Forwarder/res/msg_come.png new file mode 100644 index 0000000..0478336 --- /dev/null +++ b/Forwarder/res/msg_come.png Binary files differ diff --git a/Forwarder/res/msg_connect.png b/Forwarder/res/msg_connect.png new file mode 100644 index 0000000..4abb325 --- /dev/null +++ b/Forwarder/res/msg_connect.png Binary files differ diff --git a/Forwarder/res/msg_error.png b/Forwarder/res/msg_error.png new file mode 100644 index 0000000..ad11b1a --- /dev/null +++ b/Forwarder/res/msg_error.png Binary files differ diff --git a/Forwarder/res/msg_finish.png b/Forwarder/res/msg_finish.png new file mode 100644 index 0000000..c87a44b --- /dev/null +++ b/Forwarder/res/msg_finish.png Binary files differ diff --git a/Forwarder/res/msg_go.png b/Forwarder/res/msg_go.png new file mode 100644 index 0000000..7a69e99 --- /dev/null +++ b/Forwarder/res/msg_go.png Binary files differ diff --git a/Forwarder/res/msg_info.png b/Forwarder/res/msg_info.png new file mode 100644 index 0000000..eabaf75 --- /dev/null +++ b/Forwarder/res/msg_info.png Binary files differ diff --git a/Forwarder/res/world.png b/Forwarder/res/world.png new file mode 100644 index 0000000..c841a91 --- /dev/null +++ b/Forwarder/res/world.png Binary files differ diff --git a/Forwarder/res/world_add-1.png b/Forwarder/res/world_add-1.png new file mode 100644 index 0000000..04f5a73 --- /dev/null +++ b/Forwarder/res/world_add-1.png Binary files differ diff --git a/Forwarder/res/world_add.png b/Forwarder/res/world_add.png new file mode 100644 index 0000000..6407bd3 --- /dev/null +++ b/Forwarder/res/world_add.png Binary files differ diff --git a/Forwarder/res/world_delete-1.png b/Forwarder/res/world_delete-1.png new file mode 100644 index 0000000..0cfbb7d --- /dev/null +++ b/Forwarder/res/world_delete-1.png Binary files differ diff --git a/Forwarder/res/world_delete.png b/Forwarder/res/world_delete.png new file mode 100644 index 0000000..9deb86b --- /dev/null +++ b/Forwarder/res/world_delete.png Binary files differ diff --git a/Forwarder/res/world_go.png b/Forwarder/res/world_go.png new file mode 100644 index 0000000..63af1cb --- /dev/null +++ b/Forwarder/res/world_go.png Binary files differ