Skip to content

Commit 57eec5f

Browse files
committed
fixup!
1 parent 7f8816c commit 57eec5f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/_cffi_src/build_cares.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@
139139
...
140140
} ares_dns_rcode_t;
141141
142+
/* DNS Header flags */
143+
typedef enum {
144+
ARES_FLAG_QR = 1 << 0,
145+
ARES_FLAG_AA = 1 << 1,
146+
ARES_FLAG_TC = 1 << 2,
147+
ARES_FLAG_RD = 1 << 3,
148+
ARES_FLAG_RA = 1 << 4,
149+
ARES_FLAG_AD = 1 << 5,
150+
ARES_FLAG_CD = 1 << 6,
151+
...
152+
} ares_dns_flags_t;
153+
142154
/* DNS RR keys for accessing record fields */
143155
typedef enum {
144156
/* A record */

src/pycares/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,9 @@ def __init__(self,
434434
# Initialize _channel to None first to ensure __del__ doesn't fail
435435
self._channel = None
436436

437+
# Store flags for later use (default is 0 if not specified)
438+
self._flags = flags if flags is not None else 0
439+
437440
channel = _ffi.new("ares_channel *")
438441
options = _ffi.new("struct ares_options *")
439442
optmask = 0
@@ -730,11 +733,14 @@ def search(self, name, query_type, callback, query_class=None):
730733
raise ValueError('invalid query class specified')
731734

732735
# Create a DNS record for the search query
736+
# Set RD (Recursion Desired) flag unless ARES_FLAG_NORECURSE is set
737+
dns_flags = 0 if (self._flags & _lib.ARES_FLAG_NORECURSE) else _lib.ARES_FLAG_RD
738+
733739
dnsrec_p = _ffi.new("ares_dns_record_t **")
734740
status = _lib.ares_dns_record_create(
735741
dnsrec_p,
736742
0, # id (will be set by c-ares)
737-
0, # flags
743+
dns_flags, # flags - include RD for recursive queries
738744
_lib.ARES_OPCODE_QUERY,
739745
_lib.ARES_RCODE_NOERROR
740746
)

0 commit comments

Comments
 (0)