From 80a15f965e95ae229c2891fea71f983e301524d5 Mon Sep 17 00:00:00 2001 From: Achal Singh Date: Tue, 3 Sep 2024 18:59:26 +0530 Subject: [PATCH] BLUE-257: Sending auth data for socket-connection --- src/Data/Data.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Data/Data.ts b/src/Data/Data.ts index 2c77af9d..97c78fcf 100644 --- a/src/Data/Data.ts +++ b/src/Data/Data.ts @@ -191,21 +191,15 @@ export async function unsubscribeDataSender( export function initSocketClient(node: NodeList.ConsensusNodeInfo): void { if (config.VERBOSE) Logger.mainLogger.debug('Node Info to socket connect', node) - const socketClient = ioclient.connect(`http://${node.ip}:${node.port}`) + const socketClient = ioclient.connect(`http://${node.ip}:${node.port}`, { + query: { + data: JSON.stringify(Crypto.sign({ publicKey: State.getNodeInfo().publicKey })), + }, + }) socketClients.set(node.publicKey, socketClient) - let archiverKeyisEmitted = false - socketClient.on('connect', () => { - Logger.mainLogger.debug( - `${!archiverKeyisEmitted ? 'New connection' : 'Reconnection'} to consensus node ${node.ip}:${ - node.port - } is made` - ) - if (archiverKeyisEmitted) return - // Send ehlo event right after connect: - socketClient.emit('ARCHIVER_PUBLIC_KEY', config.ARCHIVER_PUBLIC_KEY) - archiverKeyisEmitted = true + Logger.mainLogger.debug(`✅ New Socket Connection to consensus node ${node.ip}:${node.port} is made`) if (config.VERBOSE) Logger.mainLogger.debug('Connected node', node) if (config.VERBOSE) Logger.mainLogger.debug('Init socketClients', socketClients.size, dataSenders.size) })