Skip to content

Commit

Permalink
Allow "tcp", "tcp4", "tcp6"
Browse files Browse the repository at this point in the history
  • Loading branch information
Dexus authored Aug 8, 2017
1 parent 20fe3f1 commit cbd0479
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tcplisten.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (cfg *Config) fdSetup(fd int, sa syscall.Sockaddr, addr string) error {
}

func getSockaddr(network, addr string) (sa syscall.Sockaddr, soType int, err error) {
if network != "tcp4" && network != "tcp6" {
if network != "tcp" && network != "tcp4" && network != "tcp6" {
return nil, -1, errors.New("only tcp4 and tcp6 network is supported")
}

Expand All @@ -139,7 +139,7 @@ func getSockaddr(network, addr string) (sa syscall.Sockaddr, soType int, err err
}

switch network {
case "tcp4":
case "tcp", "tcp4":
var sa4 syscall.SockaddrInet4
sa4.Port = tcpAddr.Port
copy(sa4.Addr[:], tcpAddr.IP.To4())
Expand Down

0 comments on commit cbd0479

Please sign in to comment.