Ejemplo n.º 1
0
    def getInitiatingCell(self):
        '''Build and return the initiating cell for this ntor fsm - a
        Create2Cell.

        Advance this ntor fsm's state.

        :returns: **oppy.cell.fixedlen.Create2Cell**
        '''
        onion_skin = self._ntor_handshakes[0].createOnionSkin()
        cell = Create2Cell.make(self.circuit_id, hdata=onion_skin)
        self._state = State.EXPECT_CREATED2

        return cell
Ejemplo n.º 2
0
    def getInitiatingCell(self):
        '''Build and return the initiating cell for this ntor fsm - a
        Create2Cell.

        Advance this ntor fsm's state.

        :returns: **oppy.cell.fixedlen.Create2Cell**
        '''
        onion_skin = self._ntor_handshakes[0].createOnionSkin()
        cell = Create2Cell.make(self.circuit_id, hdata=onion_skin)
        self._state = State.EXPECT_CREATED2

        return cell
Ejemplo n.º 3
0
    def test_recvCell_non_backward_cell_fail(self, mock_logging):
        self.circuit._recvRelayCell = mock.Mock()
        self.circuit._pollReadQueue = mock.Mock()
        self.circuit._sendDestroyCell = mock.Mock()
        self.circuit._closeCircuit = mock.Mock()
        cell = Create2Cell.make(ID, hdata=84 * 'a')

        self.circuit._recvCell(cell)

        self.assertEqual(self.circuit._sendDestroyCell.call_count, 1)
        self.assertEqual(self.circuit._closeCircuit.call_count, 1)
        self.assertEqual(self.circuit._recvRelayCell.call_count, 0)
        self.assertEqual(self.circuit._pollReadQueue.call_count, 0)
        self.assertTrue(mock_logging.warning.called)
Ejemplo n.º 4
0
    def test_recvCell_non_backward_cell_fail(self, mock_logging):
        self.circuit._recvRelayCell = mock.Mock()
        self.circuit._pollReadQueue = mock.Mock()
        self.circuit._sendDestroyCell = mock.Mock()
        self.circuit._closeCircuit = mock.Mock()
        cell = Create2Cell.make(ID, hdata=84*'a')

        self.circuit._recvCell(cell)

        self.assertEqual(self.circuit._sendDestroyCell.call_count, 1)
        self.assertEqual(self.circuit._closeCircuit.call_count, 1)
        self.assertEqual(self.circuit._recvRelayCell.call_count, 0)
        self.assertEqual(self.circuit._pollReadQueue.call_count, 0)
        self.assertTrue(mock_logging.warning.called)
Ejemplo n.º 5
0
 def _sendCreate2Cell(self, _, path_node):
     self._hs_state = ntor.NTorState(path_node.microdescriptor)
     onion_skin = ntor.createOnionSkin(self._hs_state)
     create2 = Create2Cell.make(self.circuit_id, hdata=onion_skin)
     self._conn.send(create2)
Ejemplo n.º 6
0
 def _sendCreate2Cell(self, _, path_node):
     self._hs_state = ntor.NTorState(path_node.microdescriptor)
     onion_skin = ntor.createOnionSkin(self._hs_state)
     create2 = Create2Cell.make(self.circuit_id, hdata=onion_skin)
     self._conn.send(create2)