-
Notifications
You must be signed in to change notification settings - Fork 8
make it possible to skip the handshake negotiation #87
base: master
Are you sure you want to change the base?
Conversation
listener.go
Outdated
if secProto.Code == 0 { | ||
return l.Listener.Multiaddr() | ||
} | ||
return l.Listener.Multiaddr().Encapsulate(ma.StringCast("/" + secProto.Name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any better solution for this? This is... ugly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the plan for exposing multiple handshakes over a single endpoint?
The idea is that every instance of a |
ad6ad0a
to
77d5bf0
Compare
This PR makes changes to the upgrader, so we can use it to handle both multiaddrs with and without the security protocol.
Depends on libp2p/go-libp2p-core#215.
For multiaddrs not containing the security protocol:
Upgrader.SecureMuxer
needs to be set (this is the same as it is now). The upgrader will then use multistream to negotiate the security protocol.For multiaddrs containing the security protocol:
Upgrader.SecureTransport
needs to be set (andUpgrader.SecureMuxer
must not be set). In that case, the upgrader will jump into the cryptographic handshake right after having dialed / accepted thenet.Conn
.This PR also adds a
Upgrader.SecurityProtocol() ma.Protocol
method, which returns the security protocol of theSecureTransport
. Perhaps a bit surprisingly, this returns the zero-value ofma.Protocol
in case aSecureMuxer
is set. We could have introduced avalid bool
here, but I chose not to do so, as we'll be dropping support for theSecureMuxer
soon-ish, and having just a single return value will be nicer then.