Skip to content

feat: add identify protocol example #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

acul71
Copy link

@acul71 acul71 commented May 16, 2025

Description

This PR fix issue #221 and adds a new example demonstrating the usage of the identify protocol in js-libp2p. The example shows how to:

  • Set up a libp2p node with the identify protocol enabled
  • Create a listener node that accepts incoming connections
  • Create a dialer node that connects to the listener
  • Exchange and display identify information between peers

The example includes:

  • A listener node that starts and displays its peer ID and multiaddrs
  • A dialer node that connects to the listener using a provided multiaddr
  • Automatic triggering of the identify protocol when connections are established
  • Display of detailed identify information including:
    • Peer ID
    • Agent Version
    • Protocol Version
    • Supported protocols
    • Observed address
    • Listen addresses

The example is well-documented with:

  • Clear setup instructions
  • Detailed explanation of how it works
  • Example output showing what to expect
  • Node.js version requirements
  • Links to relevant documentation

Notes & open questions

  • The example uses Node.js version 20 or higher as required by some dependencies
  • The identify protocol is configured using the new services-based approach in libp2p v2
  • The example demonstrates both TCP and WebSocket transports
  • The example includes mDNS peer discovery for local network discovery

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

@acul71
Copy link
Author

acul71 commented May 16, 2025

@achingbrain
Since I have to write interop tests to test interoperability between py-libp2p and js-libp2p I wrote this example. Will add a test soon.
Bye Luca

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant