Files

34 lines
1.0 KiB
Python

import re
with open('/opt/WireMCP/index.js', 'r') as f:
content = f.read()
# Replace the promisify line to include maxBuffer default
content = content.replace(
'const execAsync = promisify(exec);',
'const execAsync = promisify(exec);\nconst MAX_BUFFER = 100 * 1024 * 1024; // 100MB for large packet captures'
)
# Remove duplicate if any
lines = content.split('\n')
seen = set()
unique_lines = []
for line in lines:
if 'MAX_BUFFER' in line and line in seen:
continue
if 'MAX_BUFFER' in line:
seen.add(line)
unique_lines.append(line)
content = '\n'.join(unique_lines)
# Now wrap execAsync to pass maxBuffer by default
content = content.replace(
'const execAsync = promisify(exec);\nconst MAX_BUFFER = 100 * 1024 * 1024;',
'const _execAsync = promisify(exec);\nconst MAX_BUFFER = 100 * 1024 * 1024;\nconst execAsync = (cmd, opts = {}) => _execAsync(cmd, { maxBuffer: MAX_BUFFER, ...opts });'
)
with open('/opt/WireMCP/index.js', 'w') as f:
f.write(content)
print('OK')