Hello,
I were pointed to [1] article on fosstodon discussion and I have noticed
it does accept only numeric type value. But on other places we accept
also nicer symbolic names. I have made a simple change to allow also
type name to be specified. Not sure about wording in man page, if you
could find clearer notation, I would be glad.
Happy new year!
1.
https://forum.openwrt.org/t/resolving-query-type-65-to-local-address-for-ios-clients-in-dnsmasq/179504
Cheers,
Petr
--
Petr Menšík
Software Engineer, RHEL
Red Hat, https://www.redhat.com/
PGP: DFCF908DB7C87E8E529925BC4931CA5B6C9FC5CB
From 490ae2290b243fe0f7c6bf963d96039a2d1c17ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemen...@redhat.com>
Date: Mon, 25 Dec 2023 22:40:33 +0100
Subject: [PATCH] Allow specification of dns-rr record type by name
Use existing database of record types and support them instead of just
integer numbers for --dns-rr. Allows specification like
dns-rr=example.net,SVCB. Unknown record types are refused, but original
style dns-rr=example.net,64 still works.
Update man page to match document it.
---
man/dnsmasq.8 | 10 +++++-----
src/option.c | 14 ++++++++++++--
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/man/dnsmasq.8 b/man/dnsmasq.8
index 1b5ebda..b055795 100644
--- a/man/dnsmasq.8
+++ b/man/dnsmasq.8
@@ -731,11 +731,11 @@ If the time-to-live is given, it overrides the default, which is zero
or the value of \fB--local-ttl\fP. The value is a positive integer and gives
the time-to-live in seconds.
.TP
-.B --dns-rr=<name>,<RR-number>,[<hex data>]
-Return an arbitrary DNS Resource Record. The number is the type of the
-record (which is always in the C_IN class). The value of the record is
-given by the hex data, which may be of the form 01:23:45 or 01 23 45 or
-012345 or any mixture of these.
+.B --dns-rr=<name>,<RR-type>,[<hex data>]
+Return an arbitrary DNS Resource Record. The RR-type is the type of the
+record in an integer or a name form (which is always in the C_IN class).
+The value of the record is given by the hex data, which may be of
+the form 01:23:45 or 01 23 45 or 012345 or any mixture of these.
.TP
.B --interface-name=<name>,<interface>[/4|/6]
Return DNS records associating the name with the address(es) of
diff --git a/src/option.c b/src/option.c
index 3eeda18..520b212 100644
--- a/src/option.c
+++ b/src/option.c
@@ -766,6 +766,16 @@ static int atoi_check16(char *a, int *res)
return 1;
}
+static int atoi_or_rrtype(char *a, int *res)
+{
+ if (!atoi_check16(a, res))
+ {
+ *res = rrtype(a);
+ return (*res != 0);
+ }
+ return 1;
+}
+
#ifdef HAVE_DNSSEC
static int atoi_check8(char *a, int *res)
{
@@ -3508,7 +3518,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
else
{
comma = split(arg);
- if (!atoi_check(arg, &type) && (type = rrtype(arg)) == 0)
+ if (!atoi_or_rrtype(arg, &type))
ret_err(_("bad RR type"));
}
@@ -4992,7 +5002,7 @@ err:
new = opt_malloc(sizeof(struct txt_record));
new->name = NULL;
- if (!atoi_check(comma, &class) ||
+ if (!comma || !atoi_or_rrtype(comma, &class) ||
!(new->name = canonicalise_opt(arg)) ||
(data && (len = parse_hex(data, (unsigned char *)data, -1, NULL, NULL)) == -1U))
{
--
2.43.0
_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss