summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradshea <adshea@01de4be4-8c4a-0410-9132-4925637da917>2009-01-22 05:33:58 +0000
committeradshea <adshea@01de4be4-8c4a-0410-9132-4925637da917>2009-01-22 05:33:58 +0000
commit179d06c956d2814dca6f97289d045aa6a254224a (patch)
treed3ecc54f4726240c8268ffb0f3508f9725c8e106
parent1de4d5d63580f4d2df21f3bebe1b180d679baea0 (diff)
downloaddistcc-179d06c956d2814dca6f97289d045aa6a254224a.tar.gz
IPv6 patch for Zeroconf and and IPv6 literals in hosts file.
* Still needs configure flag masking for IPv6 literals * Needs some fix for zeroconf hosts that have both and IPv6 and IPv4 address git-svn-id: http://distcc.googlecode.com/svn/trunk@650 01de4be4-8c4a-0410-9132-4925637da917
-rw-r--r--man/distcc.16
-rw-r--r--src/hosts.c17
-rw-r--r--src/zeroconf.c6
3 files changed, 24 insertions, 5 deletions
diff --git a/man/distcc.1 b/man/distcc.1
index db34539..a1bacd8 100644
--- a/man/distcc.1
+++ b/man/distcc.1
@@ -480,7 +480,7 @@ The syntax is
SSH_HOST = [USER]@HOSTID[/LIMIT][:COMMAND][OPTIONS]
TCP_HOST = HOSTID[:PORT][/LIMIT][OPTIONS]
OLDSTYLE_TCP_HOST = HOSTID[/LIMIT][:PORT][OPTIONS]
- HOSTID = HOSTNAME | IPV4
+ HOSTID = HOSTNAME | IPV4 | IPV6
OPTIONS = ,OPTION[OPTIONS]
OPTION = lzo | cpp
GLOBAL_OPTION = --randomize
@@ -496,6 +496,10 @@ on the local machine. If you do want to connect to a daemon on the
local machine for testing, then give the machine's IP address or real
hostname. (This will be slower.)
.TP
+.B IPV6
+A literal IPv6 address enclosed in square brackets, such as
+.B [::1]
+.TP
.B IPV4
A literal IPv4 address, such as
.B 10.0.0.1
diff --git a/src/hosts.c b/src/hosts.c
index 53205f9..71bce88 100644
--- a/src/hosts.c
+++ b/src/hosts.c
@@ -322,8 +322,21 @@ static int dcc_parse_tcp_host(struct dcc_hostdef *hostdef,
int ret;
const char *token = token_start;
- if ((ret = dcc_dup_part(&token, &hostdef->hostname, "/: \t\n\r\f,")))
- return ret;
+ if (token[0] == '[') {
+ /* We have an IPv6 Address */
+ if ((ret = dcc_dup_part(&token, &hostdef->hostname, "/] \t\n\r\f,")))
+ return ret;
+ if(token[0] != ']') {
+ rs_log_error("IPv6 Hostname requires closing ']'");
+ return EXIT_BAD_HOSTSPEC;
+ }
+ token++;
+
+ } else {
+ /* Parse IPv4 address */
+ if ((ret = dcc_dup_part(&token, &hostdef->hostname, "/: \t\n\r\f,")))
+ return ret;
+ }
if (!hostdef->hostname) {
rs_log_error("hostname is required in tcp host specification \"%s\"",
diff --git a/src/zeroconf.c b/src/zeroconf.c
index 414ddc4..fc72177 100644
--- a/src/zeroconf.c
+++ b/src/zeroconf.c
@@ -158,8 +158,10 @@ static int write_hosts(struct daemon_data *d) {
if (h->resolver)
/* Not yet fully resolved */
continue;
-
- snprintf(t, sizeof(t), "%s:%u/%i\n", avahi_address_snprint(a, sizeof(a), &h->address), h->port, d->n_slots * h->n_cpus);
+ if (h->address.proto == AVAHI_PROTO_INET6)
+ snprintf(t, sizeof(t), "[%s]:%u/%i\n", avahi_address_snprint(a, sizeof(a), &h->address), h->port, d->n_slots * h->n_cpus);
+ else
+ snprintf(t, sizeof(t), "%s:%u/%i\n", avahi_address_snprint(a, sizeof(a), &h->address), h->port, d->n_slots * h->n_cpus);
if (dcc_writex(d->fd, t, strlen(t)) != 0) {
rs_log_crit("write() failed: %s\n", strerror(errno));