Skip to content

Commit

Permalink
fix: warn on mismatched underlay
Browse files Browse the repository at this point in the history
  • Loading branch information
notanatol committed Sep 1, 2021
1 parent 5b25866 commit 2c27287
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/p2p/libp2p/internal/handshake/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package handshake

import (
"bytes"
"context"
"errors"
"fmt"
Expand Down Expand Up @@ -144,7 +145,11 @@ func (s *Service) Handshake(ctx context.Context, stream p2p.Stream, peerMultiadd
return nil, fmt.Errorf("read synack message: %w", err)
}

observedUnderlay, err := ma.NewMultiaddrBytes(resp.Syn.ObservedUnderlay)
if !bytes.Equal(fullRemoteMABytes, resp.Syn.ObservedUnderlay) {
s.logger.Warningf("provided underlay %s does not match expected: %s", swarm.NewAddress(resp.Syn.ObservedUnderlay), swarm.NewAddress(peerMultiaddr.Bytes()))
}

observedUnderlay, err := ma.NewMultiaddrBytes(fullRemoteMABytes)
if err != nil {
return nil, ErrInvalidSyn
}
Expand Down

0 comments on commit 2c27287

Please sign in to comment.