mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-16 11:41:39 +00:00
ipn: remove Options.HTTPTestClient, move to LocalBackend
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
50b309c1eb
commit
d581ee2536
@ -5,7 +5,6 @@
|
|||||||
package ipn
|
package ipn
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"tailscale.com/ipn/ipnstate"
|
"tailscale.com/ipn/ipnstate"
|
||||||
@ -122,9 +121,6 @@ type Options struct {
|
|||||||
// TODO(danderson): remove some time after the transition to
|
// TODO(danderson): remove some time after the transition to
|
||||||
// tailscaled is done.
|
// tailscaled is done.
|
||||||
LegacyConfigPath string
|
LegacyConfigPath string
|
||||||
// HTTPTestClient is an optional HTTP client to pass to controlclient
|
|
||||||
// (for tests only).
|
|
||||||
HTTPTestClient *http.Client
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backend is the interface between Tailscale frontends
|
// Backend is the interface between Tailscale frontends
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -91,6 +92,7 @@ type LocalBackend struct {
|
|||||||
|
|
||||||
// The mutex protects the following elements.
|
// The mutex protects the following elements.
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
|
httpTestClient *http.Client // for controlclient. nil by default, used by tests.
|
||||||
notify func(ipn.Notify)
|
notify func(ipn.Notify)
|
||||||
c *controlclient.Client
|
c *controlclient.Client
|
||||||
stateKey ipn.StateKey // computed in part from user-provided value
|
stateKey ipn.StateKey // computed in part from user-provided value
|
||||||
@ -538,6 +540,15 @@ func (b *LocalBackend) SetNotifyCallback(notify func(ipn.Notify)) {
|
|||||||
b.notify = notify
|
b.notify = notify
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetHTTPTestClient sets an alternate HTTP client to use with
|
||||||
|
// connections to the coordination server. It exists for
|
||||||
|
// testing. Using nil means to use the default.
|
||||||
|
func (b *LocalBackend) SetHTTPTestClient(c *http.Client) {
|
||||||
|
b.mu.Lock()
|
||||||
|
defer b.mu.Unlock()
|
||||||
|
b.httpTestClient = c
|
||||||
|
}
|
||||||
|
|
||||||
// Start applies the configuration specified in opts, and starts the
|
// Start applies the configuration specified in opts, and starts the
|
||||||
// state machine.
|
// state machine.
|
||||||
//
|
//
|
||||||
@ -575,6 +586,7 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
|
|||||||
// complicated.
|
// complicated.
|
||||||
b.c.Shutdown()
|
b.c.Shutdown()
|
||||||
}
|
}
|
||||||
|
httpTestClient := b.httpTestClient
|
||||||
|
|
||||||
if b.hostinfo != nil {
|
if b.hostinfo != nil {
|
||||||
hostinfo.Services = b.hostinfo.Services // keep any previous session and netinfo
|
hostinfo.Services = b.hostinfo.Services // keep any previous session and netinfo
|
||||||
@ -650,7 +662,7 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
|
|||||||
Hostinfo: hostinfo,
|
Hostinfo: hostinfo,
|
||||||
KeepAlive: true,
|
KeepAlive: true,
|
||||||
NewDecompressor: b.newDecompressor,
|
NewDecompressor: b.newDecompressor,
|
||||||
HTTPTestClient: opts.HTTPTestClient,
|
HTTPTestClient: httpTestClient,
|
||||||
DiscoPublicKey: discoPublic,
|
DiscoPublicKey: discoPublic,
|
||||||
DebugFlags: controlDebugFlags,
|
DebugFlags: controlDebugFlags,
|
||||||
LinkMonitor: b.e.GetLinkMonitor(),
|
LinkMonitor: b.e.GetLinkMonitor(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user