public function getRemoteIp(CommandExecutor $executor) { $matches['ip'] = '127.0.0.1'; $decorator = $executor->getDecorator(); if ($decorator instanceof SSHDecorator) { $verbose = $decorator->getVerbose(); $decorator->setVerbose(true); try { $executor->executeCommand('exit'); } catch (ProcessFailedException $e) { } $output = $executor->getLastErrorOutput(); $decorator->setVerbose($verbose); preg_match('/^debug1: Connecting to [\\w\\d.-]+ \\[(?<ip>[\\d.]+)\\] port \\d+/m', $output, $matches); } return $matches['ip']; }
public function getLastError() { return $this->executor->getLastErrorOutput(); }