Skip to content

Commit

Permalink
fix: Use 4 digits for hex port
Browse files Browse the repository at this point in the history
As described in https://www.kernel.org/doc/Documentation/networking/proc_net_tcp.txt
the format of /proc/net/tcp is using 4 digits for the hex port:

46: 010310AC:9C4C 030310AC:1770 01
|      |      |      |      |   |--> connection state
|      |      |      |      |------> remote TCP port number
|      |      |      |-------------> remote IPv4 address
|      |      |--------------------> local TCP port number
|      |---------------------------> local IPv4 address
|----------------------------------> number of entry

So this string pattern is more accurate
  • Loading branch information
mdelapenya committed Feb 6, 2020
1 parent e7cea2d commit 5ce826e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion wait/host_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (hp *HostPortStrategy) WaitUntilReady(ctx context.Context, target StrategyT

func buildInternalCheckCommand(internalPort int) string {
command := `(
cat /proc/net/tcp{,6} | awk '{print $2}' | grep -i :%x ||
cat /proc/net/tcp{,6} | awk "\"{print $2}"\" | grep -i :%04x ||
nc -vz -w 1 localhost %d ||
/bin/sh -c '</dev/tcp/localhost/%d'
)
Expand Down

0 comments on commit 5ce826e

Please sign in to comment.