From 70fe7790852ca25a7ac65d76e1129d003c0fcba1 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 27 Oct 2016 09:09:13 +0200 Subject: cli: add DNS information to overview output Example: $ nmcli [...] DNS configuration: servers: 10.0.0.1 domains: foobar.com interface: tun0 type: vpn servers: 192.168.10.1 domains: home interface: ens3 servers: fd01:abcd::21 interface: ens3 --- clients/cli/general.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/clients/cli/general.c b/clients/cli/general.c index 0f1d556986..90e934a490 100644 --- a/clients/cli/general.c +++ b/clients/cli/general.c @@ -1190,6 +1190,7 @@ do_overview (NmCli *nmc, int argc, char **argv) const GPtrArray *p; NMActiveConnection *ac; NmcTermColor color; + NMDnsEntry *dns; char *tmp; int i; @@ -1245,6 +1246,39 @@ do_overview (NmCli *nmc, int argc, char **argv) } g_free (devices); + p = nm_client_get_dns_configuration (nmc->client); + for (i = 0; i < p->len; i++) { + const char * const *strv; + + dns = p->pdata[i]; + strv = nm_dns_entry_get_nameservers (dns); + if (!strv || !strv[0]) { + /* Invalid entry */ + continue; + } + + if (i == 0) + g_print ("DNS configuration:\n"); + + tmp = g_strjoinv (" ", (char **) strv); + g_print ("\tservers: %s\n", tmp); + g_free (tmp); + + strv = nm_dns_entry_get_domains (dns); + if (strv && strv[0]) { + tmp = g_strjoinv (" ", (char **) strv); + g_print ("\tdomains: %s\n", tmp); + g_free (tmp); + } + + if (nm_dns_entry_get_interface (dns)) + g_print ("\tinterface: %s\n", nm_dns_entry_get_interface (dns)); + + if (nm_dns_entry_get_vpn (dns)) + g_print ("\ttype: vpn\n"); + g_print ("\n"); + } + g_print (_("Use \"nmcli device show\" to get complete information about known devices and\n" "\"nmcli connection show\" to get an overview on active connection profiles.\n" "\n" -- cgit v1.2.1