public void Open() { _client.Connect(); _forwardedPort = new ForwardedPortLocal(LocalHost, LocalPort, _mySqlHost, (uint)_mySqlPort); _client.AddForwardedPort(_forwardedPort); _forwardedPort.Start(); _connection.Open(); }
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; }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
private static void DetachForwardedPort(ForwardedPort port) { port.Session = null; }
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; }
/// <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); }
/// <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); }