mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-12 13:48:01 +00:00
wgengine, net/packet, cmd/tailscale: add ICMP echo
Updates tailscale/corp#754 Signed-off-by: James Tucker <james@tailscale.com>
This commit is contained in:

committed by
James Tucker

parent
66f9292835
commit
ae483d3446
@@ -248,5 +248,5 @@ type Backend interface {
|
||||
// Ping attempts to start connecting to the given IP and sends a Notify
|
||||
// with its PingResult. If the host is down, there might never
|
||||
// be a PingResult sent. The cmd/tailscale CLI client adds a timeout.
|
||||
Ping(ip string, useTSMP bool)
|
||||
Ping(ip string, pingType tailcfg.PingType)
|
||||
}
|
||||
|
@@ -100,7 +100,7 @@ func (b *FakeBackend) RequestEngineStatus() {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *FakeBackend) Ping(ip string, useTSMP bool) {
|
||||
func (b *FakeBackend) Ping(ip string, pingType tailcfg.PingType) {
|
||||
if b.notify != nil {
|
||||
b.notify(Notify{PingResult: &ipnstate.PingResult{}})
|
||||
}
|
||||
|
@@ -1699,13 +1699,13 @@ func (b *LocalBackend) StartLoginInteractive() {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *LocalBackend) Ping(ipStr string, useTSMP bool) {
|
||||
func (b *LocalBackend) Ping(ipStr string, pingType tailcfg.PingType) {
|
||||
ip, err := netaddr.ParseIP(ipStr)
|
||||
if err != nil {
|
||||
b.logf("ignoring Ping request to invalid IP %q", ipStr)
|
||||
return
|
||||
}
|
||||
b.e.Ping(ip, useTSMP, func(pr *ipnstate.PingResult) {
|
||||
b.e.Ping(ip, pingType, func(pr *ipnstate.PingResult) {
|
||||
b.send(ipn.Notify{PingResult: pr})
|
||||
})
|
||||
}
|
||||
|
@@ -515,7 +515,7 @@ type PingResult struct {
|
||||
// TODO(bradfitz): details like whether port mapping was used on either side? (Once supported)
|
||||
}
|
||||
|
||||
func (pr *PingResult) ToPingResponse(pingType string) *tailcfg.PingResponse {
|
||||
func (pr *PingResult) ToPingResponse(pingType tailcfg.PingType) *tailcfg.PingResponse {
|
||||
return &tailcfg.PingResponse{
|
||||
Type: pingType,
|
||||
IP: pr.IP,
|
||||
|
@@ -52,8 +52,8 @@ type SetPrefsArgs struct {
|
||||
}
|
||||
|
||||
type PingArgs struct {
|
||||
IP string
|
||||
UseTSMP bool
|
||||
IP string
|
||||
Type tailcfg.PingType
|
||||
}
|
||||
|
||||
// Command is a command message that is JSON encoded and sent by a
|
||||
@@ -171,7 +171,7 @@ func (bs *BackendServer) GotCommand(ctx context.Context, cmd *Command) error {
|
||||
bs.b.RequestEngineStatus()
|
||||
return nil
|
||||
} else if c := cmd.Ping; c != nil {
|
||||
bs.b.Ping(c.IP, c.UseTSMP)
|
||||
bs.b.Ping(c.IP, tailcfg.PingType(c.Type))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -311,10 +311,10 @@ func (bc *BackendClient) RequestStatus() {
|
||||
bc.send(Command{AllowVersionSkew: true, RequestStatus: &NoArgs{}})
|
||||
}
|
||||
|
||||
func (bc *BackendClient) Ping(ip string, useTSMP bool) {
|
||||
func (bc *BackendClient) Ping(ip string, pingType tailcfg.PingType) {
|
||||
bc.send(Command{Ping: &PingArgs{
|
||||
IP: ip,
|
||||
UseTSMP: useTSMP,
|
||||
IP: ip,
|
||||
Type: pingType,
|
||||
}})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user