#include "log.h"
#include "conf.h"
+#include "util.h"
#define STRSIZE 254
va_list argp;
char buf[STRSIZE + 1];
int offset = 0;
- uint16_t port;
if (termprint || logfile)
offset = sprintf(buf, "INFO: ");
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);
-
+ char *clientAddressString = Util_clientAddressToString(client);
offset += snprintf(&buf[offset], STRSIZE - offset, " - [%d] %s@%s:%d",
- client->sessionId,
- client->username == NULL ? "" : client->username,
- client->addressString,
- port);
+ client->sessionId,
+ client->username == NULL ? "" : client->username,
+ clientAddressString,
+ Util_clientAddressToPortTCP(client));
+ free(clientAddressString);
if (termprint)
fprintf(stderr, "%s\n", buf);