Skip to content

Commit

Permalink
Merge pull request #77 from nicolasmoreau/master
Browse files Browse the repository at this point in the history
When a request is sent to the querystore, its ip address is found in …
  • Loading branch information
nicolasmoreau authored Jan 12, 2018
2 parents eeb5770 + c93356f commit 76d8c8f
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,18 @@ public Map<String, QueryStoreProcessor> getQuerystoreProcessors() {
* @return
*/
public String getIpAdress() {
String ipAddress = ServletContexts.instance().getRequest()
// client and proxies IP are concatenated in this header field : client, proxy1, proxy2 ...
String ipAddresses = ServletContexts.instance().getRequest()
.getHeader("X-FORWARDED-FOR");
String clientAddress = "";

if (ipAddress == null) {
ipAddress = ServletContexts.instance().getRequest().getRemoteAddr();
if (ipAddresses == null) {
clientAddress = ServletContexts.instance().getRequest().getRemoteAddr();
}else{
// keep only original client ip
clientAddress = ipAddresses.split(",")[0];
}
return ipAddress;
return clientAddress;
}

}

0 comments on commit 76d8c8f

Please sign in to comment.