|
|
@ -69,6 +69,7 @@ type Direct struct {
|
|
|
|
keepSharerAndUserSplit bool
|
|
|
|
keepSharerAndUserSplit bool
|
|
|
|
skipIPForwardingCheck bool
|
|
|
|
skipIPForwardingCheck bool
|
|
|
|
pinger Pinger
|
|
|
|
pinger Pinger
|
|
|
|
|
|
|
|
popBrowser func(url string) // or nil
|
|
|
|
|
|
|
|
|
|
|
|
mu sync.Mutex // mutex guards the following fields
|
|
|
|
mu sync.Mutex // mutex guards the following fields
|
|
|
|
serverKey key.MachinePublic // original ("legacy") nacl crypto_box-based public key
|
|
|
|
serverKey key.MachinePublic // original ("legacy") nacl crypto_box-based public key
|
|
|
@ -100,9 +101,10 @@ type Options struct {
|
|
|
|
NewDecompressor func() (Decompressor, error)
|
|
|
|
NewDecompressor func() (Decompressor, error)
|
|
|
|
KeepAlive bool
|
|
|
|
KeepAlive bool
|
|
|
|
Logf logger.Logf
|
|
|
|
Logf logger.Logf
|
|
|
|
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
|
|
|
|
|
|
|
|
PopBrowserURL func(url string) // optional func to open browser
|
|
|
|
|
|
|
|
|
|
|
|
// 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.
|
|
|
@ -198,6 +200,7 @@ func NewDirect(opts Options) (*Direct, error) {
|
|
|
|
linkMon: opts.LinkMonitor,
|
|
|
|
linkMon: opts.LinkMonitor,
|
|
|
|
skipIPForwardingCheck: opts.SkipIPForwardingCheck,
|
|
|
|
skipIPForwardingCheck: opts.SkipIPForwardingCheck,
|
|
|
|
pinger: opts.Pinger,
|
|
|
|
pinger: opts.Pinger,
|
|
|
|
|
|
|
|
popBrowser: opts.PopBrowserURL,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if opts.Hostinfo == nil {
|
|
|
|
if opts.Hostinfo == nil {
|
|
|
|
c.SetHostinfo(hostinfo.New())
|
|
|
|
c.SetHostinfo(hostinfo.New())
|
|
|
@ -849,7 +852,15 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netm
|
|
|
|
metricMapResponsePings.Add(1)
|
|
|
|
metricMapResponsePings.Add(1)
|
|
|
|
go answerPing(c.logf, c.httpc, pr)
|
|
|
|
go answerPing(c.logf, c.httpc, pr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if u := resp.PopBrowserURL; u != "" && u != sess.lastPopBrowserURL {
|
|
|
|
|
|
|
|
sess.lastPopBrowserURL = u
|
|
|
|
|
|
|
|
if c.popBrowser != nil {
|
|
|
|
|
|
|
|
c.logf("netmap: control says to open URL %v; opening...", u)
|
|
|
|
|
|
|
|
c.popBrowser(u)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
c.logf("netmap: control says to open URL %v; no popBrowser func", u)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if resp.ControlTime != nil && !resp.ControlTime.IsZero() {
|
|
|
|
if resp.ControlTime != nil && !resp.ControlTime.IsZero() {
|
|
|
|
c.logf.JSON(1, "controltime", resp.ControlTime.UTC())
|
|
|
|
c.logf.JSON(1, "controltime", resp.ControlTime.UTC())
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -858,6 +869,7 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netm
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
vlogf("netmap: got new map")
|
|
|
|
vlogf("netmap: got new map")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
select {
|
|
|
|
select {
|
|
|
|
case timeoutReset <- struct{}{}:
|
|
|
|
case timeoutReset <- struct{}{}:
|
|
|
|
vlogf("netmap: sent timer reset")
|
|
|
|
vlogf("netmap: sent timer reset")
|
|
|
|