Skip to content

Commit

Permalink
Fix ineffective assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikPelli committed Dec 27, 2024
1 parent 606639f commit 15d9bb4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@ func (proxy *ProxyHttpServer) serveWebsocketTLS(
tlsConfig *tls.Config,
clientConn *tls.Conn,
) {
host := req.URL.Host
// Port is optional in req.URL.Host, in this case SplitHostPort returns
// an error, and we add the default port
host, port, err := net.SplitHostPort(req.URL.Host)
_, port, err := net.SplitHostPort(req.URL.Host)
if err != nil || port == "" {
host = net.JoinHostPort(req.URL.Host, "443")
} else {
// We already had a port, just use it
host = req.URL.Host
}
targetURL := url.URL{Scheme: "wss", Host: host, Path: req.URL.Path}

Expand Down Expand Up @@ -68,14 +66,12 @@ func (proxy *ProxyHttpServer) serveWebsocketHttpOverTLS(
req *http.Request,
clientConn *tls.Conn,
) {
host := req.URL.Host
// Port is optional in req.URL.Host, in this case SplitHostPort returns
// an error, and we add the default port
host, port, err := net.SplitHostPort(req.URL.Host)
_, port, err := net.SplitHostPort(req.URL.Host)
if err != nil || port == "" {
host = net.JoinHostPort(req.URL.Host, "80")
} else {
// We already had a port, just use it
host = req.URL.Host
}
targetURL := url.URL{Scheme: "ws", Host: host, Path: req.URL.Path}

Expand Down

0 comments on commit 15d9bb4

Please sign in to comment.