From da3e1bec8f45feddaee41ba02562207f4b7ad1f7 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 3 May 2012 14:45:40 +0200 Subject: Print peer address on connection. --- server/src/httpd.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'server/src') diff --git a/server/src/httpd.cc b/server/src/httpd.cc index 62e4c9f..10bd5bb 100644 --- a/server/src/httpd.cc +++ b/server/src/httpd.cc @@ -42,6 +42,11 @@ #include "debug.h" +// for inet_ntop +#include +#include +#include + typedef struct { void *ptr; bool firstrun; @@ -71,6 +76,14 @@ static int request_handler(void *cls, { time_t now = time(NULL); DEBUG(httpd, "Request time: %s", ctime(&now)); + + struct sockaddr *so; + so = MHD_get_connection_info(con, MHD_CONNECTION_INFO_CLIENT_ADDRESS)->client_addr; + + char peeraddr[INET_ADDRSTRLEN]; + inet_ntop(AF_INET, &((struct sockaddr_in*)so)->sin_addr, peeraddr, sizeof(peeraddr)); + DEBUG(httpd, "peer: %s\n", peeraddr); + DEBUG(httpd, "request_handler: cls(%p) con(%p) url(%s) method(%s)" " version(%s) *con_cls(%p)\n", cls, con, url, method, version, *con_cls); -- cgit v1.2.3