예제 #1
0
    def test_bad_option_length(self):
        with self.assertRaisesRegex(ValueError,
                                    'must end with a 0-length label'):
            DomainSearchListOption.parse(
                bytes.fromhex('0018000c') + b'\x08steffann\x02nl\x00')

        with self.assertRaisesRegex(ValueError, 'exceeds available buffer'):
            DomainSearchListOption.parse(
                bytes.fromhex('0018000e') + b'\x08steffann\x02nl\x00\x01')
예제 #2
0
    def combine(
        self, existing_options: Iterable[DomainSearchListOption]
    ) -> DomainSearchListOption:
        """
        Combine multiple options into one.

        :param existing_options: The existing options to include domain names from
        :return: The combined option
        """
        domains = []

        # Add from existing options first
        for option in existing_options:
            for domain in option.search_list:
                if domain not in domains:
                    domains.append(domain)

        # Then add our own
        for domain in self.option.dns_servers:
            if domain not in domains:
                domains.append(domain)

        # And return a new option with the combined addresses
        return DomainSearchListOption(search_list=domains)
예제 #3
0
    def test_bad_option_length(self):
        with self.assertRaisesRegex(ValueError, 'must end with a 0-length label'):
            DomainSearchListOption.parse(bytes.fromhex('0018000c') + b'\x08steffann\x02nl\x00')

        with self.assertRaisesRegex(ValueError, 'exceeds available buffer'):
            DomainSearchListOption.parse(bytes.fromhex('0018000e') + b'\x08steffann\x02nl\x00\x01')
예제 #4
0
파일: dns.py 프로젝트: mndfcked/dhcpkit
    def __init__(self, search_list: [str]):
        option = DomainSearchListOption(search_list=search_list)
        option.validate()

        super().__init__(option)
예제 #5
0
 def setUp(self):
     self.option_bytes = bytes.fromhex(
         '0018000d') + b'\x08steffann\x02nl\x00'
     self.option_object = DomainSearchListOption(
         search_list=['steffann.nl'])
     self.parse_option()
예제 #6
0
    def __init__(self, search_list: Iterable[str], always_send: bool = False):
        option = DomainSearchListOption(search_list=search_list)
        option.validate()

        super().__init__(option, always_send=always_send)
예제 #7
0
    def __init__(self, search_list: Iterable[str], always_send: bool = False):
        option = DomainSearchListOption(search_list=search_list)
        option.validate()

        super().__init__(option, always_send=always_send)