From 02af2732662d8bddf5cc153e3b757903955b92c2 Mon Sep 17 00:00:00 2001 From: not-nullptr Date: Tue, 19 Mar 2024 19:19:12 +0000 Subject: [PATCH] fix for ipv6 --- src/lib/server/class/Room.ts | 5 ++--- src/routes/lobby/+server.ts | 7 ++++++- src/types/rooms.d.ts | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lib/server/class/Room.ts b/src/lib/server/class/Room.ts index 2a03a8b..4117fab 100644 --- a/src/lib/server/class/Room.ts +++ b/src/lib/server/class/Room.ts @@ -37,7 +37,6 @@ export class Room { // ip: string, config: IRoomConfig, ) { - const parsed = config.ip.split(":"); this.host = config.host; this.roomInfo = { name: config.name, @@ -46,13 +45,13 @@ export class Room { preferredGameId: config.gameId, players: config.players, maxPlayers: config.maxPlayers, - address: parsed[0], + address: config.ip, externalGuid: v4(), hasPassword: config.hasPassword, id: v4(), netVersion: 1, owner: this.host.username, - port: parseInt(parsed[1]), + port: config.port, game: globalData.games.find( (g) => g.name?.toUpperCase().trim() === config.gameName?.toUpperCase().trim(), ), diff --git a/src/routes/lobby/+server.ts b/src/routes/lobby/+server.ts index c614493..e14f286 100644 --- a/src/routes/lobby/+server.ts +++ b/src/routes/lobby/+server.ts @@ -57,7 +57,12 @@ export async function POST({ request, getClientAddress }) { }, ], maxPlayers: body.maxPlayers, - ip: `${opts.ip || request.headers.get("CF-Connecting-IP") || request.headers.get("X-Forwarded-For") || (borkedIp.includes("127.0.0.1") ? "127.0.0.1" : borkedIp)}:${body.port}`, + ip: + opts.ip || + request.headers.get("CF-Connecting-IP") || + request.headers.get("X-Forwarded-For") || + (borkedIp.includes("127.0.0.1") ? "127.0.0.1" : borkedIp), + port: body.port, host: user, hasPassword: body.hasPassword || false, }); diff --git a/src/types/rooms.d.ts b/src/types/rooms.d.ts index 77697ae..1547eef 100644 --- a/src/types/rooms.d.ts +++ b/src/types/rooms.d.ts @@ -27,6 +27,7 @@ export interface IRoomConfig { players: RoomPlayer[]; maxPlayers: number; ip: string; + port: number; host: SuyuUser; }