mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-21 06:01:42 +00:00
XXX: plumb a Pinger down to controlclient
This commit is contained in:
parent
ebcd7ab890
commit
963d585156
@ -32,6 +32,7 @@ import (
|
|||||||
"golang.org/x/crypto/nacl/box"
|
"golang.org/x/crypto/nacl/box"
|
||||||
"inet.af/netaddr"
|
"inet.af/netaddr"
|
||||||
"tailscale.com/health"
|
"tailscale.com/health"
|
||||||
|
"tailscale.com/ipn/ipnstate"
|
||||||
"tailscale.com/log/logheap"
|
"tailscale.com/log/logheap"
|
||||||
"tailscale.com/net/dnscache"
|
"tailscale.com/net/dnscache"
|
||||||
"tailscale.com/net/dnsfallback"
|
"tailscale.com/net/dnsfallback"
|
||||||
@ -66,6 +67,7 @@ type Direct struct {
|
|||||||
debugFlags []string
|
debugFlags []string
|
||||||
keepSharerAndUserSplit bool
|
keepSharerAndUserSplit bool
|
||||||
skipIPForwardingCheck bool
|
skipIPForwardingCheck bool
|
||||||
|
pinger Pinger
|
||||||
|
|
||||||
mu sync.Mutex // mutex guards the following fields
|
mu sync.Mutex // mutex guards the following fields
|
||||||
serverKey wgkey.Key
|
serverKey wgkey.Key
|
||||||
@ -80,6 +82,12 @@ type Direct struct {
|
|||||||
localPort uint16 // or zero to mean auto
|
localPort uint16 // or zero to mean auto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Pinger interface {
|
||||||
|
// Ping is a request to start a discovery ping with the peer handling
|
||||||
|
// the given IP and then call cb with its ping latency & method.
|
||||||
|
Ping(ip netaddr.IP, useTSMP bool, cb func(*ipnstate.PingResult))
|
||||||
|
}
|
||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Persist persist.Persist // initial persistent data
|
Persist persist.Persist // initial persistent data
|
||||||
GetMachinePrivateKey func() (wgkey.Private, error) // returns the machine key to use
|
GetMachinePrivateKey func() (wgkey.Private, error) // returns the machine key to use
|
||||||
@ -94,6 +102,7 @@ type Options struct {
|
|||||||
HTTPTestClient *http.Client // optional HTTP client to use (for tests only)
|
HTTPTestClient *http.Client // optional HTTP client to use (for tests only)
|
||||||
DebugFlags []string // debug settings to send to control
|
DebugFlags []string // debug settings to send to control
|
||||||
LinkMonitor *monitor.Mon // optional link monitor
|
LinkMonitor *monitor.Mon // optional link monitor
|
||||||
|
Pinger Pinger
|
||||||
|
|
||||||
// KeepSharerAndUserSplit controls whether the client
|
// KeepSharerAndUserSplit controls whether the client
|
||||||
// understands Node.Sharer. If false, the Sharer is mapped to the User.
|
// understands Node.Sharer. If false, the Sharer is mapped to the User.
|
||||||
@ -165,6 +174,7 @@ func NewDirect(opts Options) (*Direct, error) {
|
|||||||
keepSharerAndUserSplit: opts.KeepSharerAndUserSplit,
|
keepSharerAndUserSplit: opts.KeepSharerAndUserSplit,
|
||||||
linkMon: opts.LinkMonitor,
|
linkMon: opts.LinkMonitor,
|
||||||
skipIPForwardingCheck: opts.SkipIPForwardingCheck,
|
skipIPForwardingCheck: opts.SkipIPForwardingCheck,
|
||||||
|
pinger: opts.Pinger,
|
||||||
}
|
}
|
||||||
if opts.Hostinfo == nil {
|
if opts.Hostinfo == nil {
|
||||||
c.SetHostinfo(NewHostinfo())
|
c.SetHostinfo(NewHostinfo())
|
||||||
|
@ -808,6 +808,7 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
|
|||||||
DiscoPublicKey: discoPublic,
|
DiscoPublicKey: discoPublic,
|
||||||
DebugFlags: debugFlags,
|
DebugFlags: debugFlags,
|
||||||
LinkMonitor: b.e.GetLinkMonitor(),
|
LinkMonitor: b.e.GetLinkMonitor(),
|
||||||
|
Pinger: b.e,
|
||||||
|
|
||||||
// Don't warn about broken Linux IP forwading when
|
// Don't warn about broken Linux IP forwading when
|
||||||
// netstack is being used.
|
// netstack is being used.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user