2018-04-19 13:07:27 -04:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
2020-04-16 11:06:33 -04:00
|
|
|
winio "github.com/Microsoft/go-winio"
|
2018-04-19 13:07:27 -04:00
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
func dialer(address string, timeout time.Duration) (net.Conn, error) {
|
|
|
|
addrParts := strings.SplitN(address, "://", 2)
|
|
|
|
if len(addrParts) != 2 {
|
|
|
|
return nil, errors.Errorf("invalid address %s", address)
|
|
|
|
}
|
|
|
|
switch addrParts[0] {
|
|
|
|
case "npipe":
|
2019-04-03 02:23:23 -04:00
|
|
|
address = strings.Replace(addrParts[1], "/", "\\", -1)
|
2018-04-19 13:07:27 -04:00
|
|
|
return winio.DialPipe(address, &timeout)
|
|
|
|
default:
|
|
|
|
return net.DialTimeout(addrParts[0], addrParts[1], timeout)
|
|
|
|
}
|
|
|
|
}
|