summaryrefslogtreecommitdiffstats
path: root/pacredir.c
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2016-10-12 14:55:42 +0200
committerGravatar Christian Hesse <mail@eworm.de>2016-10-12 14:55:42 +0200
commita5fb19f9edc6b63815c7d0850024dfe6131150b6 (patch)
tree6170508bfa65e83d54f3e8cde08463c0934f23da /pacredir.c
parentbedacf9c09b718f96ae559607cbdbc822570f004 (diff)
downloadpacredir-a5fb19f9edc6b63815c7d0850024dfe6131150b6.tar.gz
pacredir-a5fb19f9edc6b63815c7d0850024dfe6131150b6.tar.zst
always pass real port to add_host(), print to verbose output
Diffstat (limited to 'pacredir.c')
-rw-r--r--pacredir.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/pacredir.c b/pacredir.c
index a6c4813..d78ba8a 100644
--- a/pacredir.c
+++ b/pacredir.c
@@ -67,13 +67,16 @@ int add_host(const char * host, const uint16_t port, const char * type) {
while (tmphosts->host != NULL) {
if (strcmp(tmphosts->host, host) == 0) {
/* host already exists */
- write_log(stdout, "Updating service %s on host %s\n", type, host);
+ write_log(stdout, "Updating service %s (port %d) on host %s\n",
+ type, port, host);
goto update;
}
tmphosts = tmphosts->next;
}
+
/* host not found, adding a new one */
- write_log(stdout, "Adding host %s with service %s\n", host, type);
+ write_log(stdout, "Adding host %s with service %s (port %d)\n",
+ host, type, port);
tmphosts->host = strdup(host);
tmphosts->pacserve.port = 0;
@@ -93,11 +96,11 @@ int add_host(const char * host, const uint16_t port, const char * type) {
update:
if (strcmp(type, PACSERVE) == 0) {
tmphosts->pacserve.online = 1;
- tmphosts->pacserve.port = (port > 0 ? port : PORT_PACSERVE);
+ tmphosts->pacserve.port = port;
request.service = &tmphosts->pacserve;
} else if (strcmp(type, PACDBSERVE) == 0) {
tmphosts->pacdbserve.online = 1;
- tmphosts->pacdbserve.port = (port > 0 ? port : PORT_PACDBSERVE);
+ tmphosts->pacdbserve.port = port;
request.service = &tmphosts->pacdbserve;
}
@@ -175,7 +178,7 @@ static void browse_callback(AvahiServiceBrowser *b,
if (verbose > 0)
write_log(stdout, "Found service %s on host %s on interface %s\n", type, host, intname);
- add_host(host, 0, type);
+ add_host(host, strcmp(type, PACSERVE) == 0 ? PORT_PACSERVE : PORT_PACDBSERVE, type);
out:
free(host);