From 0782bc834ba5f39d06b9505ed87953d3e74c838f Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Thu, 31 Jan 2013 17:34:13 +0100 Subject: [PATCH] Print full URLs instead of just IP addresses --- main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index ec3cdff..2eff11e 100644 --- a/main.c +++ b/main.c @@ -318,7 +318,7 @@ void init_signal_handlers(void) { } } -void print_addresses(void) { +void print_urls(int port) { struct ifaddrs *ifaddr, *ifa; int family, s; char host[INET6_ADDRSTRLEN]; @@ -349,7 +349,11 @@ void print_addresses(void) { continue; } - LOG(LVL_INFO, "%-8s: %s", ifa->ifa_name, host); + if(family == AF_INET) { + LOG(LVL_INFO, "%-8s: http://%s:%i", ifa->ifa_name, host, port); + } else { // IPv6 + LOG(LVL_INFO, "%-8s: http://[%s]:%i", ifa->ifa_name, host, port); + } } } @@ -479,7 +483,7 @@ int main(int argc, char ** argv) { } LOG(LVL_INFO, "Startup successful. Here are the IP addresses for this computer:"); - print_addresses(); + print_urls(port); while(running) { sleep(60);