dialdialer.go 731 B

1234567891011121314151617181920212223242526272829
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build go1.3
  5. // We only compile this with Go 1.3+ because previously tls.DialWithDialer
  6. // wasn't available. The dial.go file is used for previous Go versions.
  7. package websocket
  8. import (
  9. "crypto/tls"
  10. "net"
  11. )
  12. func dialWithDialer(dialer *net.Dialer, config *Config) (conn net.Conn, err error) {
  13. switch config.Location.Scheme {
  14. case "ws":
  15. conn, err = dialer.Dial("tcp", parseAuthority(config.Location))
  16. case "wss":
  17. conn, err = tls.DialWithDialer(dialer, "tcp", parseAuthority(config.Location), config.TlsConfig)
  18. default:
  19. err = ErrBadScheme
  20. }
  21. return
  22. }