Skip to content

fix(identify): complete Identify on relayed connections to allow DCUtR initiation #25

Description

@SilverFire

Summary

In BasicHost.newStream and IdentifyService._NetNotifiee.connected, Identify was explicitly skipped for circuit-relay connections (conn.state.transport == 'circuit-relay').

Problem

Reference libp2p implementations (e.g. go-libp2p v0.47.0 holepuncher.go) require IdentifyWait(conn) to complete on inbound relayed connections before calling DirectConnect(remotePeer).

Because Dart skipped Identify on relayed connections:

  1. When a Dart peer connected to a Go gateway via relay, Identify was never executed.
  2. Go's IdentifyWait never completed for the relayed connection.
  3. Go never learned Dart's supported protocols (such as /libp2p/dcutr) or Dart's observed addresses.
  4. Go never triggered DCUtR hole punching (DirectConnect).

In addition:

  • identifyWait contained a control-flow bug where alreadyIdentified / connClosed exited _connsMutex.synchronized early without setting completerToAwait, emitting false [IDENTIFY-WAIT-NO-COMPLETER] warning logs on reused connections.
  • _NetNotifiee.disconnected removed connections from _conns without completing pending identifyWaitCompleter instances with an error on connection drop, leaving callers hanging.

Proposed Fix

  • Remove the isRelayConn skip in BasicHost.newStream and IdentifyService._NetNotifiee.connected.
  • Fix identifyWait control flow to return cleanly when already identified or closed.
  • Reject pending identifyWaitCompleter instances with StateError on connection disconnect.
  • Add deterministic Dart↔Go interop test verifying relayed Identify completion and automatic Go-initiated /libp2p/dcutr stream creation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions