Check peerID in all subscribed messages #222
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors the handler functions for P2P message topics in
server_helpers.goto improve peer identity verification and logging consistency. The main change is to ensure that the sender's peer ID (fromID) matches the peer ID in the message payload, which helps prevent spoofing and improves network security. Additional improvements include renaming variables for clarity and updating log messages for better traceability.Peer identity verification and security improvements:
handleBlockTopic,handleSubtreeTopic, andhandleRejectedTxTopicfunctions to check that the sender's peer ID (fromID) matches the peer ID in the message payload, logging an error and returning early if there is a mismatch. This helps prevent spoofed messages from being processed. [1] [2] [3]Code clarity and consistency:
fromparameter tofromIDin the handler functions to clarify its meaning and updated all usages throughout these functions. [1] [2] [3]fromIDterminology and to clarify the source of messages, improving readability and debugging. [1] [2] [3]Consistent peer tracking and metrics:
fromIDfor consistency and accuracy. [1] [2] [3] [4] [5]These changes collectively make the P2P server code more robust against spoofing, easier to maintain, and simpler to debug.