コード例 #1
0
    def handle_relay(self, bundle: TransactionBundle,
                     relay_message_in: RelayForwardMessage,
                     relay_message_out: RelayReplyMessage):
        """
        Handle the options for each relay message pair.

        :param bundle: The transaction bundle
        :param relay_message_in: The incoming relay message
        :param relay_message_out: Thr outgoing relay message
        """
        # See if the relay message contains an ERO
        ero = relay_message_in.get_option_of_type(EchoRequestOption)
        if not ero:
            # Nothing to do
            return

        for option_type in ero.requested_options:
            # Don't do anything if the outgoing relay message already has this one
            if any(option.option_type == option_type
                   for option in relay_message_out.options):
                continue

            # Get the incoming options of the requested type
            incoming_options = [
                option for option in relay_message_in.options
                if option.option_type == option_type
            ]

            for option in incoming_options:
                # Make sure this option can go into this type of response
                if not relay_message_out.may_contain(option):
                    return

                # And append them to the outgoing message if possible
                relay_message_out.options.append(option)
コード例 #2
0
    def handle_relay(self, bundle: TransactionBundle,
                     relay_message_in: RelayForwardMessage, relay_message_out: RelayReplyMessage):
        """
        Copy the options for each relay message pair.

        :param bundle: The transaction bundle
        :param relay_message_in: The incoming relay message
        :param relay_message_out: Thr outgoing relay message
        """
        # Make sure this option can go into this type of response
        if not relay_message_out.may_contain(self.option_class):
            return

        # Make sure this option isn't present and then copy those from the request
        relay_message_out.options = [existing_option for existing_option in relay_message_out.options
                                     if not isinstance(existing_option, self.option_class)]
        relay_message_out.options[:0] = relay_message_in.get_options_of_type(self.option_class)
コード例 #3
0
    def handle_relay(self, bundle: TransactionBundle,
                     relay_message_in: RelayForwardMessage,
                     relay_message_out: RelayReplyMessage):
        """
        Copy the options for each relay message pair.

        :param bundle: The transaction bundle
        :param relay_message_in: The incoming relay message
        :param relay_message_out: Thr outgoing relay message
        """
        # Make sure this option can go into this type of response
        if not relay_message_out.may_contain(self.option_class):
            return

        # Make sure this option isn't present and then copy those from the request
        relay_message_out.options = [
            existing_option for existing_option in relay_message_out.options
            if not isinstance(existing_option, self.option_class)
        ]
        relay_message_out.options[:0] = relay_message_in.get_options_of_type(
            self.option_class)