Commit Graph

536 Commits

Author SHA1 Message Date
Gert Driesen 0da2c06ded Small doc fixes, fix warnings and prepare for beta 2. 2014-11-22 12:27:11 +00:00
Gert Driesen 2659048654 Prepare for 2014.4.6-beta2. 2014-11-22 11:58:42 +00:00
Gert Driesen 007112d2b4 Rephrase buffer size change. 2014-11-22 11:57:05 +00:00
Gert Driesen 52b97729e2 Reduce default buffer size as workaround for SSH servers issues. 2014-11-22 11:17:18 +00:00
Gert Driesen c45bc8f1a4 Document fix for issue #1844. 2014-11-22 11:02:09 +00:00
Gert Driesen a780cb9a56 Document fix for issue #1877. 2014-11-22 10:56:44 +00:00
Gert Driesen b1c90ea758 Document fixes for issues #2029 and #2400. 2014-11-22 10:29:50 +00:00
Gert Driesen c4b120e6a3 Fix Silverlight and WP compile. 2014-11-22 10:25:50 +00:00
Gert Driesen 3d3d76fe52 Introduce TrySendMessage method on Session which will not let SocketException or SshException exception bubble up, but instead return false in this case.
Use TrySendMessage to send SSH_MSG_DISCONNECT, SSH_MSG_CHANNEL_EOF, SSH_MSG_CHANNEL_CLOSE and SSH_MSG_IGNORE messages to avoid throwing exceptions while closing/disposing or sending keep-alive messages.
Avoid sending multiple keep-alive messages concurrently for the same client.
Fixed regression in multi-factor authentication.
2014-11-20 18:56:35 +00:00
Gert Driesen 39a75ef91c Remove redundant this qualifier. 2014-11-19 14:56:16 +00:00
Gert Driesen 9da65f35a4 Remove redundant this qualifier. 2014-11-18 18:08:25 +00:00
Gert Driesen 188c313818 When disposing a client, (re)use Disconnect() to signal that we're disconnecting - hereby avoiding exceptions getting thrown for a waithandle timeout (waiting for a SSH response message). Note: may need to revisit this again to only avoid throwing exception waiting for a response on a disconnect or channel close/eof message. 2014-11-17 20:30:47 +00:00
Gert Driesen 26548e248a No longer disconnect the SSH session whenever a timeout occurs waiting for a WaitHande to become signaled. 2014-11-17 20:09:35 +00:00
Gert Driesen e1abcd2a08 Remove redundant this qualifier. 2014-11-16 21:04:34 +00:00
Gert Driesen ab1a43aedc Document fix for issue 2010. 2014-11-16 15:05:38 +00:00
Gert Driesen 8b05e92d41 Avoid sending data on a socket that is closed (by ourselves). 2014-11-16 15:02:51 +00:00
Gert Driesen d80ce73c56 Do not set DontLinger socket option. 2014-11-16 14:55:16 +00:00
Gert Driesen 8e2ea99dd9 Increase backlog to 5. 2014-11-16 14:52:59 +00:00
Gert Driesen 861e291f44 Sync projects with .NET 4.x projects. 2014-11-16 14:36:53 +00:00
Gert Driesen b7d3a4fe5d Remove placeholder. 2014-11-16 10:39:51 +00:00
Gert Driesen cb430bb013 Add to TFS. 2014-11-16 10:29:51 +00:00
Gert Driesen f629f05081 Document fix for issue 1382. 2014-11-16 10:15:39 +00:00
Gert Driesen 6e11950d60 Added internal ctor to ScpClient that takes an IServiceFactory to allow for mocking of PipeStream.
Added missing read (and check) of the returncode after a file copy command. Fixes issue #1382.
2014-11-16 10:12:12 +00:00
Gert Driesen 063338f524 Use Socket.Shutdown(SocketShutdown.Send) to signal FIN to remove party, and allow socket to close in a clean way. 2014-11-13 19:09:47 +00:00
Gert Driesen 4dbbf7514f Create output buffer after padding to ensure its length matches the padded length.
Fixes issue #2547.
2014-11-12 20:45:43 +00:00
Gert Driesen 80a193ec50 Removed redundant this qualified.
Changed accessibility of _blockSize to private.
2014-11-12 18:58:46 +00:00
Gert Driesen 62ab1d4114 Document fix for issue #2013. 2014-11-12 18:49:44 +00:00
Gert Driesen 71664e2c93 Channel:
* Only send SSH_MSG_CHANNEL_EOF message to remote party when we haven't received a SSH_MSG_CHANNEL_EOF or SSH_MSG_CHANNEL_CLOSE message from the remote party.
* Move logic for sending SSH_MSG_CHANNEL_EOF message from derived classes and client classes into Channel.Close(bool) method.
* Move initialization to ctor.

