Configure EDNS behavior. *edns*, an ``int``, is the EDNS level to use. Specifying ``None``, ``False``, or ``-1`` means "do not use EDNS", and in this case the other parameters are ignored. Specifying ``True`` is equivalent to specifying 0, i.e. "use EDNS0". *ednsf
(
self,
edns: int | bool | None = 0,
ednsflags: int = 0,
payload: int = DEFAULT_EDNS_PAYLOAD,
request_payload: int | None = None,
options: List[dns.edns.Option] | None = None,
pad: int = 0,
)
| 790 | return dns.rrset.from_rdata(dns.name.root, int(flags), opt) |
| 791 | |
| 792 | def use_edns( |
| 793 | self, |
| 794 | edns: int | bool | None = 0, |
| 795 | ednsflags: int = 0, |
| 796 | payload: int = DEFAULT_EDNS_PAYLOAD, |
| 797 | request_payload: int | None = None, |
| 798 | options: List[dns.edns.Option] | None = None, |
| 799 | pad: int = 0, |
| 800 | ) -> None: |
| 801 | """Configure EDNS behavior. |
| 802 | |
| 803 | *edns*, an ``int``, is the EDNS level to use. Specifying ``None``, ``False``, |
| 804 | or ``-1`` means "do not use EDNS", and in this case the other parameters are |
| 805 | ignored. Specifying ``True`` is equivalent to specifying 0, i.e. "use EDNS0". |
| 806 | |
| 807 | *ednsflags*, an ``int``, the EDNS flag values. |
| 808 | |
| 809 | *payload*, an ``int``, is the EDNS sender's payload field, which is the maximum |
| 810 | size of UDP datagram the sender can handle. I.e. how big a response to this |
| 811 | message can be. |
| 812 | |
| 813 | *request_payload*, an ``int``, is the EDNS payload size to use when sending this |
| 814 | message. If not specified, defaults to the value of *payload*. |
| 815 | |
| 816 | *options*, a list of ``dns.edns.Option`` objects or ``None``, the EDNS options. |
| 817 | |
| 818 | *pad*, a non-negative ``int``. If 0, the default, do not pad; otherwise add |
| 819 | padding bytes to make the message size a multiple of *pad*. Note that if |
| 820 | padding is non-zero, an EDNS PADDING option will always be added to the |
| 821 | message. |
| 822 | """ |
| 823 | |
| 824 | if edns is None or edns is False: |
| 825 | edns = -1 |
| 826 | elif edns is True: |
| 827 | edns = 0 |
| 828 | if edns < 0: |
| 829 | self.opt = None |
| 830 | self.request_payload = 0 |
| 831 | else: |
| 832 | # make sure the EDNS version in ednsflags agrees with edns |
| 833 | ednsflags &= 0xFF00FFFF |
| 834 | ednsflags |= edns << 16 |
| 835 | if options is None: |
| 836 | options = [] |
| 837 | self.opt = self._make_opt(ednsflags, payload, options) |
| 838 | if request_payload is None: |
| 839 | request_payload = payload |
| 840 | self.request_payload = request_payload |
| 841 | if pad < 0: |
| 842 | raise ValueError("pad must be non-negative") |
| 843 | self.pad = pad |
| 844 | |
| 845 | @property |
| 846 | def edns(self) -> int: |