mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-23 02:42:28 +01:00
Trash ip logging
This commit is contained in:
parent
0e98fe9953
commit
2743907375
@ -26,12 +26,14 @@ export async function Connection(
|
|||||||
const forwardedFor = Config.get().security.forwadedFor;
|
const forwardedFor = Config.get().security.forwadedFor;
|
||||||
const ipAddress = forwardedFor ? request.headers[forwardedFor] as string : request.socket.remoteAddress;
|
const ipAddress = forwardedFor ? request.headers[forwardedFor] as string : request.socket.remoteAddress;
|
||||||
|
|
||||||
|
socket.ipAddress = ipAddress;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
socket.on("close", Close);
|
socket.on("close", Close);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
socket.on("message", Message);
|
socket.on("message", Message);
|
||||||
console.log(`[Gateway] New connection from ${ipAddress}, total ${this.clients.size}`);
|
console.log(`[Gateway] New connection from ${socket.ipAddress}, total ${this.clients.size}`);
|
||||||
|
|
||||||
const { searchParams } = new URL(`http://localhost${request.url}`);
|
const { searchParams } = new URL(`http://localhost${request.url}`);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -237,7 +237,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
|||||||
|
|
||||||
const d: ReadyEventData = {
|
const d: ReadyEventData = {
|
||||||
v: 8,
|
v: 8,
|
||||||
application,
|
application: application ?? undefined,
|
||||||
user: privateUser,
|
user: privateUser,
|
||||||
user_settings: user.settings,
|
user_settings: user.settings,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@ -296,4 +296,6 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
|||||||
//TODO send VOICE_STATE_UPDATE to let the client know if another device is already connected to a voice channel
|
//TODO send VOICE_STATE_UPDATE to let the client know if another device is already connected to a voice channel
|
||||||
|
|
||||||
await setupListener.call(this);
|
await setupListener.call(this);
|
||||||
|
|
||||||
|
console.log(`${this.ipAddress} identified as ${d.user.id}`)
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ export interface WebSocket extends WS {
|
|||||||
session_id: string;
|
session_id: string;
|
||||||
encoding: "etf" | "json";
|
encoding: "etf" | "json";
|
||||||
compress?: "zlib-stream";
|
compress?: "zlib-stream";
|
||||||
|
ipAddress?: string;
|
||||||
shard_count?: bigint;
|
shard_count?: bigint;
|
||||||
shard_id?: bigint;
|
shard_id?: bigint;
|
||||||
deflate?: Deflate;
|
deflate?: Deflate;
|
||||||
|
Loading…
Reference in New Issue
Block a user