diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-07-31 21:07:29 +1000 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-07-31 21:07:29 +1000 |
commit | 698c1cca4436ce4891d591a22ccdbadc7e573f15 (patch) | |
tree | 6f5f07fdac79a7e128d1999acad7242a35ec8d62 | |
parent | Untested gif resize support in cdn (diff) | |
download | server-698c1cca4436ce4891d591a22ccdbadc7e573f15.tar.xz |
Log IP addresses of gateway connections
-rw-r--r-- | gateway/src/events/Connection.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gateway/src/events/Connection.ts b/gateway/src/events/Connection.ts index 4954cd08..2d41b7a3 100644 --- a/gateway/src/events/Connection.ts +++ b/gateway/src/events/Connection.ts @@ -8,6 +8,7 @@ import { Close } from "./Close"; import { Message } from "./Message"; import { createDeflate } from "zlib"; import { URL } from "url"; +import { Config } from "@fosscord/util"; var erlpack: any; try { erlpack = require("@yukikaze-bot/erlpack"); @@ -22,12 +23,15 @@ export async function Connection( socket: WebSocket, request: IncomingMessage ) { + const forwardedFor = Config.get().security.forwadedFor; + const ipAddress = forwardedFor ? request.headers[forwardedFor] as string : request.socket.remoteAddress; + try { // @ts-ignore socket.on("close", Close); // @ts-ignore socket.on("message", Message); - console.log(`[Gateway] Connections: ${this.clients.size}`); + console.log(`[Gateway] New connection from ${ipAddress}, total ${this.clients.size}`); const { searchParams } = new URL(`http://localhost${request.url}`); // @ts-ignore |