update winrm to use keepalives

This commit is contained in:
Matthew Hooker
2017-06-01 15:16:20 -07:00
parent e01cd49175
commit 5fa704e3df
4 changed files with 21 additions and 4 deletions
+7
View File
@@ -3,7 +3,9 @@ package winrm
import (
"fmt"
"io/ioutil"
"net"
"strings"
"time"
"github.com/masterzen/azure-sdk-for-go/core/http"
"github.com/masterzen/azure-sdk-for-go/core/tls"
@@ -22,10 +24,15 @@ func (c *ClientAuthRequest) Transport(endpoint *Endpoint) error {
}
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: endpoint.Insecure,
Certificates: []tls.Certificate{cert},
},
Dial: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
ResponseHeaderTimeout: endpoint.Timeout,
}
+2
View File
@@ -18,6 +18,8 @@ type Endpoint struct {
HTTPS bool
// set the flag true for skipping ssl verifications
Insecure bool
// if set, used to verify the hostname on the returned certificate
TLSServerName string
// pointer pem certs, and key
CACert []byte // cert auth to intdetify the server cert
Key []byte // public key for client auth connections
+7
View File
@@ -4,8 +4,10 @@ import (
"crypto/tls"
"fmt"
"io/ioutil"
"net"
"net/http"
"strings"
"time"
"github.com/masterzen/winrm/soap"
)
@@ -44,7 +46,12 @@ func (c *clientRequest) Transport(endpoint *Endpoint) error {
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: endpoint.Insecure,
ServerName: endpoint.TLSServerName,
},
Dial: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
ResponseHeaderTimeout: endpoint.Timeout,
}