@@ -23,12 +23,23 @@ type ConcurrentAgents struct {
23
23
agents map [string ]* consulapi.Client
24
24
config * ConsulConfig
25
25
lock sync.Mutex
26
+ client * http.Client
26
27
}
27
28
28
29
func NewAgents (config * ConsulConfig ) * ConcurrentAgents {
30
+ client := & http.Client {
31
+ Transport : & http.Transport {
32
+ Proxy : http .ProxyFromEnvironment ,
33
+ TLSClientConfig : & tls.Config {
34
+ InsecureSkipVerify : ! config .SslVerify ,
35
+ },
36
+ },
37
+ Timeout : config .Timeout ,
38
+ }
29
39
return & ConcurrentAgents {
30
40
agents : make (map [string ]* consulapi.Client ),
31
41
config : config ,
42
+ client : client ,
32
43
}
33
44
}
34
45
@@ -97,8 +108,9 @@ func (a *ConcurrentAgents) addAgent(agentHost string, agent *consulapi.Client) {
97
108
func (a * ConcurrentAgents ) createAgent (ipAddress string ) (* consulapi.Client , error ) {
98
109
config := consulapi .DefaultConfig ()
99
110
111
+ config .HttpClient = a .client
112
+
100
113
config .Address = fmt .Sprintf ("%s:%s" , ipAddress , a .config .Port )
101
- config .HttpClient .Timeout = a .config .Timeout
102
114
103
115
if a .config .Token != "" {
104
116
config .Token = a .config .Token
@@ -108,14 +120,6 @@ func (a *ConcurrentAgents) createAgent(ipAddress string) (*consulapi.Client, err
108
120
config .Scheme = "https"
109
121
}
110
122
111
- if ! a .config .SslVerify {
112
- config .HttpClient .Transport = & http.Transport {
113
- TLSClientConfig : & tls.Config {
114
- InsecureSkipVerify : true ,
115
- },
116
- }
117
- }
118
-
119
123
if a .config .Auth .Enabled {
120
124
config .HttpAuth = & consulapi.HttpBasicAuth {
121
125
Username : a .config .Auth .Username ,
0 commit comments