Closed lifenjoiner closed 1 month ago
There's a trick to do that, specify any other flag, and it unsets all default flags. The obvious choice would be -f stayopen
since its meaningless for an app that terminates immediately after completion of the query.
The flags for adig aren't great right now, we really need to mimic 'dig' more, but that's a fairly low priority item since most people are interested in the library not the utilities.
Thanks for improving the whole program!
There's a trick to do that, specify any other flag, and it unsets all default flags. The obvious choice would be
-f stayopen
Not working yet.
My workaround:
diff --git a/src/lib/ares_init.c b/src/lib/ares_init.c
index 9166be77..446381e3 100644
--- a/src/lib/ares_init.c
+++ b/src/lib/ares_init.c
@@ -130,7 +130,11 @@ static ares_status_t init_by_defaults(ares_channel_t *channel)
ares_llist_t *sconfig = NULL;
/* Enable EDNS by default */
+#ifdef DO_NOT_USE_EDNS_BY_DEFAULT
+ if (channel->optmask & ARES_OPT_FLAGS) {
+#else
if (!(channel->optmask & ARES_OPT_FLAGS)) {
+#endif
channel->flags = ARES_FLAG_EDNS;
}
if (channel->ednspsz == 0) {
diff --git a/src/tools/adig.c b/src/tools/adig.c
index b0832c92..4492efdd 100644
--- a/src/tools/adig.c
+++ b/src/tools/adig.c
@@ -963,13 +963,15 @@ static ares_status_t enqueue_query(ares_channel_t *channel,
goto done;
}
- status = ares_dns_record_rr_add(&rr, dnsrec, ARES_SECTION_ADDITIONAL, "",
- ARES_REC_TYPE_OPT, ARES_CLASS_IN, 0);
- if (status != ARES_SUCCESS) {
- goto done;
+ if (config->optmask & ARES_OPT_FLAGS) {
+ status = ares_dns_record_rr_add(&rr, dnsrec, ARES_SECTION_ADDITIONAL, "",
+ ARES_REC_TYPE_OPT, ARES_CLASS_IN, 0);
+ if (status != ARES_SUCCESS) {
+ goto done;
+ }
+ ares_dns_rr_set_u16(rr, ARES_RR_OPT_UDP_SIZE, 1280);
+ ares_dns_rr_set_u8(rr, ARES_RR_OPT_VERSION, 0);
}
- ares_dns_rr_set_u16(rr, ARES_RR_OPT_UDP_SIZE, 1280);
- ares_dns_rr_set_u8(rr, ARES_RR_OPT_VERSION, 0);
status = ares_dns_write(dnsrec, &buf, &buf_len);
if (status != ARES_SUCCESS) {
mingw32-make -f Makefile.m32 demos --eval CARES_CFLAG_EXTRAS=-DDO_NOT_USE_EDNS_BY_DEFAULT -B
odd, thought it was the case, i'll have to look at the code ... though I don't want to, usually when I do that I end up refactoring the whole dang thing
Perfectionists always have strength 💪
@lifenjoiner ugh, you made me go and do something #890
adig
had been included in git-for-windows, BTW.
Many thanks!
Currently, it uses EDNS by default: https://github.com/c-ares/c-ares/blame/8b2f5e01ebc39f50438911f610dfd4edc2bc7b26/src/lib/ares_init.c#L132-L135
It results in unable to use
adig
for testing purpose without OPT record. Flagedns
for-f
staled.