-
Notifications
You must be signed in to change notification settings - Fork 13
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
http_proxy: support multi-addresses listening #654
Conversation
I'd suggest to extend the port syntax we use in the current flag
Example:
Maybe the port range is too much and can be ignored. The logic should be that we shall always be able to listen to one or more ports. |
@@ -89,24 +91,64 @@ type ListenerCallbacks interface { | |||
|
|||
// OnTLSHandshakeError is called after a TLS handshake errors out. | |||
OnTLSHandshakeError(*tls.Conn, error) | |||
|
|||
// OnBindError is called when a listener fails to bind to an address. | |||
OnBindError(address string, err 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.
Should go before TLS things.
net.go
Outdated
type Listener struct { | ||
Address string | ||
Addresses []string |
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.
Listener changes should be in a separate commit.
net.go
Outdated
Log log.Logger | ||
TLSConfig *tls.Config | ||
HandshakeTimeout time.Duration | ||
ReadLimit int64 | ||
WriteLimit int64 | ||
Callbacks ListenerCallbacks | ||
|
||
listener net.Listener | ||
ls []net.Listener |
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 not listeners
net.go
Outdated
if l.Callbacks != nil { | ||
l.Callbacks.OnBindError(addr, err) | ||
} | ||
if i == 0 { |
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 think that when using more than one port they are all equal.
return ll, nil | ||
} | ||
|
||
func (l *Listener) acceptLoop(ll net.Listener) { |
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'd use errgroup
with anonymous function instead of creating this and closeCh.
net_test.go
Outdated
@@ -70,3 +122,6 @@ func (m *mockListenerCallback) OnTLSHandshakeError(_ *tls.Conn, err error) { | |||
} | |||
m.donec <- 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.
Order.
As for the integration, the main part should be in the listener and it should go to the HttpServer. |
966c19a
to
e8fde91
Compare
This patch moves tls configuration from http.Server to forwarder.Listener. It makes TLSHandshakeTimeout applicable.
The optional addresses to listen on. Bind to this addresses may fail.
e8fde91
to
4b67218
Compare
We have Listen and Listener struct, http server using the former http proxy using the latter. I suggest the following refactoring
The MultiListeners idea may not be the best in general
Having said that maybe the Listener struct should be removed altogether. I'm thinking we should move net.go to a dedicated package ex. |
The All of that would not be a problem if we focused on file based configuration only - say we would have listener config object like Envoy. Then you could add optional field to it. We also have protocol and bunch of other stuff that make adding multiple addresses imbalance other configurations. Maybe we are solving wrong problem and this should be done on a script level? |
What do you have in mind? The problem is described in #629
I'd rather have some way to assign properties to listeners, not sure how to make it work with CLI.
hmm... #629 ? |
@waggledans #629 points to a doc that says
What that even means? Why not use a script to launch a bunch of forwarders instead - what it the benefit of integrating it. |
All these questions indicate that we need to improve Sauce Labs docs if it's not clear from the description. Let's have this discussion elsewhere (we should have had it BEFORE the implementation).
Absolutely not. It's 20-30 ports, I don't think so. |
Let's split the work and move the port forwarding to separate feature #669 |
This patch adds multi-addresses listener.
Fixes #629