Log IP of request when not a local address
This commit is contained in:
parent
d8562e610a
commit
28d40d9443
@ -52,6 +52,7 @@
|
|||||||
"bot-unable_to_find_bot_in_cache": "Unable to find bot in cache with name: %s",
|
"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?",
|
"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": "[Client Request] %s",
|
||||||
|
"client_request_ip": "[Client Request] {{ip}} {{url}}",
|
||||||
"customisation-item_already_purchased": "Clothing item {{itemId}} {{itemName}} already purchased",
|
"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_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",
|
"customisation-unable_to_find_clothing_item_in_inventory": "Clothing item not found in inventory with id: %s",
|
||||||
|
@ -77,11 +77,22 @@ export class HttpServer
|
|||||||
const sessionId = this.getCookies(req).PHPSESSID;
|
const sessionId = this.getCookies(req).PHPSESSID;
|
||||||
this.applicationContext.addValue(ContextVariableType.SESSION_ID, sessionId);
|
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)
|
if (this.httpConfig.logRequests)
|
||||||
|
{
|
||||||
|
// 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));
|
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)
|
for (const listener of this.httpListeners)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user