Ejemplo n.º 1
0
Archivo: v3.py Proyecto: CivBase/oppy
    def _processNetInfo(self, cell):
        '''Process an incoming cell when we're in V3State.EXPECT_NETINFO
        state.

        Build and return our own NetInfoCell to write to this connection
        and finish off the handshake on success.

        .. note:: See tor-spec Section 4.5 for more details.

        :returns:  oppy.cell.NetInfoCell
        '''
        # XXX do we need to verify that the address the OR claims in its
        #     NetInfo cell matches what we think it is or do anything else
        #     with the remote address(es) we get?
        # XXX is there a better way we should be figuring out our external
        #     IP address?
        V3FSM._verifyCellCmd(cell.header.cmd, NETINFO_CMD)
        self._state = V3State.DONE
        return NetInfoCell.make(cell.header.circ_id,
                                other_or_address=cell.this_or_addresses[0],
                                this_or_addresses=[cell.other_or_address])
Ejemplo n.º 2
0
 def _sendNetInfoCell(self, addresses):
     my_address, other_or_address = addresses
     cell = NetInfoCell.make(0, other_or_address=other_or_address,
                             this_or_addresses=[my_address])
     self.transport.write(cell.getBytes())
Ejemplo n.º 3
0
    def test_processCertsCell_wrong_cell_type(self):
        cell = NetInfoCell.make(0, '127.0.0.1', ['127.0.0.1'])

        self.assertRaises(TypeError,
                          self.cbt._processCertsCell,
                          cell)
Ejemplo n.º 4
0
 def test_processNetInfoCell(self):
     cell = NetInfoCell.make(0, '127.0.0.1', ['127.0.0.2'])
     
     self.assertEqual(self.cbt._processNetInfoCell(cell),
                      ('127.0.0.1', '127.0.0.2'))
Ejemplo n.º 5
0
 def _sendNetInfoCell(self, addresses):
     my_address, other_or_address = addresses
     cell = NetInfoCell.make(0,
                             other_or_address=other_or_address,
                             this_or_addresses=[my_address])
     self.transport.write(cell.getBytes())