mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
Merge pull request #8966 from yuwata/bus-resolve-fallback-dns
resolve: add bus property for fallback DNS servers
This commit is contained in:
commit
fb58b1ad27
@ -1457,13 +1457,14 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, StatusMode
|
||||
printf(" LLMNR setting: %s\n"
|
||||
"MulticastDNS setting: %s\n"
|
||||
" DNSSEC setting: %s\n"
|
||||
" DNSSEC supported: %s\n"
|
||||
" Current DNS Server: %s\n",
|
||||
" DNSSEC supported: %s\n",
|
||||
strna(link_info.llmnr),
|
||||
strna(link_info.mdns),
|
||||
strna(link_info.dnssec),
|
||||
yes_no(link_info.dnssec_supported),
|
||||
strna(link_info.current_dns));
|
||||
yes_no(link_info.dnssec_supported));
|
||||
|
||||
if (link_info.current_dns)
|
||||
printf(" Current DNS Server: %s\n", link_info.current_dns);
|
||||
|
||||
STRV_FOREACH(i, link_info.dns) {
|
||||
printf(" %s %s\n",
|
||||
@ -1595,6 +1596,7 @@ static int status_global(sd_bus *bus, StatusMode mode, bool *empty_line) {
|
||||
struct global_info {
|
||||
char *current_dns;
|
||||
char **dns;
|
||||
char **fallback_dns;
|
||||
char **domains;
|
||||
char **ntas;
|
||||
const char *llmnr;
|
||||
@ -1605,6 +1607,7 @@ static int status_global(sd_bus *bus, StatusMode mode, bool *empty_line) {
|
||||
|
||||
static const struct bus_properties_map property_map[] = {
|
||||
{ "DNS", "a(iiay)", map_global_dns_servers, offsetof(struct global_info, dns) },
|
||||
{ "FallbackDNS", "a(iiay)", map_global_dns_servers, offsetof(struct global_info, fallback_dns) },
|
||||
{ "CurrentDNSServer", "(iiay)", map_global_current_dns_server, offsetof(struct global_info, current_dns) },
|
||||
{ "Domains", "a(isb)", map_global_domains, offsetof(struct global_info, domains) },
|
||||
{ "DNSSECNegativeTrustAnchors", "as", NULL, offsetof(struct global_info, ntas) },
|
||||
@ -1682,13 +1685,14 @@ static int status_global(sd_bus *bus, StatusMode mode, bool *empty_line) {
|
||||
printf(" LLMNR setting: %s\n"
|
||||
"MulticastDNS setting: %s\n"
|
||||
" DNSSEC setting: %s\n"
|
||||
" DNSSEC supported: %s\n"
|
||||
" Current DNS Server: %s\n",
|
||||
" DNSSEC supported: %s\n",
|
||||
strna(global_info.llmnr),
|
||||
strna(global_info.mdns),
|
||||
strna(global_info.dnssec),
|
||||
yes_no(global_info.dnssec_supported),
|
||||
strna(global_info.current_dns));
|
||||
yes_no(global_info.dnssec_supported));
|
||||
|
||||
if (global_info.current_dns)
|
||||
printf(" Current DNS Server: %s\n", global_info.current_dns);
|
||||
|
||||
STRV_FOREACH(i, global_info.dns) {
|
||||
printf(" %s %s\n",
|
||||
@ -1696,6 +1700,12 @@ static int status_global(sd_bus *bus, StatusMode mode, bool *empty_line) {
|
||||
*i);
|
||||
}
|
||||
|
||||
STRV_FOREACH(i, global_info.fallback_dns) {
|
||||
printf("%s %s\n",
|
||||
i == global_info.fallback_dns ? "Fallback DNS Servers:" : " ",
|
||||
*i);
|
||||
}
|
||||
|
||||
STRV_FOREACH(i, global_info.domains) {
|
||||
printf(" %s %s\n",
|
||||
i == global_info.domains ? "DNS Domain:" : " ",
|
||||
@ -1716,6 +1726,7 @@ static int status_global(sd_bus *bus, StatusMode mode, bool *empty_line) {
|
||||
finish:
|
||||
free(global_info.current_dns);
|
||||
strv_free(global_info.dns);
|
||||
strv_free(global_info.fallback_dns);
|
||||
strv_free(global_info.domains);
|
||||
strv_free(global_info.ntas);
|
||||
|
||||
|
@ -1258,7 +1258,6 @@ static int bus_property_get_dns_servers(
|
||||
sd_bus_error *error) {
|
||||
|
||||
Manager *m = userdata;
|
||||
unsigned c = 0;
|
||||
DnsServer *s;
|
||||
Iterator i;
|
||||
Link *l;
|
||||
@ -1275,8 +1274,6 @@ static int bus_property_get_dns_servers(
|
||||
r = bus_dns_server_append(reply, s, true);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
c++;
|
||||
}
|
||||
|
||||
HASHMAP_FOREACH(l, m->links, i) {
|
||||
@ -1284,16 +1281,35 @@ static int bus_property_get_dns_servers(
|
||||
r = bus_dns_server_append(reply, s, true);
|
||||
if (r < 0)
|
||||
return r;
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
if (c == 0) {
|
||||
LIST_FOREACH(servers, s, m->fallback_dns_servers) {
|
||||
r = bus_dns_server_append(reply, s, true);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
return sd_bus_message_close_container(reply);
|
||||
}
|
||||
|
||||
static int bus_property_get_fallback_dns_servers(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
DnsServer *s, **f = userdata;
|
||||
int r;
|
||||
|
||||
assert(reply);
|
||||
assert(f);
|
||||
|
||||
r = sd_bus_message_open_container(reply, 'a', "(iiay)");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
LIST_FOREACH(servers, s, *f) {
|
||||
r = bus_dns_server_append(reply, s, true);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
return sd_bus_message_close_container(reply);
|
||||
@ -1848,6 +1864,7 @@ static const sd_bus_vtable resolve_vtable[] = {
|
||||
SD_BUS_PROPERTY("LLMNR", "s", bus_property_get_resolve_support, offsetof(Manager, llmnr_support), 0),
|
||||
SD_BUS_PROPERTY("MulticastDNS", "s", bus_property_get_resolve_support, offsetof(Manager, mdns_support), 0),
|
||||
SD_BUS_PROPERTY("DNS", "a(iiay)", bus_property_get_dns_servers, 0, 0),
|
||||
SD_BUS_PROPERTY("FallbackDNS", "a(iiay)", bus_property_get_fallback_dns_servers, offsetof(Manager, fallback_dns_servers), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("CurrentDNSServer", "(iiay)", bus_property_get_current_dns_server, offsetof(Manager, current_dns_server), 0),
|
||||
SD_BUS_PROPERTY("Domains", "a(isb)", bus_property_get_domains, 0, 0),
|
||||
SD_BUS_PROPERTY("TransactionStatistics", "(tt)", bus_property_get_transaction_statistics, 0, 0),
|
||||
|
Loading…
Reference in New Issue
Block a user