Skip to content

Commit 8ece416

Browse files
authored
fix: log rejected game server WebSocket connections (#138)
Co-authored-by: Flegma <Flegma@users.noreply.github.com>
1 parent 9150e55 commit 8ece416

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/matches/match-events.gateway.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,28 @@ export class MatchEventsGateway {
4343
const authHeader = request.headers.authorization;
4444

4545
if (!authHeader || !authHeader.startsWith("Basic ")) {
46+
this.logger.warn("game server connection rejected: missing auth", {
47+
ip: request.headers["cf-connecting-ip"],
48+
});
4649
client.close();
4750
return;
4851
}
4952

5053
const base64Credentials = authHeader.split(" ").at(1);
5154
if (!base64Credentials) {
55+
this.logger.warn("game server connection rejected: malformed auth", {
56+
ip: request.headers["cf-connecting-ip"],
57+
});
5258
client.close();
5359
return;
5460
}
5561

5662
const decoded = Buffer.from(base64Credentials, "base64").toString();
5763
const colonIndex = decoded.indexOf(":");
5864
if (colonIndex === -1) {
65+
this.logger.warn("game server connection rejected: invalid credentials format", {
66+
ip: request.headers["cf-connecting-ip"],
67+
});
5968
client.close();
6069
return;
6170
}

0 commit comments

Comments
 (0)