public TunnelViewModel(TunnelInfo tunnel)
        {
            if (tunnel == null)
            {
                throw new ArgumentNullException("tunnel");
            }

            this.Tunnel = tunnel;
        }
        private void PublishTunnelFailure(TunnelInfo tunnel, string errorMessage)
        {
            this.HasForwardingFailures = true;

            if (this.Observer != null)
            {
                this.Observer.HandleForwardingError(this, tunnel, errorMessage);
            }
        }
 void IConnectionObserver.HandleForwardingError(IConnection sender, TunnelInfo tunnel, string errorMessage)
 {
     this.Fire(o => o.HandleForwardingError(sender.Info, tunnel, errorMessage));
 }
        private static string BuildPuttyTunnelArguments(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:
                return String.Format(@" -R {0}:{1}:{2}", tunnel.LocalPort, tunnel.RemoteHostName, tunnel.RemotePort);
            case TunnelType.Dynamic:
                return String.Format(@" -D {0}", tunnel.LocalPort);
            default:
                throw new ArgumentOutOfRangeException("tunnel");
            }
        }
 protected bool Equals(TunnelInfo other)
 {
     return(string.Equals(this.Name, other.Name));
 }
 public void RenderTunnelError(TunnelInfo tunnel, string errorMessage)
 {
     var viewModel = this.tunnelViewModels.First(t => t.Tunnel.Equals(tunnel));
     viewModel.ErrorText = errorMessage;
 }
        private void AddTunnelToList(TunnelInfo tunnel)
        {
            string tunnelTypeAbbr;
            var remotePort = tunnel.RemotePort.ToString(CultureInfo.InvariantCulture);
            switch (tunnel.Type)
            {
            case TunnelType.Local:
                tunnelTypeAbbr = "L";
                break;
            case TunnelType.Remote:
                tunnelTypeAbbr = "R";
                break;
            case TunnelType.Dynamic:
                tunnelTypeAbbr = "D";
                remotePort = "";
                break;
            default:
                throw new ArgumentOutOfRangeException();
            }

            var row = new DataGridViewRow();
            row.Cells.Add(
                new DataGridViewTextBoxCell
                    {
                        Value = tunnel.Name
                    });
            row.Cells.Add(
                new DataGridViewTextBoxCell
                    {
                        Value = tunnelTypeAbbr
                    });
            row.Cells.Add(
                new DataGridViewTextBoxCell
                    {
                        Value = tunnel.LocalPort
                    });
            row.Cells.Add(
                new DataGridViewTextBoxCell
                    {
                        Value = tunnel.RemoteHostName
                    });
            row.Cells.Add(
                new DataGridViewTextBoxCell
                    {
                        Value = remotePort
                    });
            row.Tag = tunnel;
            this.tunnelsGridView.Rows.Add(row);
        }
        public void AddTunnel()
        {
            if (!this.tunnelValidator.Validate())
            {
                return;
            }

            var name = this.tunnelNameTextBox.Text;

            var srcPort = int.Parse(this.tunnelSrcPortTextBox.Text);
            string dstHost = null;
            int dstPort = 0;
            var tunnelType = this.tunnelTypeLocalRadioButton.Checked
                ? TunnelType.Local
                : (this.tunnelTypeRemoteRadioButton.Checked
                    ? TunnelType.Remote
                    : TunnelType.Dynamic);
            if (tunnelType != TunnelType.Dynamic)
            {
                dstHost = this.tunnelDstHostTextBox.Text;
                dstPort = int.Parse(this.tunnelDstPortTextBox.Text);
            }

            var tunnel = new TunnelInfo
                {
                    Name = name,
                    LocalPort = srcPort,
                    RemoteHostName = dstHost,
                    RemotePort = dstPort,
                    Type = tunnelType
                };

            this.AddTunnelToList(tunnel);
            this.Modified = true;
            this.ResetAddTunnelGroup();
        }
 public void HandleForwardingError(IConnection sender, TunnelInfo tunnel, string errorMessage)
 {
     Console.WriteLine("Forwarding error for the tunnel {0}: {1}", tunnel.DisplayText, errorMessage);
 }
Esempio n. 10
0
 protected bool Equals(TunnelInfo other)
 {
     return string.Equals(this.Name, other.Name);
 }