diff --git a/src/main/java/io/kamax/mxisd/controller/identity/v1/MappingController.java b/src/main/java/io/kamax/mxisd/controller/identity/v1/MappingController.java index 07497ef5..32b7c6a5 100644 --- a/src/main/java/io/kamax/mxisd/controller/identity/v1/MappingController.java +++ b/src/main/java/io/kamax/mxisd/controller/identity/v1/MappingController.java @@ -66,9 +66,11 @@ public class MappingController { private void setRequesterInfo(ALookupRequest lookupReq, HttpServletRequest req) { lookupReq.setRequester(req.getRemoteAddr()); String xff = req.getHeader("X-FORWARDED-FOR"); - lookupReq.setRecursive(StringUtils.isNotBlank(xff)); - if (lookupReq.isRecursive()) { + log.debug("XFF header: {}", xff); + lookupReq.setRecursive(StringUtils.isBlank(xff)); + if (!lookupReq.isRecursive()) { lookupReq.setRecurseHosts(Arrays.asList(xff.split(","))); + lookupReq.setRequester(lookupReq.getRecurseHosts().get(lookupReq.getRecurseHosts().size() - 1)); } lookupReq.setUserAgent(req.getHeader("USER-AGENT")); @@ -106,7 +108,7 @@ String lookup(HttpServletRequest request, @RequestParam String medium, @RequestP String bulkLookup(HttpServletRequest request) { BulkLookupRequest lookupRequest = new BulkLookupRequest(); setRequesterInfo(lookupRequest, request); - log.info("Got single lookup request from {} with client {} - Is recursive? {}", lookupRequest.getRequester(), lookupRequest.getUserAgent(), lookupRequest.isRecursive()); + log.info("Got bulk lookup request from {} with client {} - Is recursive? {}", lookupRequest.getRequester(), lookupRequest.getUserAgent(), lookupRequest.isRecursive()); try { ClientBulkLookupRequest input = parser.parse(request, ClientBulkLookupRequest.class);