Skip to content

Commit

Permalink
BLUE-257: Sending auth data for socket-connection
Browse files Browse the repository at this point in the history
  • Loading branch information
achal-singh committed Sep 3, 2024
1 parent 93690fc commit 80a15f9
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/Data/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`)

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
if (config.VERBOSE) Logger.mainLogger.debug('Connected node', node)
if (config.VERBOSE) Logger.mainLogger.debug('Init socketClients', socketClients.size, dataSenders.size)
})
Expand Down

0 comments on commit 80a15f9

Please sign in to comment.