From 8705f4b31e1f3cc890dc5ac232620ea5feba4b3e Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 6 Oct 2018 11:41:15 -0500 Subject: [PATCH] SSH2: update ping method to work with exceptions --- phpseclib/Net/SSH2.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index ef02ebd1..2f405ba9 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -3300,19 +3300,18 @@ class SSH2 $packet_size ); - if (!@$this->send_binary_packet($packet)) { + try { + $this->send_binary_packet($packet); + + $this->channel_status[NET_SSH2_CHANNEL_KEEP_ALIVE] = NET_SSH2_MSG_CHANNEL_OPEN; + + $response = $this->get_channel_packet(NET_SSH2_CHANNEL_KEEP_ALIVE); + } catch (\RuntimeException $e) { return $this->reconnect(); } - $this->channel_status[NET_SSH2_CHANNEL_KEEP_ALIVE] = NET_SSH2_MSG_CHANNEL_OPEN; - - $response = @$this->get_channel_packet(NET_SSH2_CHANNEL_KEEP_ALIVE); - if ($response !== false) { - $this->close_channel(NET_SSH2_CHANNEL_KEEP_ALIVE); - return true; - } - - return $this->reconnect(); + $this->close_channel(NET_SSH2_CHANNEL_KEEP_ALIVE); + return true; } /**