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
1 changed files with 7 additions and 3 deletions

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;
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);