Commit 9c5bf9c2 authored by Nemanja Zbiljić's avatar Nemanja Zbiljić Committed by GitHub

If P2P connection exists compare overlay address (#1059)

parent f365a29a
......@@ -336,6 +336,10 @@ func (k *Kad) connect(ctx context.Context, peer swarm.Address, ma ma.Multiaddr,
i, err := k.p2p.Connect(ctx, ma)
if err != nil {
if errors.Is(err, p2p.ErrAlreadyConnected) {
if !i.Overlay.Equal(peer) {
return errOverlayMismatch
}
return nil
}
......
......@@ -453,8 +453,12 @@ func (s *Service) Connect(ctx context.Context, addr ma.Multiaddr) (address *bzz.
remoteAddr := addr.Decapsulate(hostAddr)
if _, found := s.peers.isConnected(info.ID, remoteAddr); found {
return nil, p2p.ErrAlreadyConnected
if overlay, found := s.peers.isConnected(info.ID, remoteAddr); found {
address = &bzz.Address{
Overlay: overlay,
Underlay: addr,
}
return address, p2p.ErrAlreadyConnected
}
if err := s.connectionBreaker.Execute(func() error { return s.host.Connect(ctx, *info) }); err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment