Base class for port forwarding functionality.
Inheritance: IForwardedPort
        public void Open()
        {
            _client.Connect();

            _forwardedPort = new ForwardedPortLocal(LocalHost, LocalPort, _mySqlHost, (uint)_mySqlPort);
            _client.AddForwardedPort(_forwardedPort);
            _forwardedPort.Start();

            _connection.Open();
        }
Ejemplo n.º 2
0
        private void AttachForwardedPort(ForwardedPort port)
        {
            if (port.Session != null && port.Session != Session)
            {
                throw new InvalidOperationException("Forwarded port is already added to a different client.");
            }

            port.Session = Session;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds the forwarded port.
        /// </summary>
        /// <param name="port">The port.</param>
        /// <example>
        ///     <code source="..\..\Lib\Neon.SSH.NET\Examples\ForwardedPortRemoteTest.cs" region="Example SshClient AddForwardedPort Start Stop ForwardedPortRemote" language="C#" title="Remote port forwarding" />
        ///     <code source="..\..\Lib\Neon.SSH.NET\Examples\ForwardedPortLocalTest.cs" region="Example SshClient AddForwardedPort Start Stop ForwardedPortLocal" language="C#" title="Local port forwarding" />
        /// </example>
        /// <exception cref="InvalidOperationException">Forwarded port is already added to a different client.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="port"/> is <c>null</c>.</exception>
        /// <exception cref="SshConnectionException">Client is not connected.</exception>
        public void AddForwardedPort(ForwardedPort port)
        {
            if (port == null)
            {
                throw new ArgumentNullException("port");
            }
            EnsureSessionIsOpen();

            AttachForwardedPort(port);
            _forwardedPorts.Add(port);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Stops and removes the forwarded port from the list.
        /// </summary>
        /// <param name="port">Forwarded port.</param>
        /// <exception cref="ArgumentNullException"><paramref name="port"/> is null.</exception>
        public void RemoveForwardedPort(ForwardedPort port)
        {
            if (port == null)
            {
                throw new ArgumentNullException("port");
            }

            //  Stop port forwarding before removing it
            port.Stop();

            this._forwardedPorts.Remove(port);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Adds the forwarded port.
        /// </summary>
        /// <param name="port">The port.</param>
        public void AddForwardedPort(ForwardedPort port)
        {
            //  Ensure that connection is established.
            this.EnsureConnection();

            if (port.Session != null && port.Session != this.Session)
            {
                throw new InvalidOperationException("Forwarded port is already added to a different client.");
            }

            port.Session = this.Session;

            this._forwardedPorts.Add(port);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Adds the forwarded port.
        /// </summary>
        /// <param name="port">The port.</param>
        /// <example>
        ///     <code source="..\..\Renci.SshNet.Tests\Classes\ForwardedPortRemoteTest.cs" region="Example SshClient AddForwardedPort Start Stop ForwardedPortRemote" language="C#" title="Remote port forwarding" />
        ///     <code source="..\..\Renci.SshNet.Tests\Classes\ForwardedPortLocalTest.cs" region="Example SshClient AddForwardedPort Start Stop ForwardedPortLocal" language="C#" title="Local port forwarding" />
        /// </example>
        /// <exception cref="InvalidOperationException">Forwarded port is already added to a different client.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="port"/> is null.</exception>
        /// <exception cref="SshConnectionException">Client is not connected.</exception>
        public void AddForwardedPort(ForwardedPort port)
        {
            if (port == null)
            {
                throw new ArgumentNullException("port");
            }

            if (port.Session != null && port.Session != this.Session)
            {
                throw new InvalidOperationException("Forwarded port is already added to a different client.");
            }

            port.Session = this.Session;

            this._forwardedPorts.Add(port);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Stops and removes the forwarded port from the list.
        /// </summary>
        /// <param name="port">Forwarded port.</param>
        /// <exception cref="ArgumentNullException"><paramref name="port"/> is null.</exception>
        public void RemoveForwardedPort(ForwardedPort port)
        {
            if (port == null)
                throw new ArgumentNullException("port");

            //  Stop port forwarding before removing it
            port.Stop();

            port.Session = null;

            this._forwardedPorts.Remove(port);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Adds the forwarded port.
        /// </summary>
        /// <param name="port">The port.</param>
        /// <example>
        ///     <code source="..\..\Renci.SshNet.Tests\Classes\ForwardedPortRemoteTest.cs" region="Example SshClient AddForwardedPort Start Stop ForwardedPortRemote" language="C#" title="Remote port forwarding" />
        ///     <code source="..\..\Renci.SshNet.Tests\Classes\ForwardedPortLocalTest.cs" region="Example SshClient AddForwardedPort Start Stop ForwardedPortLocal" language="C#" title="Local port forwarding" />
        /// </example>
        /// <exception cref="InvalidOperationException">Forwarded port is already added to a different client.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="port"/> is null.</exception>
        /// <exception cref="SshConnectionException">Client is not connected.</exception>
        public void AddForwardedPort(ForwardedPort port)
        {
            if (port == null)
                throw new ArgumentNullException("port");

            if (port.Session != null && port.Session != this.Session)
                throw new InvalidOperationException("Forwarded port is already added to a different client.");

            port.Session = this.Session;

            this._forwardedPorts.Add(port);
        }
Ejemplo n.º 9
0
 private static void DetachForwardedPort(ForwardedPort port)
 {
     port.Session = null;
 }
Ejemplo n.º 10
0
 private static void DetachForwardedPort(ForwardedPort port)
 {
     port.Session = null;
 }
Ejemplo n.º 11
0
        private void AttachForwardedPort(ForwardedPort port)
        {
            if (port.Session != null && port.Session != Session)
                throw new InvalidOperationException("Forwarded port is already added to a different client.");

            port.Session = Session;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Adds the forwarded port.
        /// </summary>
        /// <param name="port">The port.</param>
        /// <example>
        ///     <code source="..\..\src\Renci.SshNet.Tests\Classes\ForwardedPortRemoteTest.cs" region="Example SshClient AddForwardedPort Start Stop ForwardedPortRemote" language="C#" title="Remote port forwarding" />
        ///     <code source="..\..\src\Renci.SshNet.Tests\Classes\ForwardedPortLocalTest.cs" region="Example SshClient AddForwardedPort Start Stop ForwardedPortLocal" language="C#" title="Local port forwarding" />
        /// </example>
        /// <exception cref="InvalidOperationException">Forwarded port is already added to a different client.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="port"/> is <c>null</c>.</exception>
        /// <exception cref="SshConnectionException">Client is not connected.</exception>
        public void AddForwardedPort(ForwardedPort port)
        {
            if (port == null)
                throw new ArgumentNullException("port");
            EnsureSessionIsOpen();

            AttachForwardedPort(port);
            _forwardedPorts.Add(port);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Adds the forwarded port.
        /// </summary>
        /// <param name="port">The port.</param>
        public void AddForwardedPort(ForwardedPort port)
        {
            //  Ensure that connection is established.
            this.EnsureConnection();

            if (port.Session != null && port.Session != this.Session)
                throw new InvalidOperationException("Forwarded port is already added to a different client.");

            port.Session = this.Session;

            this._forwardedPorts.Add(port);
        }