forked from jshiffer/matterbridge
2f33fe86f5
* Update dependencies and build to go1.22 * Fix api changes wrt to dependencies * Update golangci config
30 lines
678 B
Go
30 lines
678 B
Go
// Copyright 2015 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package websocket
|
|
|
|
import (
|
|
"context"
|
|
"crypto/tls"
|
|
"net"
|
|
)
|
|
|
|
func dialWithDialer(ctx context.Context, dialer *net.Dialer, config *Config) (conn net.Conn, err error) {
|
|
switch config.Location.Scheme {
|
|
case "ws":
|
|
conn, err = dialer.DialContext(ctx, "tcp", parseAuthority(config.Location))
|
|
|
|
case "wss":
|
|
tlsDialer := &tls.Dialer{
|
|
NetDialer: dialer,
|
|
Config: config.TlsConfig,
|
|
}
|
|
|
|
conn, err = tlsDialer.DialContext(ctx, "tcp", parseAuthority(config.Location))
|
|
default:
|
|
err = ErrBadScheme
|
|
}
|
|
return
|
|
}
|