From 0ab9dcd7093f624bb62419446d06fff75934e825 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 13 Mar 2010 20:11:20 +0000 Subject: [PATCH] * More tweaks to locate_host() but we still need to work on this because it does not resolve the host name. --- webcit/locate_host.c | 16 +++++++++------- webcit/serv_func.c | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/webcit/locate_host.c b/webcit/locate_host.c index 165081005..b18f1031b 100644 --- a/webcit/locate_host.c +++ b/webcit/locate_host.c @@ -29,15 +29,17 @@ void locate_host(StrBuf *tbuf, int client_socket) { struct sockaddr_in6 clientaddr; unsigned int addrlen = sizeof(clientaddr); - char str[256]; + char clienthost[NI_MAXHOST]; + char clientservice[NI_MAXSERV]; getpeername(client_socket, (struct sockaddr *)&clientaddr, &addrlen); - if(inet_ntop(AF_INET6, &clientaddr.sin6_addr, str, sizeof(str))) { - StrBufAppendBufPlain(tbuf, str, -1, 0); - } - else { - StrBufAppendBufPlain(tbuf, HKEY(""), 0); - } + getnameinfo((struct sockaddr *)&clientaddr, addrlen, + clienthost, sizeof(clienthost), + clientservice, sizeof(clientservice), + NI_NUMERICHOST + ); + + StrBufAppendBufPlain(tbuf, clienthost, -1, 0); } #else /* CTDL_IPV6 */ diff --git a/webcit/serv_func.c b/webcit/serv_func.c index 654cb4f2d..afaf957a6 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -45,7 +45,7 @@ void DeleteServInfo(ServInfo **FreeMe) /* * get info about the server we've connected to * - * browser_host the citadell we want to connect to + * browser_host the citadel we want to connect to * user_agent which browser uses our client? */ ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent) -- 2.30.2