iroh icon indicating copy to clipboard operation
iroh copied to clipboard

iroh p2p lookup command

Open faassen opened this issue 3 years ago • 8 comments

ipfs id

returns a JSON data structure which contains a bunch of pieces of information:

  • id
  • publicKey
  • addresses
  • agent version (kubo version)
  • protocol version (ipfs/0.1.0)
  • protocols (a whole host of versions)

It strikes me there's a lot of overlap with #267

What's also interesting is that this command, suddenly, returns pretty-printed JSON. Do we want to do that? Or do we want to take a more structured approach to JSON support and go for a text-based structure ala:

agent_version = "iroh/0.1"
protocol_version = "ipfs/0.1.0"

instead and have a --json option that consistently produces JSON output (turning off progress bars for add and get too)?

faassen avatar Oct 03 '22 15:10 faassen

The iroh p2p id command needs to report:

  • its peer id
  • addresses of peers it knows about
  • various protocol version, including the ipfs version

Anything I missed?

faassen avatar Oct 04 '22 14:10 faassen

the more I think about it, the more this is all just a bad pattern to follow. I like the look of https://github.com/mxinden/libp2p-lookup a lot more, and find the tool generally more useful than what IPFS id does, both in terms of what and how it's reported.

A few adjustments for our context:

  1. I see no reason to separate dht and direct into different subcommands. I'd much rather try to parse a multiaddr first, dial that on successful parsing, then fall back to trying to parse a PeerID, using the DHT when a PeerID is given. Maybe there's some nuance I'm missing, but I doubt it given this is how kubo works.

  2. no need for a --network flag, just used the configured network.

While we're at it, why don't we switch the name of the command to lookup from id? Seems less confusing to me.

b5 avatar Oct 06 '22 02:10 b5

proposed help text:

> iroh p2p lookup --help
iroh-p2p-lookup
retrieve info about a node

USAGE:
    iroh p2p lookup <addr>

ARGS:
    <addr>    multiaddress or peer ID

OPTIONS:
    -h, --help    Print help information


Takes as input a peer ID or address and prints the output of the libp2p-identify
protocol. When provided with a peer ID, the address is looked up on the 
Network's Distributed Hash Table (DHT) before connecting to the node. When 
provided with a multiaddress, the connection is dialed directly.

b5 avatar Oct 06 '22 02:10 b5

Is there any reason why a separate ipfs p2p id command is needed? In Kubo, ipfs id would return your node's info, but ipfs id PeerID returns the same info for a different node

Winterhuman avatar Oct 06 '22 12:10 Winterhuman

@winterhuman I think it's under p2p because it won't work without a p2p node running, and we envision configurations without a p2p node with iroh cloud. Is that correct, @b5?

faassen avatar Oct 06 '22 13:10 faassen

@Winterhuman I think it's under p2p because it won't work without a p2p node running, and we envision configurations without a p2p node with iroh cloud. Is that correct, @b5?

No. There will be no iroh id top level command. Instead we're moving it down into p2p, which will work either offline or online. In the offline context, I expect the command to behave like https://github.com/mxinden/libp2p-lookup , which queries the DHT, attempts to dial the peer, then closes after receiving a response from the identify protocol.

Running iroh p2p id without any id should default to the node's own Peer ID. This lookup again should work both offline and online, but in both context will not need to make any network calls, and simply return the values that would be supplied as a response to an identify protocol request.

These are great questions though, and I'll work these responses into the help text for clarity.

And to reiterate, I think this command should be renamed to lookup, both to avoid confusion with kubo id, and because the name is more accurate imho

b5 avatar Oct 06 '22 20:10 b5

Is <addr> optional for iroh p2p lookup so that you can get the information for the node you're connected to? If not, how do you start getting your peer id or address so you can do a lookup for yourself?

faassen avatar Oct 10 '22 08:10 faassen

I think yes, no <addr> means grabbing your local information. Should be added to the documentation.

ramfox avatar Oct 13 '22 13:10 ramfox

closed by #372

b5 avatar Nov 02 '22 16:11 b5