dial.go 566 B

1234567891011121314151617181920212223242526
  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. package websocket
  6. import (
  7. "crypto/tls"
  8. "net"
  9. )
  10. func dialWithDialer(dialer *net.Dialer, config *Config) (conn net.Conn, err error) {
  11. switch config.Location.Scheme {
  12. case "ws":
  13. conn, err = dialer.Dial("tcp", parseAuthority(config.Location))
  14. case "wss":
  15. conn, err = tls.Dial("tcp", parseAuthority(config.Location), config.TlsConfig)
  16. default:
  17. err = ErrBadScheme
  18. }
  19. return
  20. }