Skip to content

Commit

Permalink
Clear URL User before creating websocket connection (allowing MQTT us…
Browse files Browse the repository at this point in the history
…ername/password to be specified in URL)

Closes #623
  • Loading branch information
MattBrittan committed Dec 22, 2022
1 parent d9dea69 commit 3a8066f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions netconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ import (
func openConnection(uri *url.URL, tlsc *tls.Config, timeout time.Duration, headers http.Header, websocketOptions *WebsocketOptions, dialer *net.Dialer) (net.Conn, error) {
switch uri.Scheme {
case "ws":
conn, err := NewWebsocket(uri.String(), nil, timeout, headers, websocketOptions)
dialURI := uri // #623 - Gorilla Websockets does not accept URL's where uri.User != nil
uri.User = nil
conn, err := NewWebsocket(dialURI.String(), nil, timeout, headers, websocketOptions)
return conn, err
case "wss":
conn, err := NewWebsocket(uri.String(), tlsc, timeout, headers, websocketOptions)
dialURI := uri // #623 - Gorilla Websockets does not accept URL's where uri.User != nil
uri.User = nil
conn, err := NewWebsocket(dialURI.String(), tlsc, timeout, headers, websocketOptions)
return conn, err
case "mqtt", "tcp":
allProxy := os.Getenv("all_proxy")
Expand Down

0 comments on commit 3a8066f

Please sign in to comment.