Esempio n. 1
0
 def setUp(self):
     self.option_bytes = bytes.fromhex('00160020'
                                       '20010db8000000000000000000000001'
                                       '20010db8000000000000000000000002')
     self.option_object = SIPServersAddressListOption(sip_servers=[IPv6Address('2001:db8::1'),
                                                                   IPv6Address('2001:db8::2')])
     self.parse_option()
Esempio n. 2
0
    def __init__(self,
                 sip_servers: Iterable[IPv6Address],
                 always_send: bool = False):
        option = SIPServersAddressListOption(sip_servers=sip_servers)
        option.validate()

        super().__init__(option, always_send=always_send)
Esempio n. 3
0
    def combine(
        self, existing_options: Iterable[SIPServersAddressListOption]
    ) -> SIPServersAddressListOption:
        """
        Combine multiple options into one.

        :param existing_options: The existing options to include NTP servers from
        :return: The combined option
        """
        sip_servers = []

        # Add from existing options first
        for option in existing_options:
            for sip_server in option.sip_servers:
                if sip_server not in sip_servers:
                    sip_servers.append(sip_server)

        # Then add our own
        for sip_server in self.option.sip_servers:
            if sip_server not in sip_servers:
                sip_servers.append(sip_server)

        # And return a new option with the combined addresses
        return SIPServersAddressListOption(sip_servers=sip_servers)