mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 03:45:07 -05:00
client: don't override hostname with -4 or -6 after -h
This commit is contained in:
26
client.c
26
client.c
@@ -2729,9 +2729,9 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
char *line;
|
char *line;
|
||||||
const char *progname = argv[0];
|
const char *progname = argv[0];
|
||||||
const char *hostname = "127.0.0.1";
|
const char *hostname = NULL;
|
||||||
const char *conf_file = DEFAULT_CONF_FILE;
|
const char *conf_file = DEFAULT_CONF_FILE;
|
||||||
int quit = 0, ret = 1, multi = 0, auto_auth = 0, short_timeout = 1;
|
int quit = 0, ret = 1, multi = 0, auto_auth = 0, family = IPADDR_UNSPEC;
|
||||||
int port = DEFAULT_CANDM_PORT;
|
int port = DEFAULT_CANDM_PORT;
|
||||||
|
|
||||||
/* Parse command line options */
|
/* Parse command line options */
|
||||||
@@ -2741,7 +2741,6 @@ main(int argc, char **argv)
|
|||||||
if (*argv) {
|
if (*argv) {
|
||||||
hostname = *argv;
|
hostname = *argv;
|
||||||
}
|
}
|
||||||
short_timeout = 0;
|
|
||||||
} else if (!strcmp(*argv, "-p")) {
|
} else if (!strcmp(*argv, "-p")) {
|
||||||
++argv, --argc;
|
++argv, --argc;
|
||||||
if (*argv) {
|
if (*argv) {
|
||||||
@@ -2759,11 +2758,9 @@ main(int argc, char **argv)
|
|||||||
} else if (!strcmp(*argv, "-n")) {
|
} else if (!strcmp(*argv, "-n")) {
|
||||||
no_dns = 1;
|
no_dns = 1;
|
||||||
} else if (!strcmp(*argv, "-4")) {
|
} else if (!strcmp(*argv, "-4")) {
|
||||||
DNS_SetAddressFamily(IPADDR_INET4);
|
family = IPADDR_INET4;
|
||||||
hostname = "127.0.0.1";
|
|
||||||
} else if (!strcmp(*argv, "-6")) {
|
} else if (!strcmp(*argv, "-6")) {
|
||||||
DNS_SetAddressFamily(IPADDR_INET6);
|
family = IPADDR_INET6;
|
||||||
hostname = "::1";
|
|
||||||
} else if (!strcmp("-v", *argv) || !strcmp("--version",*argv)) {
|
} else if (!strcmp("-v", *argv) || !strcmp("--version",*argv)) {
|
||||||
printf("chronyc (chrony) version %s\n", CHRONY_VERSION);
|
printf("chronyc (chrony) version %s\n", CHRONY_VERSION);
|
||||||
exit(0);
|
exit(0);
|
||||||
@@ -2775,12 +2772,6 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (short_timeout) {
|
|
||||||
#ifdef FEAT_ASYNCDNS
|
|
||||||
initial_timeout /= 10;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isatty(0) && isatty(1) && isatty(2)) {
|
if (isatty(0) && isatty(1) && isatty(2)) {
|
||||||
on_terminal = 1;
|
on_terminal = 1;
|
||||||
}
|
}
|
||||||
@@ -2796,6 +2787,15 @@ main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DNS_SetAddressFamily(family);
|
||||||
|
|
||||||
|
if (!hostname) {
|
||||||
|
hostname = family == IPADDR_INET6 ? "::1" : "127.0.0.1";
|
||||||
|
#ifdef FEAT_ASYNCDNS
|
||||||
|
initial_timeout /= 10;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
open_io(hostname, port);
|
open_io(hostname, port);
|
||||||
|
|
||||||
if (auto_auth) {
|
if (auto_auth) {
|
||||||
|
|||||||
Reference in New Issue
Block a user