mirror of https://github.com/BOINC/boinc.git
boinccmd: accept [IPv6_addr]:port as --hostname arg
This commit is contained in:
parent
7a84dabbbc
commit
ac242a2feb
|
@ -127,7 +127,7 @@ int main(int argc, char** argv) {
|
|||
MESSAGES messages;
|
||||
NOTICES notices;
|
||||
char passwd_buf[256], hostname_buf[256], *hostname=0;
|
||||
char* passwd = passwd_buf, *p;
|
||||
char* passwd = passwd_buf, *p, *q;
|
||||
bool unix_domain = false;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -154,11 +154,33 @@ int main(int argc, char** argv) {
|
|||
if (!strcmp(argv[i], "--host")) {
|
||||
if (++i == argc) usage();
|
||||
strlcpy(hostname_buf, argv[i], sizeof(hostname_buf));
|
||||
hostname = hostname_buf;
|
||||
p = strchr(hostname, ':');
|
||||
|
||||
// see if port is specified.
|
||||
// syntax:
|
||||
// [a:b:..]:port for IPv6
|
||||
// a.b.c.d:port for IPv4
|
||||
// hostname:port for domain names
|
||||
//
|
||||
p = strchr(hostname_buf, '[');
|
||||
if (p) {
|
||||
port = atoi(p+1);
|
||||
*p=0;
|
||||
q = strchr(p, ']');
|
||||
if (!q) {
|
||||
fprintf(stderr, "invalid IPv6 syntax: %s\n", hostname_buf);
|
||||
exit(1);
|
||||
}
|
||||
hostname = p+1;
|
||||
*q = 0;
|
||||
port = atoi(q+1);
|
||||
} else {
|
||||
hostname = hostname_buf;
|
||||
p = strchr(hostname, ':');
|
||||
if (p) {
|
||||
q = strchr(p+1, ':');
|
||||
if (!q) {
|
||||
port = atoi(p+1);
|
||||
*p=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ int RPC_CLIENT::get_ip_addr(const char* host, int port) {
|
|||
//printf("trying port %d\n", htons(addr.sin_port));
|
||||
int retval;
|
||||
if (host) {
|
||||
retval = resolve_hostname(host, addr);
|
||||
retval = resolve_hostname_or_ip_addr(host, addr);
|
||||
if (retval) {
|
||||
return ERR_GETHOSTBYNAME;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue