From a5fb19f9edc6b63815c7d0850024dfe6131150b6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 12 Oct 2016 14:55:42 +0200 Subject: always pass real port to add_host(), print to verbose output --- pacredir.c | 13 ++++++++----- 1 file 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); -- cgit v1.2.3-70-g09d2