control/controlclient: use wgcfg.PrivateKey.IsZero

Generated by eg using template:

---

package p

import "github.com/tailscale/wireguard-go/wgcfg"

func before(k wgcfg.PrivateKey) bool { return k == wgcfg.PrivateKey{} }
func after(k wgcfg.PrivateKey) bool  { return k.IsZero() }


Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
pull/797/head
Josh Bleecher Snyder 4 years ago
parent 2b8d2babfa
commit 1fecf87363

@ -289,7 +289,7 @@ func (c *Direct) doLogin(ctx context.Context, t *oauth2.Token, flags LoginFlags,
expired := c.expiry != nil && !c.expiry.IsZero() && c.expiry.Before(c.timeNow()) expired := c.expiry != nil && !c.expiry.IsZero() && c.expiry.Before(c.timeNow())
c.mu.Unlock() c.mu.Unlock()
if persist.PrivateMachineKey == (wgcfg.PrivateKey{}) { if persist.PrivateMachineKey.IsZero() {
c.logf("Generating a new machinekey.") c.logf("Generating a new machinekey.")
mkey, err := wgcfg.NewPrivateKey() mkey, err := wgcfg.NewPrivateKey()
if err != nil { if err != nil {
@ -322,7 +322,7 @@ func (c *Direct) doLogin(ctx context.Context, t *oauth2.Token, flags LoginFlags,
var oldNodeKey wgcfg.Key var oldNodeKey wgcfg.Key
if url != "" { if url != "" {
} else if regen || persist.PrivateNodeKey == (wgcfg.PrivateKey{}) { } else if regen || persist.PrivateNodeKey.IsZero() {
c.logf("Generating a new nodekey.") c.logf("Generating a new nodekey.")
persist.OldPrivateNodeKey = persist.PrivateNodeKey persist.OldPrivateNodeKey = persist.PrivateNodeKey
key, err := wgcfg.NewPrivateKey() key, err := wgcfg.NewPrivateKey()
@ -339,7 +339,7 @@ func (c *Direct) doLogin(ctx context.Context, t *oauth2.Token, flags LoginFlags,
oldNodeKey = persist.OldPrivateNodeKey.Public() oldNodeKey = persist.OldPrivateNodeKey.Public()
} }
if tryingNewKey == (wgcfg.PrivateKey{}) { if tryingNewKey.IsZero() {
log.Fatalf("tryingNewKey is empty, give up") log.Fatalf("tryingNewKey is empty, give up")
} }
if backendLogID == "" { if backendLogID == "" {

Loading…
Cancel
Save