telize

High performance JSON IP and GeoIP REST API (IP Geolocation)
Log | Files | Refs | README | LICENSE

commit b03926ef0a8a6f9e5bfa809b1c0dd0ed17849369
parent cff6efc63f269d7cc582367037edc1f2aefc336d
Author: Frederic Cambus <fred@statdns.com>
Date:   Sat,  6 Oct 2018 22:28:27 +0200

When 'X-Forwarded-For' header is set, only get the first IP of the list

Diffstat:
Msrc/ip.c | 2++
Msrc/jsonip.c | 2++
Msrc/location.c | 2++
3 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/ip.c b/src/ip.c @@ -12,6 +12,7 @@ /* */ /*****************************************************************************/ +#include <string.h> #include <sys/socket.h> #include <kore/kore.h> @@ -34,6 +35,7 @@ ip(struct http_request *req) } if (http_request_header(req, "X-Forwarded-For", &visitor_ip)) { + strtok(visitor_ip, ","); ip = visitor_ip; } else { ip = addr; diff --git a/src/jsonip.c b/src/jsonip.c @@ -13,6 +13,7 @@ /*****************************************************************************/ #include <stdio.h> +#include <string.h> #include <sys/socket.h> #include <kore/kore.h> @@ -40,6 +41,7 @@ jsonip(struct http_request *req) } if (http_request_header(req, "X-Forwarded-For", &visitor_ip)) { + strtok(visitor_ip, ","); ip = visitor_ip; } else { ip = addr; diff --git a/src/location.c b/src/location.c @@ -13,6 +13,7 @@ /*****************************************************************************/ #include <stdio.h> +#include <string.h> #include <time.h> #include <sys/socket.h> @@ -71,6 +72,7 @@ location(struct http_request *req) } if (http_request_header(req, "X-Forwarded-For", &visitor_ip)) { + strtok(visitor_ip, ","); ip = visitor_ip; } else { ip = addr;