diff --git a/project/assets/database/locales/server/en.json b/project/assets/database/locales/server/en.json index 142f69ac..da422792 100644 --- a/project/assets/database/locales/server/en.json +++ b/project/assets/database/locales/server/en.json @@ -52,6 +52,7 @@ "bot-unable_to_find_bot_in_cache": "Unable to find bot in cache with name: %s", "bot-missing_application_context": "applicationContext could not find %s value. Did you restart the server without restarting the game?", "client_request": "[Client Request] %s", + "client_request_ip": "[Client Request] {{ip}} {{url}}", "customisation-item_already_purchased": "Clothing item {{itemId}} {{itemName}} already purchased", "customisation-unable_to_find_suit_by_id": "Unable to find trader suit offer with id: %s", "customisation-unable_to_find_clothing_item_in_inventory": "Clothing item not found in inventory with id: %s", diff --git a/project/src/servers/HttpServer.ts b/project/src/servers/HttpServer.ts index 9aabff8c..d038edd6 100644 --- a/project/src/servers/HttpServer.ts +++ b/project/src/servers/HttpServer.ts @@ -77,10 +77,21 @@ export class HttpServer const sessionId = this.getCookies(req).PHPSESSID; this.applicationContext.addValue(ContextVariableType.SESSION_ID, sessionId); - // http.json logRequests boolean option to allow the user/server to choose to not log requests if (this.httpConfig.logRequests) { - this.logger.info(this.localisationService.getText("client_request", req.url)); + // TODO: Extend to include 192.168 / 10.10 ranges or check subnet + const isLocalRequest = req.socket.remoteAddress.startsWith("127.0.0"); + if (isLocalRequest) + { + this.logger.info(this.localisationService.getText("client_request", req.url)); + } + else + { + this.logger.info(this.localisationService.getText("client_request_ip", { + ip: req.socket.remoteAddress, + url: req.url.replaceAll("/", "\\"), // Localisation service escapes `/` into hex code `/` + })); + } } for (const listener of this.httpListeners)