Skip to content

Commit

Permalink
Release 5.0.0 merge master (#12)
Browse files Browse the repository at this point in the history
* Fixed: Remove data race around default dialer (#6)

* Use gorilla DialContext (vulcand#158)

* Handle Te header when http2 (vulcand#157)

* fix: buffer error and go1.11. (vulcand#159)

* fix: buffer error and go1.11.

* chore: add go1.11 in Travis.

* review: comment.

* fix: use internal logger. (vulcand#160)

* fix: body should never be nil (vulcand#162)

* Pass host header for Websocket. (vulcand#163)

* feat: pass host header for Websocket.

* add tests.

* fix: golint. (vulcand#165)

* Flush when we have unannonced trailers (vulcand#168)

* Flush when we have unannonced trailers

* Remove 1.8, not supported in golint anymore

* add missing callback on close of hijacked connections (vulcand#175)

* Allowing sticky session's affinity cookies to be created with more options such as HttpOnly or Secure (vulcand#174)

* Ensuring the CookieOption struct's fields are exported (vulcand#179)

* ensuring the CookieOption struct's fields are exported (vulcand#174)

* dep ensuring

* Updating failing test, I should pay more attention

* dep ensuring has caused problems, reverting. Although this is really strange that dep should do this

* chore: migrate to go module. (vulcand#182)

* Update README.md

Go library change godoc to "pkg.go.dev"

* feat: add more cookie options. (vulcand#195)

* chore: update dependencies.

* feat: add more cookie options.

* chore: update travis configuration.

* Add Fallback setter on CircuitBreaker (vulcand#201)

Signed-off-by: Sylvain Rabot <[email protected]>

* review.

* doc: buffer.go: s/request/response/ (vulcand#172)

* doc: typo fix /serveHTTP/serveWebSocket/s (vulcand#176)

* Make the MakeRateError delay field public so that custom RateErrHandlers can be more easily written (vulcand#206)

* fix typo (vulcand#212)

* Fix panics on ratelimit period (division by zero) (vulcand#213)

* Bump to go1.16 (vulcand#214)

* Add a mechanism to format the sticky cookie value (vulcand#216)

Co-authored-by: Tom Moulard <[email protected]>
Co-authored-by: M <[email protected]>
Co-authored-by: Sylvain Rabot <[email protected]>

* Do not use global websocket.DefaultDialer

This change makes it so that each forward gets its own dialer rather
then all sharing the global `websocket.DefaultDialer`. It fixes the flaky
`TestWebSocketNumGoRoutine` test and allows `WebsocketTLSClientConfig` to
set a different TLS config than the one used in the http `RoundTripper`,
the TLS config in the http `RoundTripper` will still be used as a
fallback if one wasn't set by the user.

Adds the new `optSetter` `WebsocketNetDialContext` to set a custom
DialContet for WebSocket use.

-  `go test -run=TestWebSocketNumGoRoutine -count=100 ./forward` now
   passes. Removed the skip directive.
-  Closes vulcand#199
-  Closes vulcand#125

* Revert un-skipping test

* Update: Cleanup local and remote merged changes

Co-authored-by: SALLEYRON Julien <[email protected]>
Co-authored-by: Ludovic Fernandez <[email protected]>
Co-authored-by: Michael <[email protected]>
Co-authored-by: ravilr <[email protected]>
Co-authored-by: Amir Keibi <[email protected]>
Co-authored-by: colynn.liu <[email protected]>
Co-authored-by: Sylvain Rabot <[email protected]>
Co-authored-by: Fernandez Ludovic <[email protected]>
Co-authored-by: colynn.liu <[email protected]>
Co-authored-by: Wes Turner <[email protected]>
Co-authored-by: Ben Yanke <[email protected]>
Co-authored-by: Peter C <[email protected]>
Co-authored-by: Iman Sahebi <[email protected]>
Co-authored-by: Douglas De Toni Machado <[email protected]>
Co-authored-by: Romain <[email protected]>
Co-authored-by: Jean-Baptiste Doumenjou <[email protected]>
Co-authored-by: Tom Moulard <[email protected]>
Co-authored-by: M <[email protected]>
Co-authored-by: Clifton Kaznocha <[email protected]>
Co-authored-by: Clifton Kaznocha <[email protected]>

* fixed: forwarder did not set deadline for ws connections (#11)

* fixed: forwarder did not set deadline for ws connections

* remove debug prints

Co-authored-by: Primalmotion <[email protected]>

Co-authored-by: Eric Powers <[email protected]>
Co-authored-by: SALLEYRON Julien <[email protected]>
Co-authored-by: Ludovic Fernandez <[email protected]>
Co-authored-by: Michael <[email protected]>
Co-authored-by: ravilr <[email protected]>
Co-authored-by: Amir Keibi <[email protected]>
Co-authored-by: colynn.liu <[email protected]>
Co-authored-by: Sylvain Rabot <[email protected]>
Co-authored-by: Fernandez Ludovic <[email protected]>
Co-authored-by: colynn.liu <[email protected]>
Co-authored-by: Wes Turner <[email protected]>
Co-authored-by: Ben Yanke <[email protected]>
Co-authored-by: Peter C <[email protected]>
Co-authored-by: Iman Sahebi <[email protected]>
Co-authored-by: Douglas De Toni Machado <[email protected]>
Co-authored-by: Romain <[email protected]>
Co-authored-by: Jean-Baptiste Doumenjou <[email protected]>
Co-authored-by: Tom Moulard <[email protected]>
Co-authored-by: M <[email protected]>
Co-authored-by: Clifton Kaznocha <[email protected]>
Co-authored-by: Clifton Kaznocha <[email protected]>
Co-authored-by: primalmotion <[email protected]>
Co-authored-by: Primalmotion <[email protected]>
  • Loading branch information
24 people authored Sep 2, 2021
1 parent 5fac166 commit c0a043b
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions forward/fwd.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ func WebsocketNetDialContext(dialContext func(ctx context.Context, network strin
}
}

// WebsocketPongWait sets the max time to wait for a pong
// before closing the connection.
func WebsocketPongWait(wait time.Duration) optSetter {
return func(f *Forwarder) error {
f.httpForwarder.websocketPongWait = wait
return nil
}
}

// ErrorHandler is a functional argument that sets error handler of the server
func ErrorHandler(h utils.ErrorHandler) optSetter {
return func(f *Forwarder) error {
Expand Down Expand Up @@ -202,6 +211,7 @@ type httpForwarder struct {
bufferPool httputil.BufferPool
websocketConnectionClosedHook func(req *http.Request, conn net.Conn)
websocketDialer *websocket.Dialer
websocketPongWait time.Duration
}

const defaultFlushInterval = time.Duration(100) * time.Millisecond
Expand All @@ -218,7 +228,10 @@ type UrlForwardingStateListener func(*url.URL, int)
// New creates an instance of Forwarder based on the provided list of configuration options
func New(setters ...optSetter) (*Forwarder, error) {
f := &Forwarder{
httpForwarder: &httpForwarder{log: &internalLogger{Logger: log.StandardLogger()}},
httpForwarder: &httpForwarder{
log: &internalLogger{Logger: log.StandardLogger()},
websocketPongWait: 30 * time.Second,
},
handlerContext: &handlerContext{},
}

Expand Down Expand Up @@ -420,10 +433,16 @@ func (f *httpForwarder) serveWebSocket(w http.ResponseWriter, req *http.Request,
})

src.SetPongHandler(func(data string) error {
return forward(websocket.PongMessage, bytes.NewReader([]byte(data)))
if err := forward(websocket.PongMessage, bytes.NewReader([]byte(data))); err != nil {
return err
}
return src.SetReadDeadline(time.Now().Add(f.websocketPongWait))
})

for {

src.SetReadDeadline(time.Now().Add(f.websocketPongWait))

msgType, reader, err := src.NextReader()

if err != nil {
Expand Down

0 comments on commit c0a043b

Please sign in to comment.