Created
February 8, 2015 06:51
-
-
Save joshenders/faac5b0478039b10f971 to your computer and use it in GitHub Desktop.
X-Forwarded-For patch for thttpd-2.26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- libhttpd.c 2014-12-10 12:53:07.000000000 -0800 | |
+++ libhttpd.c.patched 2015-02-07 22:44:59.183663432 -0800 | |
@@ -2231,6 +2231,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 || |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! (FYI: This is included in both sthttpd and Merecat, both forks of thttpd.)