1// Copyright 2016 go-dockerclient 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
5// +build !windows
6
7package docker
8
9import (
10	"context"
11	"net"
12	"net/http"
13)
14
15// initializeNativeClient initializes the native Unix domain socket client on
16// Unix-style operating systems
17func (c *Client) initializeNativeClient(trFunc func() *http.Transport) {
18	if c.endpointURL.Scheme != unixProtocol {
19		return
20	}
21	sockPath := c.endpointURL.Path
22
23	tr := trFunc()
24
25	tr.Dial = func(network, addr string) (net.Conn, error) {
26		return c.Dialer.Dial(unixProtocol, sockPath)
27	}
28	tr.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
29		return c.Dialer.Dial(unixProtocol, sockPath)
30	}
31	c.HTTPClient.Transport = tr
32}
33