* More tweaks to locate_host() but we still need to work on this because it does...
authorArt Cancro <ajc@citadel.org>
Sat, 13 Mar 2010 20:11:20 +0000 (20:11 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 13 Mar 2010 20:11:20 +0000 (20:11 +0000)
webcit/locate_host.c
webcit/serv_func.c

index 165081005e6bdd67e1b0ffa3f252316402852a29..b18f1031bc9ddc4b63b3f190d11dcfdd177616ed 100644 (file)
@@ -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("<unknown>"), 0);
-       }
+       getnameinfo((struct sockaddr *)&clientaddr, addrlen,
+               clienthost, sizeof(clienthost),
+               clientservice, sizeof(clientservice),
+               NI_NUMERICHOST
+       );
+
+        StrBufAppendBufPlain(tbuf, clienthost, -1, 0);
 }
 
 #else /* CTDL_IPV6 */
index 654cb4f2dc0bad384290a9c36ab013eddefc02ec..afaf957a66ff4fea2082033e832743f74180e1fa 100644 (file)
@@ -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)