X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Flog.c;fp=src%2Flog.c;h=17bbe14a56e804bd9aea4b9b68475e06a3cbc088;hb=b331021d492fd5febb576a61717a489c5cc875ff;hp=ebb5cd1c0ae1e4b4965da971df41a3484f538928;hpb=7a4674db9a32bccbcf8d1655ede3ac293a9171f5;p=umurmur.git diff --git a/src/log.c b/src/log.c index ebb5cd1..17bbe14 100644 --- a/src/log.c +++ b/src/log.c @@ -182,6 +182,7 @@ void Log_info_client(client_t *client, const char *logstring, ...) va_list argp; char buf[STRSIZE + 1]; int offset = 0; + uint16_t port; if (termprint || logfile) offset = sprintf(buf, "INFO: "); @@ -190,11 +191,17 @@ void Log_info_client(client_t *client, const char *logstring, ...) offset += vsnprintf(&buf[offset], STRSIZE - offset, logstring, argp); va_end(argp); + if(client->remote_tcp.ss_family == AF_INET) + port = ntohs(((struct sockaddr_in*)&client->remote_tcp)->sin_port); + else + port = ntohs(((struct sockaddr_in6*)&client->remote_tcp)->sin6_port); + offset += snprintf(&buf[offset], STRSIZE - offset, " - [%d] %s@%s:%d", client->sessionId, client->username == NULL ? "" : client->username, - inet_ntoa(client->remote_tcp.sin_addr), - ntohs(client->remote_tcp.sin_port)); + client->addressString, + port); + if (termprint) fprintf(stderr, "%s\n", buf); else if (logfile)