fix: Increase maxStringLength for large handshake messages

**Motivations :**
- Fix WebSocket message validation for large handshake messages
- Allow processing of long peer lists in handshake content

**Modifications :**
- Increased maxStringLength from 10000 to 100000 characters
- Added detailed error logging for validation failures

**Pages affectées :**
- src/services/message-validator.ts - Increased string length limit
- src/websockets.ts - Enhanced error logging
This commit is contained in:
NicolasCantu 2025-10-23 19:29:47 +02:00
parent a96a292089
commit 82e37cbff7
2 changed files with 2 additions and 1 deletions

View File

@ -17,7 +17,7 @@ export interface WebSocketMessage {
export class MessageValidator { export class MessageValidator {
private static instance: MessageValidator; private static instance: MessageValidator;
private maxMessageSize = 1024 * 1024; // 1MB private maxMessageSize = 1024 * 1024; // 1MB
private maxStringLength = 10000; private maxStringLength = 100000; // Increased for large handshake messages
private allowedFlags = ['Handshake', 'NewTx', 'Cipher', 'Commit']; private allowedFlags = ['Handshake', 'NewTx', 'Cipher', 'Commit'];
private constructor() {} private constructor() {}

View File

@ -37,6 +37,7 @@ export async function initWebsocket(url: string) {
errors: validation.errors, errors: validation.errors,
messagePreview: msgData.substring(0, 100) messagePreview: msgData.substring(0, 100)
}); });
console.log('🔍 DEBUG: Full validation errors:', validation.errors);
secureLogger.warn('Invalid WebSocket message received', { secureLogger.warn('Invalid WebSocket message received', {
component: 'WebSocket', component: 'WebSocket',
operation: 'message_validation', operation: 'message_validation',