blob: 3d66bdef9d7493931859e181d22dff1892b8d1ef [file] [log] [blame]
Scott Bakered4efab2020-01-13 19:12:25 -08001// 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
5package proxy
6
7import (
divyadesai19009132020-03-04 12:58:08 +00008 "context"
Scott Bakered4efab2020-01-13 19:12:25 -08009 "net"
10)
11
12type direct struct{}
13
divyadesai19009132020-03-04 12:58:08 +000014// Direct implements Dialer by making network connections directly using net.Dial or net.DialContext.
Scott Bakered4efab2020-01-13 19:12:25 -080015var Direct = direct{}
16
divyadesai19009132020-03-04 12:58:08 +000017var (
18 _ Dialer = Direct
19 _ ContextDialer = Direct
20)
21
22// Dial directly invokes net.Dial with the supplied parameters.
Scott Bakered4efab2020-01-13 19:12:25 -080023func (direct) Dial(network, addr string) (net.Conn, error) {
24 return net.Dial(network, addr)
25}
divyadesai19009132020-03-04 12:58:08 +000026
27// DialContext instantiates a net.Dialer and invokes its DialContext receiver with the supplied parameters.
28func (direct) DialContext(ctx context.Context, network, addr string) (net.Conn, error) {
29 var d net.Dialer
30 return d.DialContext(ctx, network, addr)
31}