How to identify my peer?

#1

Hi,

I am write a program that will provide some feature through a IPFS node. I want to able to identify my node from all peers. What’s the best way to do it? what I can think of it to encode a special key into it’s name or id or other information which will be returned from “ipfs swarm peers “ . but it seems IPFS does not allow that. Are there other ways to do it?

Any suggestion is welcome

Thanks

Jeff

#2

Your peer ID is reported back in the output of ipfs id.

#3

Maybe I didn’t make it clear. My program will run on many partners’ computer. There is no way I know the exact id. I was thinking to add some special informtion like a string in the id or othesr, so the node from my code could identify each other.

#4

Why do you need to know which peers have your application running on them?

Perhaps a pub sub channel would work if the number of nodes aren’t too high. The application on each node could publish its peer ID to the application-specific channel at some interval so other nodes who are listening can know who they are.

#5

Because only my nodes have the features I created. Pubsub is a way but I heard it’s not very reliable and kinda heavy for this purpose.

#6

There is no way to identify your peers from something like swarm peers. Without knowing what “service” they are going to provide and how it is hard to understand why you want your peers to be easily identifiable like that.

Also, IPFS does not currently have any “service discovery” mechanism by default (as in, announcing that a certain peer supports certain libp2p service), so you’d have to build your own (using pubsub as suggested above, or writing custom values directly to the DHT perhaps).

#7

Thanks. Then I want to suggest to add such capacity. It could be very simple, like allow a peer to set a custom string and other peers are able to get it from swarm peers. It will be very light weight and open a lot of possiblities.
Here is an example,

we can write some code to make the node act as a http proxy (I believe some project already did it). If someone want to use this service, he must be able to find out such node from all peers. With this capacity, the proxy node could just SetCustomString(“httpProxy”). and other node could look for this string to identify the proxy.

#8

This already happens at the protocol level. Your peer can test if other peers support certain libp2p protocol. What doesn’t exist, afaik, is a way to “find peers that support protocol X”.

#10

Do you mean get support protocol info to identify? I tried to get it from ‘ipfs swarm peers —stream” and I can see some protocol info from connected peers, like ‘/ipfs/kad/1.0.0/‘ , but I don’t see the protocol I created through ‘ipfs p2p listen’, for example ‘/x/dd/1.0’, appear under my node info. Any suggestion ?

Thanks

#11

It looks like this thread might have an answer.