From 09b1b9b9253cd01f3484ba4a78fd260220313ae1 Mon Sep 17 00:00:00 2001
From: Robert James Kaes <rjkaes@users.sourceforge.net>
Date: Thu, 23 May 2002 18:23:29 +0000
Subject: Added the peer's socket information to the connection structure.  The
 information is passed along during the initialization of the structure.

---
 src/conns.c | 14 +++++++++++---
 src/conns.h | 11 +++++++++--
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/conns.c b/src/conns.c
index 1d72bfe..2d3f8a7 100644
--- a/src/conns.c
+++ b/src/conns.c
@@ -1,4 +1,4 @@
-/* $Id: conns.c,v 1.10 2002-04-18 21:43:52 rjkaes Exp $
+/* $Id: conns.c,v 1.11 2002-05-23 18:23:29 rjkaes Exp $
  *
  * Create and free the connection structure. One day there could be
  * other connnection related tasks put here, but for now the header
@@ -22,11 +22,11 @@
 
 #include "buffer.h"
 #include "conns.h"
+#include "heap.h"
 #include "stats.h"
-#include "utils.h"
 
 struct conn_s *
-initialize_conn(int client_fd)
+initialize_conn(int client_fd, const char* ipaddr, const char* string_addr)
 {
 	struct conn_s *connptr;
 	struct buffer_s *cbuffer, *sbuffer;
@@ -68,6 +68,9 @@ initialize_conn(int client_fd)
 
 	connptr->remote_content_length = -1;
 
+	connptr->client_ip_addr = safestrdup(ipaddr);
+	connptr->client_string_addr = safestrdup(string_addr);
+
 	update_stats(STAT_OPEN);
 
 	return connptr;
@@ -105,6 +108,11 @@ destroy_conn(struct conn_s *connptr)
 	if (connptr->error_string)
 		safefree(connptr->error_string);
 
+	if (connptr->client_ip_addr)
+		safefree(connptr->client_ip_addr);
+	if (connptr->client_string_addr)
+		safefree(connptr->client_string_addr);
+
 	safefree(connptr);
 
 	update_stats(STAT_CLOSE);
diff --git a/src/conns.h b/src/conns.h
index 9fd9eea..59ec8e9 100644
--- a/src/conns.h
+++ b/src/conns.h
@@ -1,4 +1,4 @@
-/* $Id: conns.h,v 1.9 2002-04-18 21:43:53 rjkaes Exp $
+/* $Id: conns.h,v 1.10 2002-05-23 18:23:29 rjkaes Exp $
  *
  * See 'conns.c' for a detailed description.
  *
@@ -43,6 +43,12 @@ struct conn_s {
 	/* A Content-Length value from the remote server */
 	long remote_content_length;
 
+	/*
+	 * Store the client's IP and hostname information
+	 */
+	char* client_ip_addr;
+	char* client_string_addr;
+
 	/*
 	 * Store the incoming request's HTTP protocol.
 	 */
@@ -55,7 +61,8 @@ struct conn_s {
 /*
  * Functions for the creation and destruction of a connection structure.
  */
-extern struct conn_s* initialize_conn(int client_fd);
+extern struct conn_s* initialize_conn(int client_fd, const char* ipaddr,
+				      const char* string_addr);
 extern void destroy_conn(struct conn_s *connptr);
 
 #endif
-- 
cgit v1.2.3