Skip to content

Commit

Permalink
debug: list_sessions 显示连接IP
Browse files Browse the repository at this point in the history
  • Loading branch information
SALTWOOD committed Oct 22, 2024
1 parent 8b3a82a commit 3f34576
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,11 @@ export class Server {
this.app.get('/93AtHome/debug/list_sessions', (req: Request, res: Response) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(Array.from(this.sessionToClusterMap.entries())));
res.end(JSON.stringify(Array.from(this.io.sockets.sockets).map(([id, socket]) => ({
session: id,
ip: getRealIP(socket.handshake.headers) || socket.handshake.address,
cluster: this.sessionToClusterMap.get(id)?.getJson(true, true)
}))));
});
this.app.post('/93AtHome/debug/test_all_cluster', (req: Request, res: Response) => {
const hash = req.body.hash as string;
Expand Down Expand Up @@ -1426,6 +1430,7 @@ export class Server {
cluster.doOffline("Client disconnected")
this.db.update(cluster);
}
this.sessionToClusterMap.delete(socket.id);
}
});

Expand Down

0 comments on commit 3f34576

Please sign in to comment.