thttpd (2.25b-11) 10-x-forwarded-for-header.dpatch

Summary

 libhttpd.c |    6 ++++++
 1 file changed, 6 insertions(+)

    
download this patch

Patch contents

#! /bin/sh /usr/share/dpatch/dpatch-run
## 11-x-forwarded-for-header.dpatch by  <skx@gold.my.flat>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' thttpd-2.25b~/libhttpd.c thttpd-2.25b/libhttpd.c
--- thttpd-2.25b~/libhttpd.c	2005-06-29 18:50:39.000000000 +0100
+++ thttpd-2.25b/libhttpd.c	2010-02-26 12:50:16.000000000 +0000
@@ -2207,6 +2207,12 @@
 		if ( strcasecmp( cp, "keep-alive" ) == 0 )
 		    hc->keep_alive = 1;
 		}
+        else if ( strncasecmp( buf, "X-Forwarded-For:", 16 ) == 0 )
+        { /* Use real IP if available  */
+           cp = &buf[16];
+           cp += strspn( cp, " \t" );
+           inet_aton( cp, &(hc->client_addr.sa_in.sin_addr) );
+        }
 #ifdef LOG_UNKNOWN_HEADERS
 	    else if ( strncasecmp( buf, "Accept-Charset:", 15 ) == 0 ||
 		      strncasecmp( buf, "Accept-Language:", 16 ) == 0 ||