support unix sockets (#26)

This commit is contained in:
Joshua Humphries
2018-03-27 11:24:35 -04:00
committed by GitHub
parent 09a863d763
commit ca5693f42c
6 changed files with 70 additions and 16 deletions

View File

@@ -878,7 +878,7 @@ func ServerTransportCredentials(cacertFile, serverCertFile, serverKeyFile string
// BlockingDial is a helper method to dial the given address, using optional TLS credentials,
// and blocking until the returned connection is ready. If the given credentials are nil, the
// connection will be insecure (plain-text).
func BlockingDial(ctx context.Context, address string, creds credentials.TransportCredentials, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
func BlockingDial(ctx context.Context, network, address string, creds credentials.TransportCredentials, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
// grpc.Dial doesn't provide any information on permanent connection errors (like
// TLS handshake failures). So in order to provide good error messages, we need a
// custom dialer that can provide that info. That means we manage the TLS handshake.
@@ -895,7 +895,8 @@ func BlockingDial(ctx context.Context, address string, creds credentials.Transpo
dialer := func(address string, timeout time.Duration) (net.Conn, error) {
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
conn, err := (&net.Dialer{Cancel: ctx.Done()}).Dial("tcp", address)
conn, err := (&net.Dialer{Cancel: ctx.Done()}).Dial(network, address)
if err != nil {
writeResult(err)
return nil, err