Skip to content

Commit

Permalink
Fix recursive logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Dor committed Oct 2, 2017
1 parent 640512e commit 3954be2
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3954be2

Please sign in to comment.