direct.go 743 B

1234567891011121314151617181920212223242526
  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 is a direct proxy: one that makes network connections directly.
  11. var Direct = direct{}
  12. // Dial directly invokes net.Dial with the supplied parameters.
  13. func (direct) Dial(network, addr string) (net.Conn, error) {
  14. return net.Dial(network, addr)
  15. }
  16. // DialContext instantiates a net.Dialer and invokes its DialContext receiver with the supplied parameters.
  17. func (direct) DialContext(ctx context.Context, network, addr string) (net.Conn, error) {
  18. var d net.Dialer
  19. return d.DialContext(ctx, network, addr)
  20. }