ChannelSession:
* Avoid leaking session semaphores.

SftpFileStream:
* Modify CanRead, CanWrite and CanSeek to return false when the stream is disposed.
* Modify other public members to throw ObjectDisposedException when the stream is disposed or the SFTP session is no longer open.
* Modify Dispose to only flush the write buffer and/or close the SFTP file handle when the SFTP session is open.
* No longer flush write buffer or close SFTP file handle in finalizer. Fixes issue #2013.

Session:
* Remove CreateClientChannel<T> and CreateServerChannel<T> methods; use specific constructors of channels instead.

SftpClient:
* BufferSize was not used for AppendText(String, Encoding) and Create(String) overloads.

SubsystemSession:
* Added IsOpen property.
* Throw ObjectDisposedException in all public members - except for IsOpen - when the session is disposed.
* Throw InvalidOperationException in all public members - except for Connect and IsOpen - when the session is not open.
* Modify Disconnect to release managed resources that are linked to the connected session.
* Modify Dispose to use Disconnect to managed resources that are linked to the connected session.

Unit tests:
* Added large set of tests for changes listed above.
* Tests for which the code was automatically, and that are not yet correctly implemented, are now marked as Ignore.
* Tests that require a (specifically configured) running SSH server are now marked with test category "integration".
2014-11-12 18:48:20 +00:00
Gert Driesen 3a5edc9077 Added missing checks for availability of session. 2014-11-11 12:53:03 +00:00
Gert Driesen 7ca7bae4e8 Added basic tests for Pipestream. 2014-11-11 11:14:15 +00:00
Gert Driesen 4733eff54e Implemented basic tests for SemaphoreLight. 2014-11-11 10:24:01 +00:00
Gert Driesen 04d4c18a13 Remove redundant this qualifiers.
Change SubsystemSession._operationTimeout into a read-only OperationTimeout property.
FlagsAttribute is used as a bit field, so mark it as such.
2014-11-09 08:55:37 +00:00
Gert Driesen 9366658bc4 Added simple ServiceFactory to allow unit testing of SshClient.
When disposing SshClient, make sure to stop forwarded ports before the session is closed.
2014-11-08 19:43:22 +00:00
Gert Driesen 4d7c01572a Remove redundant this qualifiers. 2014-11-08 19:16:03 +00:00
Gert Driesen e35b79f4eb Remove redundant this qualifier. 2014-11-08 09:12:31 +00:00
Gert Driesen 0cb4194d50 Remove redundant this qualifier. 2014-11-08 09:10:56 +00:00
Gert Driesen 174f388ad2 Improve robustness of client channel by not letting an exception - that occurs while processing events signaled by session - bubble up to the session where this would cause the message loop to interrupt, and hence the SSH client would be disconnected. 2014-11-08 08:57:39 +00:00
Gert Driesen 73e2b2517c Remove redundan this qualified. 2014-11-08 08:54:35 +00:00
Gert Driesen c1f8e06c25 Immediately exit Bind when the client socket has shut down.
The SSH_MSG_CHANNEL_EOF message is now only sent from Close(bool), and we now only ever wait for an SSH_MSG_CHANNEL_CLOSE message once the client has shut down.
The SSH_MSG_CHANNEL_EOF which is sent by the server is now only used to interrupt the blocking receive on the client socket, and close it.
2014-11-07 22:20:06 +00:00
Gert Driesen 45f99561b4 Channel:
* Improve robustness of channels by not letting an exception - that occurs while processing events signaled by session - up to session where this would cause the message loop to interrupt, and hence the SSH client would be disconnected.
  Instead, exceptions that are thrown during processing of session events are now signaled using a new Exception event.
