Commit 86d919dd authored by nanahira's avatar nanahira

add more logs to windbot

parent 211a9003
Pipeline #43312 passed with stages
in 2 minutes and 33 seconds
...@@ -129,7 +129,16 @@ export class ClientHandler { ...@@ -129,7 +129,16 @@ export class ClientHandler {
this.logger.debug({ client: client.name }, 'Handshake completed'); this.logger.debug({ client: client.name }, 'Handshake completed');
client.established = true; client.established = true;
}) })
.catch(() => { .catch((error) => {
this.logger.warn(
{
client: client.name || client.loggingIp(),
ip: client.loggingIp(),
isInternal: client.isInternal,
error: (error as Error)?.message || String(error),
},
'Handshake failed, disconnecting client',
);
client.disconnect(); client.disconnect();
}); });
} }
......
...@@ -22,17 +22,35 @@ export class JoinWindbotToken { ...@@ -22,17 +22,35 @@ export class JoinWindbotToken {
const token = msg.pass.slice('AIJOIN#'.length); const token = msg.pass.slice('AIJOIN#'.length);
const tokenData = this.windbotProvider.consumeJoinToken(token); const tokenData = this.windbotProvider.consumeJoinToken(token);
if (!tokenData) { if (!tokenData) {
this.logger.warn(
{ token, clientIp: client.loggingIp() },
'Windbot token not found when joining',
);
return client.die('#{invalid_password_not_found}', ChatColor.RED); return client.die('#{invalid_password_not_found}', ChatColor.RED);
} }
const room = this.roomManager.findByName(tokenData.roomName); const room = this.roomManager.findByName(tokenData.roomName);
if (!room) { if (!room) {
this.logger.warn(
{ token, roomName: tokenData.roomName, clientIp: client.loggingIp() },
'Windbot target room not found when joining',
);
return client.die('#{invalid_password_not_found}', ChatColor.RED); return client.die('#{invalid_password_not_found}', ChatColor.RED);
} }
client.isInternal = true; client.isInternal = true;
client.windbot = tokenData.windbot; client.windbot = tokenData.windbot;
return room.join(client); await room.join(client);
this.logger.info(
{
token,
roomName: room.name,
botName: tokenData.windbot.name,
pos: client.pos,
},
'Windbot joined room by token',
);
return;
}); });
} }
} }
...@@ -323,6 +323,23 @@ export class WindBotProvider { ...@@ -323,6 +323,23 @@ export class WindBotProvider {
'Reverse ws windbot client handler failed', 'Reverse ws windbot client handler failed',
); );
}); });
const roomName = room.name;
setTimeout(() => {
if (!this.tokenDataMap.has(token)) {
return;
}
this.logger.warn(
{
roomToken: token,
roomName,
botName,
endpoint: url.toString(),
},
'Windbot join token still not consumed after reverse ws request',
);
}, 6000);
return true; return true;
} catch (error) { } catch (error) {
this.logger.warn( this.logger.warn(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment