tailcfg, control/controlclient: add PingRequest.URLIsNoise [capver 38]
Change-Id: I19bb63b6d99e96b2f9fd2c440afcc31d38137ded Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>pull/5352/head
parent
b33c337baa
commit
90555c5cb2
|
@ -885,7 +885,7 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, readOnly bool
|
||||||
|
|
||||||
if pr := resp.PingRequest; pr != nil && c.isUniquePingRequest(pr) {
|
if pr := resp.PingRequest; pr != nil && c.isUniquePingRequest(pr) {
|
||||||
metricMapResponsePings.Add(1)
|
metricMapResponsePings.Add(1)
|
||||||
go answerPing(c.logf, c.httpc, pr, c.pinger)
|
go c.answerPing(pr)
|
||||||
}
|
}
|
||||||
if u := resp.PopBrowserURL; u != "" && u != sess.lastPopBrowserURL {
|
if u := resp.PopBrowserURL; u != "" && u != sess.lastPopBrowserURL {
|
||||||
sess.lastPopBrowserURL = u
|
sess.lastPopBrowserURL = u
|
||||||
|
@ -1203,21 +1203,30 @@ func (c *Direct) isUniquePingRequest(pr *tailcfg.PingRequest) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func answerPing(logf logger.Logf, c *http.Client, pr *tailcfg.PingRequest, pinger Pinger) {
|
func (c *Direct) answerPing(pr *tailcfg.PingRequest) {
|
||||||
|
httpc := c.httpc
|
||||||
|
if pr.URLIsNoise {
|
||||||
|
nc, err := c.getNoiseClient()
|
||||||
|
if err != nil {
|
||||||
|
c.logf("failed to get noise client for ping request: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
httpc = nc.Client
|
||||||
|
}
|
||||||
if pr.URL == "" {
|
if pr.URL == "" {
|
||||||
logf("invalid PingRequest with no URL")
|
c.logf("invalid PingRequest with no URL")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if pr.Types == "" {
|
if pr.Types == "" {
|
||||||
answerHeadPing(logf, c, pr)
|
answerHeadPing(c.logf, httpc, pr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, t := range strings.Split(pr.Types, ",") {
|
for _, t := range strings.Split(pr.Types, ",") {
|
||||||
switch pt := tailcfg.PingType(t); pt {
|
switch pt := tailcfg.PingType(t); pt {
|
||||||
case tailcfg.PingTSMP, tailcfg.PingDisco, tailcfg.PingICMP, tailcfg.PingPeerAPI:
|
case tailcfg.PingTSMP, tailcfg.PingDisco, tailcfg.PingICMP, tailcfg.PingPeerAPI:
|
||||||
go doPingerPing(logf, c, pr, pinger, pt)
|
go doPingerPing(c.logf, httpc, pr, c.pinger, pt)
|
||||||
default:
|
default:
|
||||||
logf("unsupported ping request type: %q", t)
|
c.logf("unsupported ping request type: %q", t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,8 @@ type CapabilityVersion int
|
||||||
// 34: 2022-08-02: client understands CapabilityFileSharingTarget
|
// 34: 2022-08-02: client understands CapabilityFileSharingTarget
|
||||||
// 36: 2022-08-02: added PeersChangedPatch.{Key,DiscoKey,Online,LastSeen,KeyExpiry,Capabilities}
|
// 36: 2022-08-02: added PeersChangedPatch.{Key,DiscoKey,Online,LastSeen,KeyExpiry,Capabilities}
|
||||||
// 37: 2022-08-09: added Debug.{SetForceBackgroundSTUN,SetRandomizeClientPort}; Debug are sticky
|
// 37: 2022-08-09: added Debug.{SetForceBackgroundSTUN,SetRandomizeClientPort}; Debug are sticky
|
||||||
const CurrentCapabilityVersion CapabilityVersion = 37
|
// 38: 2022-08-11: added PingRequest.URLIsNoise
|
||||||
|
const CurrentCapabilityVersion CapabilityVersion = 38
|
||||||
|
|
||||||
type StableID string
|
type StableID string
|
||||||
|
|
||||||
|
@ -1151,6 +1152,10 @@ type PingRequest struct {
|
||||||
// If Types and IP are defined, then URL is the URL to send a POST request to.
|
// If Types and IP are defined, then URL is the URL to send a POST request to.
|
||||||
URL string
|
URL string
|
||||||
|
|
||||||
|
// URLIsNoise, if true, means that the client should hit URL over the Noise
|
||||||
|
// transport instead of TLS.
|
||||||
|
URLIsNoise bool `json:",omitempty"`
|
||||||
|
|
||||||
// Log is whether to log about this ping in the success case.
|
// Log is whether to log about this ping in the success case.
|
||||||
// For failure cases, the client will log regardless.
|
// For failure cases, the client will log regardless.
|
||||||
Log bool `json:",omitempty"`
|
Log bool `json:",omitempty"`
|
||||||
|
|
Loading…
Reference in New Issue