You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2020/08/23 15:04:05 UTC

[mina-sshd] branch master updated: [SSHD-1059] Do not send heartbeat if KEX state not DONE

This is an automated email from the ASF dual-hosted git repository.

lgoldstein pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git


The following commit(s) were added to refs/heads/master by this push:
     new 61785ae  [SSHD-1059] Do not send heartbeat if KEX state not DONE
61785ae is described below

commit 61785ae6c37cc390172b26f19b6f2e9147a71763
Author: Lyor Goldstein <lg...@apache.org>
AuthorDate: Tue Aug 18 11:18:43 2020 +0300

    [SSHD-1059] Do not send heartbeat if KEX state not DONE
---
 CHANGES.md                                                 |  5 +++--
 .../common/session/helpers/AbstractConnectionService.java  | 14 +++++++++++++-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 095744a..7470f94 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -42,6 +42,7 @@ or `-key-file` command line option.
 * [SSHD-1047](https://issues.apache.org/jira/browse/SSHD-1047) Support for SSH jumps.
 * [SSHD-1048](https://issues.apache.org/jira/browse/SSHD-1048) Wrap instead of rethrow IOException in Future.
 * [SSHD-1050](https://issues.apache.org/jira/browse/SSHD-1050) Fixed race condition in AuthFuture if exception caught before authentication started.
-* [SSHD-1056](https://issues.apache.org/jira/browse/SSHD-1005) Added support for SCP remote-to-remote directory transfer - including '-3' option of SCP command CLI.
-* [SSHD-1058](https://issues.apache.org/jira/browse/SSHD-1057) Added capability to select a ShellFactory based on the current session + use it for "WinSCP"
+* [SSHD-1056](https://issues.apache.org/jira/browse/SSHD-1056) Added support for SCP remote-to-remote directory transfer - including '-3' option of SCP command CLI.
+* [SSHD-1057](https://issues.apache.org/jira/browse/SSHD-1057) Added capability to select a ShellFactory based on the current session + use it for "WinSCP"
 * [SSHD-1058](https://issues.apache.org/jira/browse/SSHD-1058) Improve exception logging strategy.
+* [SSHD-1059](https://issues.apache.org/jira/browse/SSHD-1059) Do not send heartbeat if KEX state not DONE
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
index d57e582..7a9eb07 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
@@ -56,6 +56,7 @@ import org.apache.sshd.common.forward.PortForwardingEventListener;
 import org.apache.sshd.common.forward.PortForwardingEventListenerManager;
 import org.apache.sshd.common.io.AbstractIoWriteFuture;
 import org.apache.sshd.common.io.IoWriteFuture;
+import org.apache.sshd.common.kex.KexState;
 import org.apache.sshd.common.session.ConnectionService;
 import org.apache.sshd.common.session.ReservedSessionMessagesHandler;
 import org.apache.sshd.common.session.Session;
@@ -204,7 +205,7 @@ public abstract class AbstractConnectionService
 
     /**
      * Sends a heartbeat message/packet
-     * 
+     *
      * @return {@code true} if heartbeat successfully sent
      */
     protected boolean sendHeartBeat() {
@@ -221,6 +222,17 @@ public abstract class AbstractConnectionService
             return false;
         }
 
+        // SSHD-1059
+        KexState kexState = session.getKexState();
+        if ((heartbeatType != HeartbeatType.NONE)
+                && (kexState != KexState.DONE)) {
+            if (traceEnabled) {
+                log.trace("sendHeartbeat({}) heartbeat type={}, interval={} - skip due to KEX state={}",
+                        session, heartbeatType, interval, kexState);
+            }
+            return false;
+        }
+
         try {
             switch (heartbeatType) {
                 case NONE: