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 | 4826a2fc1f93070919f2200096864a793cd9f39b (patch) | |
tree | 9e8db2cd3a8bd0d38d8706479e70ed66141bd827 /gateway/src/events/Connection.ts | |
parent | Untested gif resize support in cdn (diff) | |
download | server-4826a2fc1f93070919f2200096864a793cd9f39b.tar.xz |
Log IP addresses of gateway connections
Diffstat (limited to 'gateway/src/events/Connection.ts')
-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 |