-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow adding prologue to noise connections #1663
Conversation
return newSecureSession(i.t, ctx, insecure, p, i.prologue, true) | ||
} | ||
|
||
func (t *Transport) WithNoiseOptions(opts NoiseOptions) sec.SecureTransport { |
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.
Why can't this be a normal constructor option?
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.
This is because the noise transport has both transport level and session level options. eg. The private key could be shared among multiple different connections, but the prologue can be unique to each connection.
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.
I can rename this to WithSessionOptions
manet "github.com/multiformats/go-multiaddr/net" | ||
) | ||
|
||
type NoiseOptions struct { |
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.
Please avoid config structs and use the normal config function pattern.
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.
I considered that but want to avoid exposing the intermediate transport.
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.
lgtm, module a minor nit in the test case.
p2p/security/noise/transport_test.go
Outdated
go func() { | ||
defer close(done) | ||
tpt, err := initTransport. | ||
WithSessionOptions(Prologue([]byte("testtesttest"))) |
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.
Nit: no line break.
Your choice of this prologue doesn't make this easy to read.
@marten-seemann It looks like the previous commit failed the tests because |
Yeah, that's a known flaky test. |
Allows adding the prologue to an existing noise transport. This is for potential use in implementing the webrtc transport.
Related discussion: libp2p/specs#412 (comment)