Esempio n. 1
0
 def test_get_source_port(self):
     self.assertEqual(util.get_source_port("SOURCE_ADDR="
                                           "255.255.255.255:0"), 0)
     self.assertEqual(util.get_source_port("SOURCE_ADDR=1.1.1.1:1"), 1)
     self.assertEqual(util.get_source_port("SOURCE_ADDR=1.1.1.1:"
                                           "65535"), 65535)
     self.assertIsNone(util.get_source_port(""))
Esempio n. 2
0
 def test_get_source_port(self):
     self.assertEqual(
         util.get_source_port("SOURCE_ADDR="
                              "255.255.255.255:0"), 0)
     self.assertEqual(util.get_source_port("SOURCE_ADDR=1.1.1.1:1"), 1)
     self.assertEqual(util.get_source_port("SOURCE_ADDR=1.1.1.1:"
                                           "65535"), 65535)
Esempio n. 3
0
    def new_stream(self, stream_event):
        """
        Create a function which is later used to attach a stream to a circuit.

        The attaching cannot be done right now as we do not know the stream's
        desired circuit ID at this point.  So we set up all we can at this
        point and wait for the attaching to be done in queue_reader().
        """

        if stream_event.status not in self.our_stream_events:
            return

        # Keep track of how many streams are already finished.

        if stream_event.status in [StreamStatus.CLOSED, StreamStatus.FAILED,
                                   StreamStatus.DETACHED]:
            self.finished_streams += 1
            return

        port = util.get_source_port(str(stream_event))

        if not port:
            logger.warning("Couldn't extract source port from stream " \
                           "event: %s" % str(stream_event))
            return

        logger.debug("Adding attacher for new stream %s." % stream_event.id)

        self.prepare_attach(port, stream_id=stream_event.id)
    def new_stream(self, stream_event):
        """
        Create a function which is later used to attach a stream to a circuit.

        The attaching cannot be done right now as we do not know the stream's
        desired circuit ID at this point.  So we set up all we can at this
        point and wait for the attaching to be done in queue_reader().
        """

        if stream_event.status not in [StreamStatus.NEW,
                                       StreamStatus.NEWRESOLVE]:
            return

        port = util.get_source_port(str(stream_event))
        if not port:
            logger.warning("Couldn't extract source port from stream "
                           "event: %s" % str(stream_event))
            return

        logger.debug("Adding attacher for new stream %s." % stream_event.id)
        self.attacher.prepare(port, stream_id=stream_event.id)
        self.check_finished()
Esempio n. 5
0
    def new_stream(self, stream_event):
        """
        Create a function which is later used to attach a stream to a circuit.

        The attaching cannot be done right now as we do not know the stream's
        desired circuit ID at this point.  So we set up all we can at this
        point and wait for the attaching to be done in queue_reader().
        """

        if stream_event.status not in [StreamStatus.NEW,
                                       StreamStatus.NEWRESOLVE]:
            return

        port = util.get_source_port(str(stream_event))
        if not port:
            log.warning("Couldn't extract source port from stream "
                        "event: %s" % str(stream_event))
            return

        log.debug("Adding attacher for new stream %s." % stream_event.id)
        self.attacher.prepare(port, stream_id=stream_event.id)
        self.check_finished()