mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-10 21:02:40 +00:00
evaluate X-Forwarded-For header upon replica registration so as to obtain the true replica client IP address
This commit is contained in:
1 parent
de2842e259
commit
2aa0848226
1 file changed
+6
-3
+6
-3
@@ -340,9 +340,12 @@ public class ReplicationServlet extends AbstractHttpServlet {
|
||||
}
|
||||
|
||||
private ReplicaDescriptor getReplicaDescriptor(HttpServletRequest req) throws UnknownHostException {
|
||||
InetAddress ipAddress = InetAddress.getByName(req.getRemoteAddr());
|
||||
UUID uuid = UUID.fromString(req.getParameter(SERVER_UUID));
|
||||
String additional = req.getParameter(ADDITIONAL_INFORMATION);
|
||||
final String forwardedFor = req.getHeader("X-Forwarded-For"); // could have come through a load balancer / reverse proxy
|
||||
final InetAddress ipAddress = forwardedFor != null && !forwardedFor.trim().isEmpty()
|
||||
? InetAddress.getByName(forwardedFor)
|
||||
: InetAddress.getByName(req.getRemoteAddr());
|
||||
final UUID uuid = UUID.fromString(req.getParameter(SERVER_UUID));
|
||||
final String additional = req.getParameter(ADDITIONAL_INFORMATION);
|
||||
final String[] replicableIdsAsStrings = req.getParameter(REPLICABLES_IDS_AS_STRINGS_COMMA_SEPARATED).split(",");
|
||||
return new ReplicaDescriptorImpl(ipAddress, uuid, additional, replicableIdsAsStrings);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user