Replies: 2 comments 2 replies
-
If you have Stream, you can send and receive any data you want. Use it for a handshake. |
Beta Was this translation helpful? Give feedback.
-
You can use InterceptUpgraded on the ConnectionGater to run your own handshake. This is called before the connection is added to the swarm for wider use. Otherwise, I think you'll have to maintain some kind of application state to check if the peer has been authenticated yet. You can also see if the pnet capability in go-libp2p is what you want. https://github.com/libp2p/go-libp2p/blob/master/options.go#L211 |
Beta Was this translation helpful? Give feedback.
-
I’ve implemented a p2p network using go-libp2p. I have an issue where I want to have an application layer handshake, for example - check network ID, or verify a certain type of cryptographic identity. I used streams to do it but as soon as a peer is added it is automatically exposed to all procotols which means that during my protocol handshake I can receive messages from this peer in pubsub for example.
Is there an easy way to add application-layer handshake? or should I just guard pubsub for example using a whitelist that is generated from my application-handshake?
I found there is ConnectionGater but haven't found an example of the usage.
Any pointing to resources will be very helpful.
Beta Was this translation helpful? Give feedback.
All reactions