Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistently connect to Unix sockets #2922

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/networks/usernet/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ func NewClient(endpointSock string, subnet net.IP) *Client {
func create(sock string, subnet net.IP, base string) *Client {
client := &http.Client{
Transport: &http.Transport{
DialContext: func(context.Context, string, string) (net.Conn, error) {
return net.Dial("unix", sock)
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {
var d net.Dialer
return d.DialContext(ctx, "unix", sock)
},
},
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/qemu/qemu_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ func (a *qArgTemplateApplier) applyTemplate(qArg string) (string, error) {
if !ok {
return "", fmt.Errorf("non-string argument %+v", v)
}
addr := &net.UnixAddr{
Net: "unix",
Name: s,
addr, err := net.ResolveUnixAddr("unix", s)
if err != nil {
return "", err
}
conn, err := net.DialUnix("unix", nil, addr)
if err != nil {
Expand Down
8 changes: 6 additions & 2 deletions pkg/vz/network_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import (
)

func PassFDToUnix(unixSock string) (*os.File, error) {
unixConn, err := net.Dial("unix", unixSock)
unixAddr, err := net.ResolveUnixAddr("unix", unixSock)
if err != nil {
return nil, err
}
unixConn, err := net.DialUnix("unix", nil, unixAddr)
if err != nil {
return nil, err
}
Expand All @@ -27,7 +31,7 @@ func PassFDToUnix(unixSock string) (*os.File, error) {
if err != nil {
return nil, err
}
err = fd.Put(unixConn.(*net.UnixConn), server)
tamird marked this conversation as resolved.
Show resolved Hide resolved
err = fd.Put(unixConn, server)
tamird marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return nil, err
}
Expand Down
Loading