Skip to content

Commit

Permalink
don't try to SplitHostPort when the target garden is on a unix socket
Browse files Browse the repository at this point in the history
  • Loading branch information
rosenhouse committed Aug 7, 2016
1 parent f58744f commit 828e1b7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions commands/net_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package commands
import (
"fmt"
"net"
"os"
)

type NetIn struct {
Expand All @@ -16,8 +17,13 @@ func (command *NetIn) Execute(maybeHandle []string) error {
hostPort, _, err := container.NetIn(0, uint32(command.Port))
failIf(err)

host, _, err := net.SplitHostPort(Globals.Target.Address)
failIf(err)
host := Globals.Target.Address
if _, err := os.Stat(host); err == nil {
host = "127.0.0.1"
} else {
host, _, err = net.SplitHostPort(host)
failIf(err)
}

fmt.Println(net.JoinHostPort(host, fmt.Sprintf("%d", hostPort)))

Expand Down

0 comments on commit 828e1b7

Please sign in to comment.