Skip to content
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
8 changes: 4 additions & 4 deletions listener/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (l UnixListener) Listen() (net.Listener, error) {
}

// Being lazy here...
var reLooksLikeHostPort = regexp.MustCompile(`^(\d+):(\d+)$`)
var reLooksLikeHostPort = regexp.MustCompile(`^(.+?):(\d+)$`)
var reLooksLikePort = regexp.MustCompile(`^\d+$`)

func parseListenTargets(str string) ([]Listener, error) {
Expand All @@ -103,14 +103,14 @@ func parseListenTargets(str string) ([]Listener, error) {
return nil, fmt.Errorf("failed to parse '%s' as listen target: %s", pairString, err)
}

if matches := reLooksLikeHostPort.FindAllString(hostPort, -1); matches != nil {
port, err := strconv.ParseInt(matches[1], 10, 0)
if matches := reLooksLikeHostPort.FindStringSubmatch(hostPort); matches != nil {
port, err := strconv.ParseInt(matches[2], 10, 0)
if err != nil {
return nil, err
}

ret[i] = TCPListener{
Addr: matches[0],
Addr: matches[1],
Port: int(port),
fd: uintptr(fd),
}
Expand Down
5 changes: 5 additions & 0 deletions listener/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ func TestPort(t *testing.T) {
if port.Fd() != expect[i].Fd() {
t.Errorf("parsed fd is not what we expected (expected %d, got %d)", expect[i].Fd(), port.Fd())
}
_, gotTcp := port.(TCPListener)
_, expectTcp := expect[i].(TCPListener)
if gotTcp != expectTcp {
t.Errorf("parsed listener is the wrong type")
}
}
}

Expand Down