From 7606f81279fc9cc4622963c85d5dbaea6a1d9156 Mon Sep 17 00:00:00 2001 From: Moritz Kornher Date: Wed, 14 Jun 2017 11:56:50 +1200 Subject: [PATCH] Add new mode READ_NEXT to only ready the next packet from the channel. --- phpseclib/Net/SSH2.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 7a5e88a4..0e2333af 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -122,6 +122,10 @@ define('NET_SSH2_LOG_REALTIME', 3); * Dumps the content real-time to a file */ define('NET_SSH2_LOG_REALTIME_FILE', 4); +/** + * Make sure that the log never gets larger than this + */ +define('NET_SSH2_LOG_MAX_SIZE', 1024 * 1024); /**#@-*/ /**#@+ @@ -137,9 +141,9 @@ define('NET_SSH2_READ_SIMPLE', 1); */ define('NET_SSH2_READ_REGEX', 2); /** - * Make sure that the log never gets larger than this + * Returns when a string matching the regular expression $expect is found */ -define('NET_SSH2_LOG_MAX_SIZE', 1024 * 1024); +define('NET_SSH2_READ_NEXT', 3); /**#@-*/ /** @@ -2914,6 +2918,10 @@ class Net_SSH2 $channel = $this->_get_interactive_channel(); + if ($mode == NET_SSH2_READ_NEXT) { + return $this->_get_channel_packet($channel); + } + $match = $expect; while (true) { if ($mode == NET_SSH2_READ_REGEX) {