|
|
@ -330,7 +330,7 @@ func (c *Direct) doLogin(ctx context.Context, opt loginOpt) (mustRegen bool, new
|
|
|
|
var oldNodeKey wgkey.Key
|
|
|
|
var oldNodeKey wgkey.Key
|
|
|
|
switch {
|
|
|
|
switch {
|
|
|
|
case opt.Logout:
|
|
|
|
case opt.Logout:
|
|
|
|
tryingNewKey = persist.PrivateNodeKey
|
|
|
|
tryingNewKey = persist.PrivateNodeKey.AsWGPrivate()
|
|
|
|
case opt.URL != "":
|
|
|
|
case opt.URL != "":
|
|
|
|
// Nothing.
|
|
|
|
// Nothing.
|
|
|
|
case regen || persist.PrivateNodeKey.IsZero():
|
|
|
|
case regen || persist.PrivateNodeKey.IsZero():
|
|
|
@ -344,10 +344,10 @@ func (c *Direct) doLogin(ctx context.Context, opt loginOpt) (mustRegen bool, new
|
|
|
|
tryingNewKey = key
|
|
|
|
tryingNewKey = key
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
// Try refreshing the current key first
|
|
|
|
// Try refreshing the current key first
|
|
|
|
tryingNewKey = persist.PrivateNodeKey
|
|
|
|
tryingNewKey = persist.PrivateNodeKey.AsWGPrivate()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !persist.OldPrivateNodeKey.IsZero() {
|
|
|
|
if !persist.OldPrivateNodeKey.IsZero() {
|
|
|
|
oldNodeKey = persist.OldPrivateNodeKey.Public()
|
|
|
|
oldNodeKey = persist.OldPrivateNodeKey.Public().AsWGKey()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if tryingNewKey.IsZero() {
|
|
|
|
if tryingNewKey.IsZero() {
|
|
|
@ -468,7 +468,7 @@ func (c *Direct) doLogin(ctx context.Context, opt loginOpt) (mustRegen bool, new
|
|
|
|
c.mu.Lock()
|
|
|
|
c.mu.Lock()
|
|
|
|
if resp.AuthURL == "" {
|
|
|
|
if resp.AuthURL == "" {
|
|
|
|
// key rotation is complete
|
|
|
|
// key rotation is complete
|
|
|
|
persist.PrivateNodeKey = tryingNewKey
|
|
|
|
persist.PrivateNodeKey = key.NodePrivateFromRaw32(mem.B(tryingNewKey[:]))
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// save it for the retry-with-URL
|
|
|
|
// save it for the retry-with-URL
|
|
|
|
c.tryingNewKey = tryingNewKey
|
|
|
|
c.tryingNewKey = tryingNewKey
|
|
|
@ -600,7 +600,7 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netm
|
|
|
|
request := &tailcfg.MapRequest{
|
|
|
|
request := &tailcfg.MapRequest{
|
|
|
|
Version: tailcfg.CurrentMapRequestVersion,
|
|
|
|
Version: tailcfg.CurrentMapRequestVersion,
|
|
|
|
KeepAlive: c.keepAlive,
|
|
|
|
KeepAlive: c.keepAlive,
|
|
|
|
NodeKey: tailcfg.NodeKey(persist.PrivateNodeKey.Public()),
|
|
|
|
NodeKey: tailcfg.NodeKeyFromNodePublic(persist.PrivateNodeKey.Public()),
|
|
|
|
DiscoKey: c.discoPubKey,
|
|
|
|
DiscoKey: c.discoPubKey,
|
|
|
|
Endpoints: epStrs,
|
|
|
|
Endpoints: epStrs,
|
|
|
|
EndpointTypes: epTypes,
|
|
|
|
EndpointTypes: epTypes,
|
|
|
@ -707,7 +707,7 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netm
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
sess := newMapSession(persist.PrivateNodeKey)
|
|
|
|
sess := newMapSession(persist.PrivateNodeKey.AsWGPrivate())
|
|
|
|
sess.logf = c.logf
|
|
|
|
sess.logf = c.logf
|
|
|
|
sess.vlogf = vlogf
|
|
|
|
sess.vlogf = vlogf
|
|
|
|
sess.machinePubKey = machinePubKey
|
|
|
|
sess.machinePubKey = machinePubKey
|
|
|
|