|
|
@ -83,6 +83,7 @@ type Direct struct {
|
|
|
|
mu sync.Mutex // mutex guards the following fields
|
|
|
|
mu sync.Mutex // mutex guards the following fields
|
|
|
|
serverKey wgcfg.Key
|
|
|
|
serverKey wgcfg.Key
|
|
|
|
persist Persist
|
|
|
|
persist Persist
|
|
|
|
|
|
|
|
authKey string
|
|
|
|
tryingNewKey wgcfg.PrivateKey
|
|
|
|
tryingNewKey wgcfg.PrivateKey
|
|
|
|
expiry *time.Time
|
|
|
|
expiry *time.Time
|
|
|
|
hostinfo *tailcfg.Hostinfo // always non-nil
|
|
|
|
hostinfo *tailcfg.Hostinfo // always non-nil
|
|
|
@ -94,6 +95,7 @@ type Options struct {
|
|
|
|
Persist Persist // initial persistent data
|
|
|
|
Persist Persist // initial persistent data
|
|
|
|
HTTPC *http.Client // HTTP client used to talk to tailcontrol
|
|
|
|
HTTPC *http.Client // HTTP client used to talk to tailcontrol
|
|
|
|
ServerURL string // URL of the tailcontrol server
|
|
|
|
ServerURL string // URL of the tailcontrol server
|
|
|
|
|
|
|
|
AuthKey string // optional node auth key for auto registration
|
|
|
|
TimeNow func() time.Time // time.Now implementation used by Client
|
|
|
|
TimeNow func() time.Time // time.Now implementation used by Client
|
|
|
|
Hostinfo *tailcfg.Hostinfo // non-nil passes ownership, nil means to use default using os.Hostname, etc
|
|
|
|
Hostinfo *tailcfg.Hostinfo // non-nil passes ownership, nil means to use default using os.Hostname, etc
|
|
|
|
NewDecompressor func() (Decompressor, error)
|
|
|
|
NewDecompressor func() (Decompressor, error)
|
|
|
@ -131,6 +133,7 @@ func NewDirect(opts Options) (*Direct, error) {
|
|
|
|
newDecompressor: opts.NewDecompressor,
|
|
|
|
newDecompressor: opts.NewDecompressor,
|
|
|
|
keepAlive: opts.KeepAlive,
|
|
|
|
keepAlive: opts.KeepAlive,
|
|
|
|
persist: opts.Persist,
|
|
|
|
persist: opts.Persist,
|
|
|
|
|
|
|
|
authKey: opts.AuthKey,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if opts.Hostinfo == nil {
|
|
|
|
if opts.Hostinfo == nil {
|
|
|
|
c.SetHostinfo(NewHostinfo())
|
|
|
|
c.SetHostinfo(NewHostinfo())
|
|
|
@ -313,6 +316,7 @@ func (c *Direct) doLogin(ctx context.Context, t *oauth2.Token, flags LoginFlags,
|
|
|
|
request.Auth.Oauth2Token = t
|
|
|
|
request.Auth.Oauth2Token = t
|
|
|
|
request.Auth.Provider = persist.Provider
|
|
|
|
request.Auth.Provider = persist.Provider
|
|
|
|
request.Auth.LoginName = persist.LoginName
|
|
|
|
request.Auth.LoginName = persist.LoginName
|
|
|
|
|
|
|
|
request.Auth.AuthKey = c.authKey
|
|
|
|
bodyData, err := encode(request, &serverKey, &persist.PrivateMachineKey)
|
|
|
|
bodyData, err := encode(request, &serverKey, &persist.PrivateMachineKey)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return regen, url, err
|
|
|
|
return regen, url, err
|
|
|
|