mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-22 07:57:34 +00:00
Make hostname dns safe, allow string in ping command
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
ecce82d44a
commit
d242ceac46
@ -58,7 +58,7 @@ func TestPingAll(t *testing.T) {
|
|||||||
|
|
||||||
for _, client := range allClients {
|
for _, client := range allClients {
|
||||||
for _, ip := range allIps {
|
for _, ip := range allIps {
|
||||||
err := client.Ping(ip)
|
err := client.Ping(ip.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to ping %s from %s: %s", ip, client.Hostname(), err)
|
t.Errorf("failed to ping %s from %s: %s", ip, client.Hostname(), err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -14,5 +14,5 @@ type TailscaleClient interface {
|
|||||||
IPs() ([]netip.Addr, error)
|
IPs() ([]netip.Addr, error)
|
||||||
Status() (*ipnstate.Status, error)
|
Status() (*ipnstate.Status, error)
|
||||||
WaitForPeers(expected int) error
|
WaitForPeers(expected int) error
|
||||||
Ping(ip netip.Addr) error
|
Ping(hostnameOrIP string) error
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ func New(
|
|||||||
return nil, err
|
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.
|
// TODO(kradalby): figure out why we need to "refresh" the network here.
|
||||||
// network, err = dockertestutil.GetFirstOrCreateNetwork(pool, network.Network.Name)
|
// network, err = dockertestutil.GetFirstOrCreateNetwork(pool, network.Network.Name)
|
||||||
@ -220,14 +220,14 @@ func (t *TailscaleInContainer) WaitForPeers(expected int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO(kradalby): Make multiping, go routine magic.
|
// 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 {
|
return t.pool.Retry(func() error {
|
||||||
command := []string{
|
command := []string{
|
||||||
"tailscale", "ping",
|
"tailscale", "ping",
|
||||||
"--timeout=1s",
|
"--timeout=1s",
|
||||||
"--c=10",
|
"--c=10",
|
||||||
"--until-direct=true",
|
"--until-direct=true",
|
||||||
ip.String(),
|
hostnameOrIP,
|
||||||
}
|
}
|
||||||
|
|
||||||
result, _, err := dockertestutil.ExecuteCommand(
|
result, _, err := dockertestutil.ExecuteCommand(
|
||||||
@ -238,8 +238,8 @@ func (t *TailscaleInContainer) Ping(ip netip.Addr) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf(
|
log.Printf(
|
||||||
"failed to run ping command from %s to %s, err: %s",
|
"failed to run ping command from %s to %s, err: %s",
|
||||||
t.hostname,
|
t.Hostname(),
|
||||||
ip.String(),
|
hostnameOrIP,
|
||||||
err,
|
err,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user