mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-18 02:48:40 +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
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"tailscale.com/ipn/ipnstate"
|
||||
@ -122,9 +121,6 @@ type Options struct {
|
||||
// TODO(danderson): remove some time after the transition to
|
||||
// tailscaled is done.
|
||||
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
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@ -91,6 +92,7 @@ type LocalBackend struct {
|
||||
|
||||
// The mutex protects the following elements.
|
||||
mu sync.Mutex
|
||||
httpTestClient *http.Client // for controlclient. nil by default, used by tests.
|
||||
notify func(ipn.Notify)
|
||||
c *controlclient.Client
|
||||
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
|
||||
}
|
||||
|
||||
// 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
|
||||
// state machine.
|
||||
//
|
||||
@ -575,6 +586,7 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
|
||||
// complicated.
|
||||
b.c.Shutdown()
|
||||
}
|
||||
httpTestClient := b.httpTestClient
|
||||
|
||||
if b.hostinfo != nil {
|
||||
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,
|
||||
KeepAlive: true,
|
||||
NewDecompressor: b.newDecompressor,
|
||||
HTTPTestClient: opts.HTTPTestClient,
|
||||
HTTPTestClient: httpTestClient,
|
||||
DiscoPublicKey: discoPublic,
|
||||
DebugFlags: controlDebugFlags,
|
||||
LinkMonitor: b.e.GetLinkMonitor(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user