aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2016-05-02 10:15:33 +0200
committerAndreas Schneider <asn@cryptomilk.org>2016-05-03 10:58:36 +0200
commita3688ada1a6145429837e5768ced6c2933a53e35 (patch)
treeb75e1dde461bad271eca2e4c6b21917c9b268963
parent219d0bba42ad95227035728c5cb37b9f51e6a8fa (diff)
downloadlibssh-a3688ada1a6145429837e5768ced6c2933a53e35.tar.gz
libssh-a3688ada1a6145429837e5768ced6c2933a53e35.tar.xz
libssh-a3688ada1a6145429837e5768ced6c2933a53e35.zip
client: If SSHv1 is disabled send the banner immediately
This saves a round-trip with SSHv2 connecting to the server. See RFC 4253 section 5.2 (New Client, Old Server). Thanks to Yang Yubo <yang@yangyubo.com> for the suggestion. Signed-off-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit 1da5c94b44ea2610450aacda24d9789859942926)
-rw-r--r--src/client.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/client.c b/src/client.c
index 74f2112e..3eb7c61b 100644
--- a/src/client.c
+++ b/src/client.c
@@ -386,7 +386,13 @@ static void ssh_client_connection_callback(ssh_session session){
switch(session->session_state){
case SSH_SESSION_STATE_NONE:
case SSH_SESSION_STATE_CONNECTING:
+ break;
case SSH_SESSION_STATE_SOCKET_CONNECTED:
+ /* If SSHv1 is disabled, we can send the banner immedietly */
+ if (session->opts.ssh1 == 0) {
+ ssh_set_fd_towrite(session);
+ ssh_send_banner(session, 0);
+ }
break;
case SSH_SESSION_STATE_BANNER_RECEIVED:
if (session->serverbanner == NULL) {
@@ -432,7 +438,9 @@ static void ssh_client_connection_callback(ssh_session session){
#endif
ssh_packet_set_default_callbacks(session);
session->session_state=SSH_SESSION_STATE_INITIAL_KEX;
- ssh_send_banner(session, 0);
+ if (session->opts.ssh1 == 1) {
+ ssh_send_banner(session, 0);
+ }
set_status(session, 0.5f);
break;
case SSH_SESSION_STATE_INITIAL_KEX: