Improved local request log handling
This commit is contained in:
parent
4e936572e5
commit
d609d4b41a
@ -82,8 +82,7 @@ export class HttpServer
|
||||
|
||||
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");
|
||||
const isLocalRequest = this.isLocalRequest(req.socket.remoteAddress);
|
||||
if (typeof isLocalRequest !== "undefined")
|
||||
{
|
||||
if (isLocalRequest)
|
||||
@ -110,6 +109,23 @@ export class HttpServer
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check against hardcoded values that determine its from a local address
|
||||
* @param remoteAddress Address to check
|
||||
* @returns True if its local
|
||||
*/
|
||||
protected isLocalRequest(remoteAddress: string): boolean
|
||||
{
|
||||
if (!remoteAddress)
|
||||
{
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return remoteAddress.startsWith("127.0.0")
|
||||
|| remoteAddress.startsWith("192.168.")
|
||||
|| remoteAddress.startsWith("localhost");
|
||||
}
|
||||
|
||||
protected getCookies(req: IncomingMessage): Record<string, string>
|
||||
{
|
||||
const found: Record<string, string> = {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user