Print full URLs instead of just IP addresses

This commit is contained in:
Thomas Kolb 2013-01-31 17:34:13 +01:00
parent 8336b7ef9d
commit 0782bc834b

10
main.c
View file

@ -318,7 +318,7 @@ void init_signal_handlers(void) {
} }
} }
void print_addresses(void) { void print_urls(int port) {
struct ifaddrs *ifaddr, *ifa; struct ifaddrs *ifaddr, *ifa;
int family, s; int family, s;
char host[INET6_ADDRSTRLEN]; char host[INET6_ADDRSTRLEN];
@ -349,7 +349,11 @@ void print_addresses(void) {
continue; 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:"); LOG(LVL_INFO, "Startup successful. Here are the IP addresses for this computer:");
print_addresses(); print_urls(port);
while(running) { while(running) {
sleep(60); sleep(60);