* Renamed RequestSuccessed event to RequestSucceeded, fixing a typo.

ChannelDirectTcpip:
* Interrupt blocking receive when forwarded port is closing allowing for a clean close of the channel.
* Send SSH_MSG_CHANNEL_EOF to server when client quits sending data.

ChannelForwardedTcpip:
* Interrupt blocking receive when forwarded port is closing or when an error occurs in the session allowing for a clean close of the channel.

ForwardedPortDynamic:
* When stopping the port, signal all channels that the port is closing and wait for the channels to close.
* Modify Start() and Stop() to throw ObjectDisposedException when instance is disposed.
* Modify Dispose() to also interrupt blocking receive and wait for the channels to close.
* Fixed IPv6 support for SOCKS5.
* Signal exceptions in channels using the Exception event on the forwarded port.

ForwardedPortLocal:
* When stopping the port, signal all channels that the port is closing and wait for the channels to close.
* Modify Start() and Stop() to throw ObjectDisposedException when instance is disposed.
* Modify Dispose() to also interrupt blocking receive and wait for the channels to close.
* Signal exceptions in channels using the Exception event on the forwarded port.

ForwardedPortRemote:
* When stopping the port, cancel the tcpip-forward, interrupt pending channels and for the channels to close.
* Modify Start() and Stop() to throw ObjectDisposedException when instance is disposed.
* Modify Dispose() to also cancel the tcpip-forward, interrupt pending channels and for the channels to close.
* Signal exceptions in channels using the Exception event on the forwarded port.

Overall:
* Add huge set of unit tests for channels and forwarded ports.
2014-11-07 19:07:14 +00:00
Gert Driesen a0bc7f61a5 Document fix for issue #1558. 2014-10-26 19:10:28 +00:00
Gert Driesen 00ed218425 Added internal IForwardPort interface to allow mocking of forwarded ports.
Added internal IChannelDirectTcpip and IChannelForwardedTcpip interfaces.
Extended ISession and IConnection interface to allow for unit tests of ChannelDirectTcpip.

Modified ChannelDirectTcpip to interrupt blocking receive when the ForwardedPort is closed.
Shutdown send of socket when EOF is received.
Close the socket when unhandled exception occurs in session message loop, and when server terminates connection using SSH_MSG_DISCONNECT message.
Fixes issue #1558.

When stopping ForwardedLocalPort, block until all channels have been closed or until Connection.Timeout has elapsed.
2014-10-26 19:06:58 +00:00
Gert Driesen ba309fc716 Modify accessiblity of Authenticate to internal, and modify IsAuthenticated depending on the outcome of the authentication. 2014-10-26 07:51:41 +00:00
Gert Driesen 3bfd1fbef1 Include signing key in source download.
Fixes issue #2455.
2014-10-19 15:09:49 +00:00
Gert Driesen 542b2f80ba Added SftpClientTest.Connect.cs to test project for .NET 3.5.
Do not use TPL to allow tests to work on .NET 3.5.
2014-10-19 14:40:46 +00:00
Gert Driesen 6423b7e0a0 Make internal methods available to castle proxies. 2014-10-19 14:38:41 +00:00
Gert Driesen 446354ed6b Document fix for issue #1845. 2014-10-19 14:25:15 +00:00
Gert Driesen 23a178f7aa Document exceptions for ConnectionInfo constructors.
Improve exception messages for argument checks.
Only perform null argument check for hosts. Fixes issue #1845.
2014-10-19 14:17:56 +00:00
Gert Driesen acaae44836 Fix exception documentation for BaseClient.Connect() and Session.Connect().
Added SftpPathNotFoundException to doc for SftpClient.Get(String) and SftpClient.GetAttributes(String).
Do not throw exception in Session.Disconnect() and Session.Dispose() when socket is not connected.
Fixes issue #2148.
2014-10-19 11:14:50 +00:00
Gert Driesen 8678d087d9 Modify ShellStream.ReadLine() to take into account multi-byte character.
Fixes issue #2190.
Modify ShellStream.Write(string) to write nothing when text is null.
Added unit tests.
2014-10-18 17:40:58 +00:00