Ejemplo n.º 1
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)
Ejemplo n.º 2
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()
Ejemplo n.º 3
0
    def test_bad_option_length(self):
        with self.assertRaisesRegex(ValueError, 'length must be a multiple of 16'):
            SIPServersAddressListOption.parse(bytes.fromhex('0016000f20010db8000000000000000000000001'))

        with self.assertRaisesRegex(ValueError, 'longer than the available buffer'):
            SIPServersAddressListOption.parse(bytes.fromhex('0016001120010db8000000000000000000000001'))

        with self.assertRaisesRegex(ValueError, 'length must be a multiple of 16'):
            SIPServersAddressListOption.parse(bytes.fromhex('0016001120010db800000000000000000000000100'))
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
    def __init__(self, sip_servers: [IPv6Address]):
        option = SIPServersAddressListOption(sip_servers=sip_servers)
        option.validate()

        super().__init__(option)