Ejemplo n.º 1
0
    def test_recvRelayCell_data_cell(self, mock_decrypt):
        cell = RelayDataCell.make(ID, ID, 'a')
        mock_decrypt.return_value = (cell, 2)
        self.circuit._processRelayDataCell = mock.Mock()

        self.circuit._recvRelayCell(cell)

        self.circuit._processRelayDataCell.assert_called_once_with(cell, 2)
Ejemplo n.º 2
0
    def test_recvRelayCell_data_cell(self, mock_decrypt):
        cell = RelayDataCell.make(ID, ID, 'a')
        mock_decrypt.return_value = (cell, 2)
        self.circuit._processRelayDataCell = mock.Mock()

        self.circuit._recvRelayCell(cell)

        self.circuit._processRelayDataCell.assert_called_once_with(cell, 2)
Ejemplo n.º 3
0
    def _writeData(self, data_stream_id_tuple):
        '''Write data to this circuit's connection.

        Do the following:

            1. Package this data (with appropriate stream_id) into a
               RelayDataCell.
            2. Encrypt this cell.
            3. Write this cell to this circuit's connection.
            4. Decrement this circuit's packaging window (if we can't
               package anymore data, enter state CState.BUFFERING, otherwise
               begin polling from _write_queue again).

        :param tuple, str, int data_stream_id_tuple: tuple of (data, stream_id)
            to package into a RelayData cell
        '''
        data, stream_id = data_stream_id_tuple
        cell = RelayDataCell.make(self.circuit_id, stream_id, data)
        self._encryptAndSendCell(cell)
        self._decPackageWindow()
Ejemplo n.º 4
0
    def _writeData(self, data_stream_id_tuple):
        '''Write data to this circuit's connection.

        Do the following:

            1. Package this data (with appropriate stream_id) into a
               RelayDataCell.
            2. Encrypt this cell.
            3. Write this cell to this circuit's connection.
            4. Decrement this circuit's packaging window (if we can't
               package anymore data, enter state CState.BUFFERING, otherwise
               begin polling from _write_queue again).

        :param tuple, str, int data_stream_id_tuple: tuple of (data, stream_id)
            to package into a RelayData cell
        '''
        data, stream_id = data_stream_id_tuple
        cell = RelayDataCell.make(self.circuit_id, stream_id, data)
        self._encryptAndSendCell(cell)
        self._decPackageWindow()
Ejemplo n.º 5
0
    def _writeData(self, data_stream_id_tuple):
        '''Write data to this circuit's connection.

        Do the following:

            1. Package this data (with appropriate stream_id) into a
               RelayDataCell.
            2. Encrypt this cell.
            3. Write this cell to this circuit's connection.
            4. Decrement this circuit's packaging window (if we can't
               package anymore data, enter state CState.BUFFERING, otherwise
               begin polling from _write_queue again).

        :param tuple, str, int data_stream_id_tuple: tuple of (data, stream_id)
            to package into a RelayData cell
        '''
        data, stream_id = data_stream_id_tuple
        assert len(data) <= MAX_RPAYLOAD_LEN
        cell = RelayDataCell.make(self.circuit_id, stream_id, data)
        enc = crypto.encryptCellToTarget(cell, self._crypt_path)
        self.writeCell(enc)
        self._decPackageWindow()
Ejemplo n.º 6
0
    def _writeData(self, data_stream_id_tuple):
        '''Write data to this circuit's connection.

        Do the following:

            1. Package this data (with appropriate stream_id) into a
               RelayDataCell.
            2. Encrypt this cell.
            3. Write this cell to this circuit's connection.
            4. Decrement this circuit's packaging window (if we can't
               package anymore data, enter state CState.BUFFERING, otherwise
               begin polling from _write_queue again).

        :param tuple, str, int data_stream_id_tuple: tuple of (data, stream_id)
            to package into a RelayData cell
        '''
        data, stream_id = data_stream_id_tuple
        assert len(data) <= MAX_RPAYLOAD_LEN
        cell = RelayDataCell.make(self.circuit_id, stream_id, data)
        enc = crypto.encryptCellToTarget(cell, self._crypt_path)
        self.writeCell(enc)
        self._decPackageWindow()