<option>--type=</option>/<option>--class=</option> is used IDNA translation is turned off and domain
names are processed as specified.</para>
+ <para>If combined with <option>--json=</option> (only supported in combination with
+ <option>--type=</option>) will output the resource record data in a JSON object.</para>
+
<xi:include href="version-info.xml" xpointer="v239"/></listitem>
</varlistentry>
</varlistentry>
<xi:include href="standard-options.xml" xpointer="json" />
-
- <varlistentry>
- <term><option>-j</option></term>
-
- <listitem><para>Short for <option>--json=auto</option></para>
-
- <xi:include href="version-info.xml" xpointer="v252"/></listitem>
- </varlistentry>
-
+ <xi:include href="standard-options.xml" xpointer="j" />
<xi:include href="standard-options.xml" xpointer="no-pager" />
<xi:include href="standard-options.xml" xpointer="help" />
<xi:include href="standard-options.xml" xpointer="version" />
if (!arg_legend)
return;
+ if (!FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF))
+ return;
+
if (flags == 0)
return;
assert(name);
+ if (!FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF))
+ return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Use --json=pretty with --type=A or --type=AAAA to acquire address record information in JSON format.");
+
log_debug("Resolving %s (family %s, interface %s).", name, af_to_name(arg_family) ?: "*", isempty(arg_ifname) ? "*" : arg_ifname);
r = bus_message_new_method_call(bus, &req, bus_resolve_mgr, "ResolveHostname");
assert(IN_SET(family, AF_INET, AF_INET6));
assert(address);
+ if (!FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF))
+ return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Use --json=pretty with --type= to acquire resource record information in JSON format.");
+
if (ifindex <= 0)
ifindex = arg_ifindex;
_cleanup_(dns_resource_record_unrefp) DnsResourceRecord *rr = NULL;
int r;
+ assert(d || l == 0);
+
r = dns_resource_record_new_from_raw(&rr, d, l);
if (r < 0)
return log_error_errno(r, "Failed to parse RR: %m");
- if (arg_raw == RAW_PAYLOAD) {
+ if (!FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF)) {
+ _cleanup_(json_variant_unrefp) JsonVariant *j = NULL;
+ r = dns_resource_record_to_json(rr, &j);
+ if (r < 0)
+ return log_error_errno(r, "Failed to convert RR to JSON: %m");
+
+ r = json_variant_dump(j, arg_json_format_flags, NULL, NULL);
+ if (r < 0)
+ return r;
+
+ } else if (arg_raw == RAW_PAYLOAD) {
void *data;
ssize_t k;
static int verb_service(int argc, char **argv, void *userdata) {
sd_bus *bus = userdata;
+ if (!FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF))
+ return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Use --json=pretty with --type= to acquire resource record information in JSON format.");
+
if (argc == 2)
return resolve_service(bus, NULL, NULL, argv[1]);
else if (argc == 3)
sd_bus *bus = userdata;
int q, r = 0;
+ if (!FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF))
+ return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Use --json=pretty with --type= to acquire resource record information in JSON format.");
+
STRV_FOREACH(p, argv + 1) {
q = resolve_openpgp(bus, *p);
if (q < 0)
const char *family = "tcp";
int q, r = 0;
+ if (!FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF))
+ return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Use --json=pretty with --type= to acquire resource record information in JSON format.");
+
if (service_family_is_valid(argv[1])) {
family = argv[1];
args++;
run resolvectl reset-statistics --json=short
+test "$(resolvectl --json=short query -t AAAA localhost)" == '{"key":{"class":1,"type":28,"name":"localhost"},"address":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]}'
+test "$(resolvectl --json=short query -t A localhost)" == '{"key":{"class":1,"type":1,"name":"localhost"},"address":[127,0,0,1]}'
+
# Check if resolved exits cleanly.
restart_resolved