diff --git a/src/AwsInspector/Ssh/Connection.php b/src/AwsInspector/Ssh/Connection.php index 622a16b..430cd17 100644 --- a/src/AwsInspector/Ssh/Connection.php +++ b/src/AwsInspector/Ssh/Connection.php @@ -146,7 +146,18 @@ public function connect() */ public function tunnel($configuration) { - list($localPort, $remoteHost, $remotePort) = explode(':', $configuration); + $configurationData = explode(':', $configuration); + + if (count($configurationData) == 4) { + list($localIp, $localPort, $remoteHost, $remotePort) = $configurationData; + + if (empty($localIp)) { + throw new \InvalidArgumentException('Invalid local host'); + } + } else { + list($localPort, $remoteHost, $remotePort) = $configurationData; + } + if (!ctype_digit($localPort)) { throw new \InvalidArgumentException('Invalid local port'); } @@ -206,4 +217,4 @@ public function getJumpHost() return $this->jumpHost; } -} \ No newline at end of file +}