Add dns command to configure DNS resolving in chronyc
This commit is contained in:
parent
49bd8cfab3
commit
00a77fca52
2 changed files with 55 additions and 0 deletions
30
chrony.texi
30
chrony.texi
|
@ -2544,6 +2544,8 @@ This option allows the user to specify the UDP port number which the
|
|||
target @code{chronyd} is using for its command & monitoring connections.
|
||||
This defaults to the compiled-in default; there would rarely be a need
|
||||
to change this.
|
||||
@item -n
|
||||
This option disables resolving IP addresses to hostnames.
|
||||
@item -4
|
||||
With this option hostnames will be resolved only to IPv4 addresses.
|
||||
@item -6
|
||||
|
@ -2584,6 +2586,7 @@ Only the following commands can be used @emph{without} providing a
|
|||
password:
|
||||
|
||||
@itemize @bullet
|
||||
@item @code{dns}
|
||||
@item @code{exit}
|
||||
@item @code{help}
|
||||
@item @code{password}
|
||||
|
@ -2623,6 +2626,7 @@ interface.
|
|||
* delete command:: Remove an NTP server or peer
|
||||
* deny command :: Denying NTP client access
|
||||
* deny all command:: Denying NTP client access
|
||||
* dns command:: Configure how are hostnames and IP addresses resolved
|
||||
* dump command:: Dump measurement histories to files
|
||||
* exit command:: Exit from chronyc
|
||||
* help command:: Generate help summary
|
||||
|
@ -2983,6 +2987,32 @@ deny
|
|||
The effect of the allow command is identical to the @code{deny all}
|
||||
directive in the configuration file (@pxref{deny directive}).
|
||||
@c }}}
|
||||
@c {{{ dns
|
||||
@node dns command
|
||||
@subsubsection dns
|
||||
The @code{dns} command configures how are hostnames and IP addresses resolved in
|
||||
@code{chronyc}. IP addresses can be resolved to hostnames when printing results
|
||||
of @code{sources}, @code{sourcestats}, @code{tracking} and @code{clients}
|
||||
commands. Hostnames are resolved in commands that take an address as argument.
|
||||
|
||||
There are five forms of the command:
|
||||
|
||||
@table @code
|
||||
@item dns -n
|
||||
Disables resolving IP addresses to hostnames. Raw IP addresses will be
|
||||
displayed.
|
||||
@item dns +n
|
||||
Enables resolving IP addresses to hostnames. This is the default unless
|
||||
@code{chronyc} was started with @code{-n} option.
|
||||
@item dns -4
|
||||
Resolves hostnames only to IPv4 addresses.
|
||||
@item dns -6
|
||||
Resolves hostnames only to IPv6 addresses.
|
||||
@item dns -46
|
||||
Resolves hostnames to both address families. This is the default unless
|
||||
@code{chronyc} was started with @code{-4} or @code{-6} option.
|
||||
@end table
|
||||
@c }}}
|
||||
@c {{{ dump
|
||||
@node dump command
|
||||
@subsubsection dump
|
||||
|
|
25
client.c
25
client.c
|
@ -2238,6 +2238,28 @@ process_cmd_activity(const char *line)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
static int
|
||||
process_cmd_dns(const char *line)
|
||||
{
|
||||
if (!strncmp(line, "-46", 3)) {
|
||||
DNS_SetAddressFamily(IPADDR_UNSPEC);
|
||||
} else if (!strncmp(line, "-4", 2)) {
|
||||
DNS_SetAddressFamily(IPADDR_INET4);
|
||||
} else if (!strncmp(line, "-6", 2)) {
|
||||
DNS_SetAddressFamily(IPADDR_INET6);
|
||||
} else if (!strncmp(line, "-n", 2)) {
|
||||
no_dns = 1;
|
||||
} else if (!strncmp(line, "+n", 2)) {
|
||||
no_dns = 0;
|
||||
} else {
|
||||
fprintf(stderr, "Unrecognized dns command\n");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
static int
|
||||
process_line(char *line, int *quit)
|
||||
{
|
||||
|
@ -2351,6 +2373,9 @@ process_line(char *line, int *quit)
|
|||
} else if (!strncmp(p, "activity", 8)) {
|
||||
ret = process_cmd_activity(p+8);
|
||||
do_normal_submit = 0;
|
||||
} else if (!strncmp(p, "dns ", 4)) {
|
||||
ret = process_cmd_dns(p+4);
|
||||
do_normal_submit = 0;
|
||||
} else if (!strncmp(p, "help", 4)) {
|
||||
do_normal_submit = 0;
|
||||
give_help();
|
||||
|
|
Loading…
Reference in a new issue