mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-02 21:12:49 +08:00
Fix 7 corner cases found in second review pass
Critical:
- Persist serverProtocol/ts6ApiKey in database schema so TS6 config
survives restarts (added columns + manager save/load)
Medium:
- Clear udpErrorTimer on disconnect to prevent memory leak and stale
log messages from firing after teardown
- Guard against double connect() by disconnecting old client first
- Add settled guard in TS6HttpQuery.request() to prevent double
reject when both res error and req error fire
- Add res.on("error") handler to TS6HttpQuery response stream
Low:
- Cap probeTS3Query banner buffer at 256 bytes to prevent memory abuse
from non-TS3 services sending large data on port 10011
- Remove unnecessary EventEmitter inheritance from TS6HttpQuery
- Update database test fixtures with new serverProtocol/ts6ApiKey fields
https://claude.ai/code/session_016WhH58avUD9xy2dgADJgTh
This commit is contained in:
6 files changed
+54
-15
No files matched your search
@@ -67,11 +67,13 @@ function probeTS3Query(host: string, port: number, timeoutMs: number): Promise<b
|
||||
|
||||
const socket = net.createConnection({ host, port, timeout: timeoutMs });
|
||||
let banner = "";
|
||||
const MAX_BANNER = 256; // TS3 banner is ~50 bytes; cap to avoid memory abuse
|
||||
|
||||
socket.setTimeout(timeoutMs);
|
||||
|
||||
socket.on("data", (data: Buffer) => {
|
||||
banner += data.toString("utf-8");
|
||||
if (banner.length > MAX_BANNER) banner = banner.slice(0, MAX_BANNER);
|
||||
if (banner.includes("TS3")) {
|
||||
done(true);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user