AwsInspector\Ssh\Connection::tunnel PHP Method

tunnel() public method

Interactive connection
public tunnel ( $configuration )
    public function tunnel($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');
        }
        if (empty($remoteHost)) {
            throw new \InvalidArgumentException('Invalid remote host');
        }
        if (!ctype_digit($remotePort)) {
            throw new \InvalidArgumentException('Invalid remote port');
        }
        $descriptorSpec = [0 => STDIN, 1 => STDOUT, 2 => STDERR];
        $pipes = [];
        $command = $this->__toString() . ' -L ' . $configuration . ' -N';
        $process = proc_open($command, $descriptorSpec, $pipes);
        if (is_resource($process)) {
            proc_close($process);
        }
    }