Example #1
0
    def test_recvRelayCell_sendme_cell(self, mock_decrypt):
        cell = RelaySendMeCell.make(ID, ID)
        mock_decrypt.return_value = (cell, 2)
        self.circuit._processRelaySendMeCell = mock.Mock()

        self.circuit._recvRelayCell(cell)

        self.circuit._processRelaySendMeCell.assert_called_once_with(cell, 2)
Example #2
0
    def test_recvRelayCell_sendme_cell(self, mock_decrypt):
        cell = RelaySendMeCell.make(ID, ID)
        mock_decrypt.return_value = (cell, 2)
        self.circuit._processRelaySendMeCell = mock.Mock()

        self.circuit._recvRelayCell(cell)

        self.circuit._processRelaySendMeCell.assert_called_once_with(cell, 2)
Example #3
0
    def sendStreamSendMe(self, stream_id):
        '''Send a stream-level RelaySendMe cell with its stream_id equal to
        *stream_id*.

        Construct the send me cell, encrypt it, and immediately write it to
        this circuit's connection.

        :param int stream_id: stream_id to use in the RelaySendMeCell
        '''
        cell = RelaySendMeCell.make(self.circuit_id, stream_id=stream_id)
        enc = crypto.encryptCellToTarget(cell, self._crypt_path)
        self.writeCell(enc)
Example #4
0
    def sendStreamSendMe(self, stream_id):
        '''Send a stream-level RelaySendMe cell with its stream_id equal to
        *stream_id*.

        Construct the send me cell, encrypt it, and immediately write it to
        this circuit's connection.

        :param int stream_id: stream_id to use in the RelaySendMeCell
        '''
        cell = RelaySendMeCell.make(self.circuit_id, stream_id=stream_id)
        enc = crypto.encryptCellToTarget(cell, self._crypt_path)
        self.writeCell(enc)
Example #5
0
 def _decDeliverWindow(self):
     '''Decrement this circuit's deliver window.
     
     Called when we deliver an incoming RelayDataCell's payload to
     a stream. If the delivery window is below the default threshold, send
     a RelaySendMeCell.
     '''
     self._deliver_window -= 1
     if self._deliver_window <= SENDME_THRESHOLD:
         cell = RelaySendMeCell.make(self.circuit_id)
         enc = crypto.encryptCellToTarget(cell, self._crypt_path)
         self.writeCell(enc)
         self._deliver_window += WINDOW_SIZE
Example #6
0
 def _decDeliverWindow(self):
     '''Decrement this circuit's deliver window.
     
     Called when we deliver an incoming RelayDataCell's payload to
     a stream. If the delivery window is below the default threshold, send
     a RelaySendMeCell.
     '''
     self._deliver_window -= 1
     if self._deliver_window <= SENDME_THRESHOLD:
         cell = RelaySendMeCell.make(self.circuit_id)
         enc = crypto.encryptCellToTarget(cell, self._crypt_path)
         self.writeCell(enc)
         self._deliver_window += WINDOW_SIZE
Example #7
0
    def sendStreamSendMe(self, stream):
        '''Send a stream-level RelaySendMe cell with its stream_id equal to
        *stream_id*.

        Construct the send me cell, encrypt it, and immediately write it to
        this circuit's connection.

        :param int stream_id: stream_id to use in the RelaySendMeCell
        '''
        cell = RelaySendMeCell.make(self.circuit_id,
                                    stream_id=stream.stream_id)
        self._encryptAndSendCell(cell)

        msg = ("Circuit {} sent a RelaySendMeCell for stream {}.".format(
            self.circuit_id, stream.stream_id))
        logging.debug(msg)
Example #8
0
    def sendStreamSendMe(self, stream):
        '''Send a stream-level RelaySendMe cell with its stream_id equal to
        *stream_id*.

        Construct the send me cell, encrypt it, and immediately write it to
        this circuit's connection.

        :param int stream_id: stream_id to use in the RelaySendMeCell
        '''
        cell = RelaySendMeCell.make(self.circuit_id,
                                    stream_id=stream.stream_id)
        self._encryptAndSendCell(cell)

        msg = ("Circuit {} sent a RelaySendMeCell for stream {}."
               .format(self.circuit_id, stream.stream_id))
        logging.debug(msg)
Example #9
0
    def _decDeliverWindow(self):
        '''Decrement this circuit's deliver window.

        Called when we deliver an incoming RelayDataCell's payload to
        a stream. If the delivery window is below the default threshold, send
        a RelaySendMeCell.
        '''
        self._deliver_window -= 1
        if self._deliver_window <= SENDME_THRESHOLD:
            cell = RelaySendMeCell.make(self.circuit_id)
            self._encryptAndSendCell(cell)
            self._deliver_window += WINDOW_SIZE

            msg = ("Circuit {}'s delivery window dropped to {}. The circuit "
                   "sent a circuit-level RelaySendMeCell and incremented "
                   "its delivery window to {}.".format(
                       self.circuit_id, self._deliver_window - WINDOW_SIZE,
                       self._deliver_window))
            logging.debug(msg)
Example #10
0
    def _decDeliverWindow(self):
        '''Decrement this circuit's deliver window.

        Called when we deliver an incoming RelayDataCell's payload to
        a stream. If the delivery window is below the default threshold, send
        a RelaySendMeCell.
        '''
        self._deliver_window -= 1
        if self._deliver_window <= SENDME_THRESHOLD:
            cell = RelaySendMeCell.make(self.circuit_id)
            self._encryptAndSendCell(cell)
            self._deliver_window += WINDOW_SIZE

            msg = ("Circuit {}'s delivery window dropped to {}. The circuit "
                   "sent a circuit-level RelaySendMeCell and incremented "
                   "its delivery window to {}."
                   .format(self.circuit_id, self._deliver_window - WINDOW_SIZE,
                           self._deliver_window))
            logging.debug(msg)