Skip to content

Commit

Permalink
Merge pull request containerd#9412 from profnandaa/fix/dialer_functio…
Browse files Browse the repository at this point in the history
…n_windows

pkg/dialer: minor fix on dialer function for windows
  • Loading branch information
samuelkarp authored Nov 23, 2023
2 parents 6ed8f01 + 8e91edb commit 787943d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/dialer/dialer_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
package dialer

import (
"fmt"
"net"
"os"
"path/filepath"
"strings"
"time"

winio "github.com/Microsoft/go-winio"
Expand All @@ -29,10 +32,16 @@ func isNoent(err error) bool {
}

func dialer(address string, timeout time.Duration) (net.Conn, error) {
address = strings.TrimPrefix(filepath.ToSlash(address), "npipe://")
return winio.DialPipe(address, &timeout)
}

// DialAddress returns the dial address
// DialAddress returns the dial address with npipe:// prepended to the
// provided address
func DialAddress(address string) string {
address = filepath.ToSlash(address)
if !strings.HasPrefix(address, "npipe://") {
address = fmt.Sprintf("npipe://%s", address)
}
return address
}

0 comments on commit 787943d

Please sign in to comment.