fix for ipv6
This commit is contained in:
parent
300cb18c1e
commit
02af273266
3 changed files with 9 additions and 4 deletions
|
@ -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(),
|
||||
),
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
|
|
1
src/types/rooms.d.ts
vendored
1
src/types/rooms.d.ts
vendored
|
@ -27,6 +27,7 @@ export interface IRoomConfig {
|
|||
players: RoomPlayer[];
|
||||
maxPlayers: number;
|
||||
ip: string;
|
||||
port: number;
|
||||
host: SuyuUser;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue