direct.go 832 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2011 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. package proxy
  5. import (
  6. "context"
  7. "net"
  8. )
  9. type direct struct{}
  10. // Direct implements Dialer by making network connections directly using net.Dial or net.DialContext.
  11. var Direct = direct{}
  12. var (
  13. _ Dialer = Direct
  14. _ ContextDialer = Direct
  15. )
  16. // Dial directly invokes net.Dial with the supplied parameters.
  17. func (direct) Dial(network, addr string) (net.Conn, error) {
  18. return net.Dial(network, addr)
  19. }
  20. // DialContext instantiates a net.Dialer and invokes its DialContext receiver with the supplied parameters.
  21. func (direct) DialContext(ctx context.Context, network, addr string) (net.Conn, error) {
  22. var d net.Dialer
  23. return d.DialContext(ctx, network, addr)
  24. }