diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-01-15 20:50:44 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-15 20:50:44 -0800 |
commit | 729021a19086d982c1b4ec5661d9140c42f030f8 (patch) | |
tree | a31c0870cc6e62b1f002d62f8c602ef124f173ab /src/main/java/org/traccar/helper/ServletHelper.java | |
parent | 50d8c39d41113a73fdae7a30971b4b39c35c5566 (diff) | |
parent | b62d3ba2a545a2f6b2963a2aa2c36b53abdfd6bc (diff) | |
download | trackermap-server-729021a19086d982c1b4ec5661d9140c42f030f8.tar.gz trackermap-server-729021a19086d982c1b4ec5661d9140c42f030f8.tar.bz2 trackermap-server-729021a19086d982c1b4ec5661d9140c42f030f8.zip |
Merge pull request #4460 from DeveloperKurt/failedLoginLogsIp-developerKurt
Failed Login Attempts logs IP Addresses
Diffstat (limited to 'src/main/java/org/traccar/helper/ServletHelper.java')
-rw-r--r-- | src/main/java/org/traccar/helper/ServletHelper.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/helper/ServletHelper.java b/src/main/java/org/traccar/helper/ServletHelper.java new file mode 100644 index 000000000..f951d17c0 --- /dev/null +++ b/src/main/java/org/traccar/helper/ServletHelper.java @@ -0,0 +1,28 @@ +package org.traccar.helper; + +import javax.servlet.http.HttpServletRequest; + + +public final class ServletHelper { + + + private ServletHelper() { + } + + public static String retrieveRemoteAddress(HttpServletRequest request) { + + if (request != null) { + String ipAddress = request.getHeader("X-FORWARDED-FOR"); + + if (ipAddress != null && !ipAddress.isEmpty()) { + return ipAddress.substring(0, ipAddress.indexOf(",")); //Removes the additional data + } else { + ipAddress = request.getRemoteAddr(); + return ipAddress; + } + + } else { + return null; + } + } +} |