-
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
feat: Implement Custom TCP Dialers #3166
Conversation
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.
The change looks good except for some naming preferences.
- The pattern is to use the provided
Dialer
for dialling. So, do we need to name itCustom
? CustomTCPDialer
reads like it should be theDialer
not something that returns aDialer
.
p2p/transport/tcp/tcp.go
Outdated
type ContextDialer interface { | ||
DialContext(ctx context.Context, network, address string) (net.Conn, error) | ||
} | ||
type CustomTCPDialer func(raddr ma.Multiaddr) (ContextDialer, error) |
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: DialerForAddr
p2p/transport/tcp/tcp.go
Outdated
func WithCustomDialer(d CustomTCPDialer) Option { | ||
return func(tr *TcpTransport) error { | ||
tr.customDialer = d | ||
return nil | ||
} | ||
} |
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: WithDialerForAddr
looking at this today, sorry for the delay |
Thanks @parkan. If this works for you, it'll be included in the next release (hopefully today) |
in practice I think this should work for us 👍 what's mostly on my mind is how similar functionality is already implemented in net.proxy and whether anything in there should be leveraged or used as an example to follow 🤔 looking at it closely RegisterDialerType is actually a good place to inject a http proxy dialer for us, though that doesn't generalize to other dialer behaviors that don't map to Url schemes (as a side note the onion transport uses net/proxy already: https://github.com/OpenBazaar/go-onion-transport/blob/master/onion_transport.go#L136) |
for example the PerHost functionality is very similar to |
I don't want to spend too much time bikeshedding an API that a handful of people will use. I see this as an escape hatch that enables your use case, but not something that most users should use. With some finangling, I believe the |
@MarcoPolo totally fair, thank you for getting this in 💪 |
closes #3155. @parkan does this work for your use case? See the libp2p_test.go for an example on how to set this up.