Skip to content

Commit

Permalink
added X-Forwarded-For header support, to correct display IP behind
Browse files Browse the repository at this point in the history
frontend
  • Loading branch information
leandr committed Jun 8, 2012
1 parent 76dc45d commit 30ade61
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -1446,14 +1446,16 @@ void stats_set_conv (long handle, const char *name, const char *value, const cha
void stats_listener_to_xml (client_t *listener, xmlNodePtr parent)
{
const char *useragent;
const char *ip;
char buf[30];

xmlNodePtr node = xmlNewChild (parent, NULL, XMLSTR("listener"), NULL);

snprintf (buf, sizeof (buf), "%lu", listener->connection.id);
xmlSetProp (node, XMLSTR("id"), XMLSTR(buf));

xmlNewChild (node, NULL, XMLSTR("IP"), XMLSTR(listener->connection.ip));
ip = httpp_getvar (listener->parser, "x-forwarded-for");
xmlNewChild (node, NULL, XMLSTR("IP"), XMLSTR(ip == NULL ? listener->connection.ip: ip));

useragent = httpp_getvar (listener->parser, "user-agent");
if (useragent && xmlCheckUTF8((unsigned char *)useragent))
Expand Down

0 comments on commit 30ade61

Please sign in to comment.