mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 19:09:58 +00:00
TUN-7125: Add management streaming logs WebSocket protocol
This commit is contained in:
@@ -142,7 +142,7 @@ func (p *Proxy) ProxyHTTP(
|
||||
}
|
||||
return nil
|
||||
case ingress.HTTPLocalProxy:
|
||||
originProxy.ServeHTTP(w, req)
|
||||
p.proxyLocalRequest(originProxy, w, req, isWebsocket)
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("Unrecognized service: %s, %t", rule.Service, originProxy)
|
||||
@@ -306,6 +306,17 @@ func (p *Proxy) proxyStream(
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Proxy) proxyLocalRequest(proxy ingress.HTTPLocalProxy, w connection.ResponseWriter, req *http.Request, isWebsocket bool) {
|
||||
if isWebsocket {
|
||||
// These headers are added since they are stripped off during an eyeball request to origintunneld, but they
|
||||
// are required during the Handshake process of a WebSocket request.
|
||||
req.Header.Set("Connection", "Upgrade")
|
||||
req.Header.Set("Upgrade", "websocket")
|
||||
req.Header.Set("Sec-Websocket-Version", "13")
|
||||
}
|
||||
proxy.ServeHTTP(w, req)
|
||||
}
|
||||
|
||||
type bidirectionalStream struct {
|
||||
reader io.Reader
|
||||
writer io.Writer
|
||||
|
Reference in New Issue
Block a user