mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
fix(remote-control): add payload size limit handling for remote control requests
This commit is contained in:
1 parent
7c9db4bc7d
commit
3ee1d71b79
1 file changed
+17
@@ -272,10 +272,27 @@ class RemoteControlEvents {
|
||||
callback: (body: any) => void
|
||||
): void {
|
||||
let data = '';
|
||||
let totalSize = 0;
|
||||
let payloadTooLarge = false;
|
||||
const MAX_BODY_SIZE = 10 * 1024; // 10KB
|
||||
|
||||
req.on('data', (chunk: Buffer) => {
|
||||
if (payloadTooLarge) return;
|
||||
|
||||
totalSize += chunk.length;
|
||||
if (totalSize > MAX_BODY_SIZE) {
|
||||
payloadTooLarge = true;
|
||||
res.writeHead(413, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ error: 'Payload too large' }));
|
||||
req.destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
data += chunk.toString();
|
||||
});
|
||||
req.on('end', () => {
|
||||
if (payloadTooLarge) return;
|
||||
|
||||
if (!data) {
|
||||
callback({});
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user