private void buttonAddTunnel_Click(object sender, EventArgs e) { if (!_tunnelValidator.ValidateControls()) return; var name = textBoxTunnelName.Text; var srcPort = textBoxSourcePort.Text; var dstHost = textBoxDestHost.Text; var dstPort = textBoxDestPort.Text; var tunnelType = radioButtonLocal.Checked ? TunnelType.Local : (radioButtonRemote.Checked ? TunnelType.Remote : TunnelType.Dynamic); var tunnel = new TunnelInfo {Name = name, LocalPort = srcPort, RemoteHostname = dstHost, RemotePort = dstPort, Type = tunnelType}; addTunnel(tunnel); Modified = true; resetAddTunnelGroup(); }
public static string PuttyTunnelArguments(TunnelInfo tunnel) { if (tunnel == null) throw new ArgumentNullException("tunnel"); switch (tunnel.Type) { case TunnelType.Local: return String.Format(@"-L {0}:{1}:{2}", tunnel.LocalPort, tunnel.RemoteHostname, tunnel.RemotePort); case TunnelType.Remote: throw new NotImplementedException(); case TunnelType.Dynamic: return String.Format(@"-D {0}", tunnel.LocalPort); default: throw new FormatException(Resources.ConsoleTools_Error_InvalidTunnelType); } }
private void addTunnel(TunnelInfo tunnel) { var row = new DataGridViewRow(); row.Cells.Add(new DataGridViewTextBoxCell {Value = tunnel.Name}); row.Cells.Add(new DataGridViewTextBoxCell {Value = tunnel.Type.ToString()[0]}); row.Cells.Add(new DataGridViewTextBoxCell {Value = tunnel.LocalPort}); row.Cells.Add(new DataGridViewTextBoxCell {Value = tunnel.RemoteHostname}); row.Cells.Add(new DataGridViewTextBoxCell {Value = tunnel.RemotePort}); row.Tag = tunnel; tunnelsGridView.Rows.Add(row); }