Skip to content

Commit

Permalink
Make hostname dns safe, allow string in ping command
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
  • Loading branch information
kradalby committed Oct 23, 2022
1 parent ecce82d commit d242cea
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion integration/general_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestPingAll(t *testing.T) {

for _, client := range allClients {
for _, ip := range allIps {
err := client.Ping(ip)
err := client.Ping(ip.String())
if err != nil {
t.Errorf("failed to ping %s from %s: %s", ip, client.Hostname(), err)
} else {
Expand Down
2 changes: 1 addition & 1 deletion integration/tailscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ type TailscaleClient interface {
IPs() ([]netip.Addr, error)
Status() (*ipnstate.Status, error)
WaitForPeers(expected int) error
Ping(ip netip.Addr) error
Ping(hostnameOrIP string) error
}
10 changes: 5 additions & 5 deletions integration/tsic/tsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func New(
return nil, err
}

hostname := fmt.Sprintf("ts-%s-%s", version, hash)
hostname := fmt.Sprintf("ts-%s-%s", strings.ReplaceAll(version, ".", "-"), hash)

// TODO(kradalby): figure out why we need to "refresh" the network here.
// network, err = dockertestutil.GetFirstOrCreateNetwork(pool, network.Network.Name)
Expand Down Expand Up @@ -220,14 +220,14 @@ func (t *TailscaleInContainer) WaitForPeers(expected int) error {
}

// TODO(kradalby): Make multiping, go routine magic.
func (t *TailscaleInContainer) Ping(ip netip.Addr) error {
func (t *TailscaleInContainer) Ping(hostnameOrIP string) error {
return t.pool.Retry(func() error {
command := []string{
"tailscale", "ping",
"--timeout=1s",
"--c=10",
"--until-direct=true",
ip.String(),
hostnameOrIP,
}

result, _, err := dockertestutil.ExecuteCommand(
Expand All @@ -238,8 +238,8 @@ func (t *TailscaleInContainer) Ping(ip netip.Addr) error {
if err != nil {
log.Printf(
"failed to run ping command from %s to %s, err: %s",
t.hostname,
ip.String(),
t.Hostname(),
hostnameOrIP,
err,
)

Expand Down

0 comments on commit d242cea

Please sign in to comment.