Skip to content

Commit

Permalink
GOLD-265 -- feat: add timestamp when subscribing socketio to consenso…
Browse files Browse the repository at this point in the history
…rs (#81)

* feat: add timestamp when subscribing socketio to consensors

* feat: include consensor pubkey in the sig to prevent replay
  • Loading branch information
kgmyatthu authored and urnotsam committed Oct 30, 2024
1 parent 9be4c34 commit 8f2f96d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Data/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,17 @@ export async function unsubscribeDataSender(

export function initSocketClient(node: NodeList.ConsensusNodeInfo): void {
if (config.VERBOSE) Logger.mainLogger.debug('Node Info to socket connect', node)

try {
const socketClient = ioclient.connect(`http://${node.ip}:${node.port}`, {
query: {
data: JSON.stringify(Crypto.sign({publicKey: State.getNodeInfo().publicKey})),
data: JSON.stringify(
Crypto.sign({
publicKey: State.getNodeInfo().publicKey,
timestamp: Date.now(),
intendedConsensor: node.publicKey
})
),
},
})
socketClients.set(node.publicKey, socketClient)
Expand Down

0 comments on commit 8f2f96d

Please sign in to comment.