Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/peerinfo/adhoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func DoOnce(ctx context.Context, p2pNode host.Host, peerID peer.ID) (*pbv1.PeerI
resp := new(pbv1.PeerInfo)

err := p2p.SendReceive(ctx, p2pNode, peerID, req, resp, protocolID2,
p2p.WithSendReceiveRTT(rttCallback), p2p.WithSendMetricTopic("peerinfo_adhoc"))
p2p.WithSendReceiveRTT(rttCallback), p2p.WithSendMetricTopic("peerinfo_adhoc"), p2p.WithReadLimit(maxPeerInfoMsgSize))
if err != nil {
return nil, 0, false, err
}
Expand Down
8 changes: 5 additions & 3 deletions app/peerinfo/peerinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import (
)

const (
period = time.Minute
protocolID2 protocol.ID = "/charon/peerinfo/2.0.0"
period = time.Minute
protocolID2 protocol.ID = "/charon/peerinfo/2.0.0"
maxPeerInfoMsgSize = 1 << 20 // 1MB, PeerInfo messages are < 1KB in practice.
)

var gitHashMatch = regexp.MustCompile("^[0-9a-f]{7}$")
Expand Down Expand Up @@ -105,6 +106,7 @@ func newInternal(p2pNode host.Host, peers []peer.ID, version version.SemVer, loc
Nickname: nickname,
}, true, nil
},
p2p.WithReadLimit(maxPeerInfoMsgSize),
)

// Maps peers to their nickname
Expand Down Expand Up @@ -197,7 +199,7 @@ func (p *PeerInfo) sendOnce(ctx context.Context, now time.Time) {

resp := new(pbv1.PeerInfo)

err := p.sendFunc(ctx, p.p2pNode, peerID, req, resp, protocolID2, p2p.WithSendReceiveRTT(rttCallback), p2p.WithSendMetricTopic("peerinfo"))
err := p.sendFunc(ctx, p.p2pNode, peerID, req, resp, protocolID2, p2p.WithSendReceiveRTT(rttCallback), p2p.WithSendMetricTopic("peerinfo"), p2p.WithReadLimit(maxPeerInfoMsgSize))
if err != nil {
return // Logging handled by send func.
} else if resp.GetSentAt() == nil || resp.GetStartedAt() == nil {
Expand Down
Loading