summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/httpd.cc13
1 files changed, 13 insertions, 0 deletions
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 <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+
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);