@@ -90,6 +90,7 @@ class DNSIncoming:
9090 'now' ,
9191 'scope_id' ,
9292 'source' ,
93+ 'has_qu_question' ,
9394 )
9495
9596 def __init__ (
@@ -117,6 +118,7 @@ def __init__(
117118 self .now = now or current_time_millis ()
118119 self .source = source
119120 self .scope_id = scope_id
121+ self .has_qu_question = False
120122 try :
121123 self ._initial_parse ()
122124 except DECODE_EXCEPTIONS :
@@ -135,16 +137,6 @@ def is_response(self) -> bool:
135137 """Returns true if this is a response."""
136138 return (self .flags & _FLAGS_QR_MASK ) == _FLAGS_QR_RESPONSE
137139
138- def has_qu_question (self ) -> bool :
139- """Returns true if any question is a QU question."""
140- if not self .num_questions :
141- return False
142- for question in self .questions :
143- # QU questions use the same bit as unique
144- if question .unique :
145- return True
146- return False
147-
148140 @property
149141 def truncated (self ) -> bool :
150142 """Returns true if this is a truncated."""
@@ -223,6 +215,8 @@ def _read_questions(self) -> None:
223215 type_ , class_ = UNPACK_HH (self .data , self .offset )
224216 self .offset += 4
225217 question = DNSQuestion (name , type_ , class_ )
218+ if not self .has_qu_question and question .unique :
219+ self .has_qu_question = True
226220 self .questions .append (question )
227221
228222 def _read_character_string (self ) -> bytes :
0 commit comments