diff --git a/src/main/java/eu/openaire/urls_worker/controllers/GeneralController.java b/src/main/java/eu/openaire/urls_worker/controllers/GeneralController.java index 199fc06..1717ad4 100644 --- a/src/main/java/eu/openaire/urls_worker/controllers/GeneralController.java +++ b/src/main/java/eu/openaire/urls_worker/controllers/GeneralController.java @@ -21,10 +21,12 @@ public class GeneralController { private static final Logger logger = LoggerFactory.getLogger(GeneralController.class); + private final String controllerIp; private final String shutdownOrCancelCode; - public GeneralController(@Value("${info.shutdownOrCancelCode}") String shutdownOrCancelCode) { + public GeneralController(@Value("${info.controllerIp}") String controllerIp, @Value("${info.shutdownOrCancelCode}") String shutdownOrCancelCode) { + this.controllerIp = controllerIp; this.shutdownOrCancelCode = shutdownOrCancelCode; } @@ -91,7 +93,7 @@ public class GeneralController { if ( remoteAddr == null || "".equals(remoteAddr) ) remoteAddr = request.getRemoteAddr(); - if ( ! (remoteAddr.equals("127.0.0.1") || remoteAddr.equals(UriBuilder.ip)) ) { + if ( ! (remoteAddr.equals("127.0.0.1") || remoteAddr.equals(UriBuilder.ip) || remoteAddr.equals(controllerIp)) ) { logger.error(initMsg + " The request came from another IP: " + remoteAddr + " | while this worker has the IP: " + UriBuilder.ip); return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index fa0c5fe..afea8a3 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -22,7 +22,9 @@ info.workerId = XX info.maxAssignmentsLimitPerBatch = 10000 # If the "info.maxAssignmentsBatchesToHandleBeforeShutdown" is zero, then an infinite number of assignments-batches will be handled. info.maxAssignmentsBatchesToHandleBeforeShutdown = 0 -info.controllerBaseUrl = XX +info.controllerIp = XX +into.controllerPort = XX +info.controllerBaseUrl = http://${info.controllerIp}:${info.controllerPort}/api/ info.shutdownOrCancelCode = XX