fix for ipv6

This commit is contained in:
not-nullptr 2024-03-19 19:19:12 +00:00
parent 300cb18c1e
commit 02af273266
3 changed files with 9 additions and 4 deletions

View file

@ -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(),
),

View file

@ -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,
});

View file

@ -27,6 +27,7 @@ export interface IRoomConfig {
players: RoomPlayer[];
maxPlayers: number;
ip: string;
port: number;
host: SuyuUser;
}