Skip to content

Commit

Permalink
Websocket fix (#623)
Browse files Browse the repository at this point in the history
* Fix panic when Tr is nil

* Explicitly call handshake for tls connection
  • Loading branch information
ErikPelli authored Jan 12, 2025
1 parent dd21e8d commit 40759cc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions https.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (proxy *ProxyHttpServer) dial(ctx *ProxyCtx, network, addr string) (c net.C
return ctx.Dialer(ctx.Req.Context(), network, addr)
}

if proxy.Tr.DialContext != nil {
if proxy.Tr != nil && proxy.Tr.DialContext != nil {
return proxy.Tr.DialContext(ctx.Req.Context(), network, addr)
}

Expand Down Expand Up @@ -651,5 +651,9 @@ func (proxy *ProxyHttpServer) initializeTLSconnection(
if ctx.InitializeTLS != nil {
return ctx.InitializeTLS(targetConn, tlsConfig)
}
return tls.Client(targetConn, tlsConfig), nil
tlsConn := tls.Client(targetConn, tlsConfig)
if err := tlsConn.Handshake(); err != nil {
return nil, err
}
return tlsConn, nil
}

0 comments on commit 40759cc

Please sign in to comment.