phpseclib\System\SSH\Agent::_forward_data PHP Method

_forward_data() public method

Forward data to SSH Agent and return data reply
public _forward_data ( string $data ) : data
$data string
return data from SSH Agent
    function _forward_data($data)
    {
        if ($this->expected_bytes > 0) {
            $this->socket_buffer .= $data;
            $this->expected_bytes -= strlen($data);
        } else {
            $agent_data_bytes = current(unpack('N', $data));
            $current_data_bytes = strlen($data);
            $this->socket_buffer = $data;
            if ($current_data_bytes != $agent_data_bytes + 4) {
                $this->expected_bytes = $agent_data_bytes + 4 - $current_data_bytes;
                return false;
            }
        }
        if (strlen($this->socket_buffer) != fwrite($this->fsock, $this->socket_buffer)) {
            throw new \RuntimeException('Connection closed attempting to forward data to SSH agent');
        }
        $this->socket_buffer = '';
        $this->expected_bytes = 0;
        $agent_reply_bytes = current(unpack('N', fread($this->fsock, 4)));
        $agent_reply_data = fread($this->fsock, $agent_reply_bytes);
        $agent_reply_data = current(unpack('a*', $agent_reply_data));
        return pack('Na*', $agent_reply_bytes, $agent_reply_data);
    }