diff options
author | developerKurt <mustafakurt.business@gmail.com> | 2020-01-03 10:20:07 +0300 |
---|---|---|
committer | developerKurt <mustafakurt.business@gmail.com> | 2020-01-03 10:20:07 +0300 |
commit | 13b27f8d7ac08bb3ff1a56a48865201263d6462d (patch) | |
tree | 0a64acc277808d83d6a7ce6a65da7ac42a2de05e /src/main/java/org/traccar/helper/ServletHelper.java | |
parent | a6ab28c8990d0506e20bb2c45ed9c6183a9b9594 (diff) | |
download | trackermap-server-13b27f8d7ac08bb3ff1a56a48865201263d6462d.tar.gz trackermap-server-13b27f8d7ac08bb3ff1a56a48865201263d6462d.tar.bz2 trackermap-server-13b27f8d7ac08bb3ff1a56a48865201263d6462d.zip |
As the owner requested:
• Javadocs are removed
• Spring test framework removed, created custom mock implementation instead
• Added class and method renamed
Diffstat (limited to 'src/main/java/org/traccar/helper/ServletHelper.java')
-rw-r--r-- | src/main/java/org/traccar/helper/ServletHelper.java | 27 |
1 files changed, 27 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..4eab49001 --- /dev/null +++ b/src/main/java/org/traccar/helper/ServletHelper.java @@ -0,0 +1,27 @@ +package org.traccar.helper; + +import javax.servlet.http.HttpServletRequest; + + +public final class 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; + } + + + } +}
\ No newline at end of file |