cmd/tailscaled, wgengine, ipn: add /debug/ipn handler with world state

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2020-03-25 22:57:46 -07:00
committed by Brad Fitzpatrick
parent dbca186a64
commit 322499473e
9 changed files with 415 additions and 4 deletions

View File

@@ -5,7 +5,11 @@
// Package key defines some types related to curve25519 keys.
package key
import "golang.org/x/crypto/curve25519"
import (
"encoding/base64"
"golang.org/x/crypto/curve25519"
)
// Private represents a curve25519 private key.
type Private [32]byte
@@ -24,6 +28,13 @@ type Public [32]byte
// Public reports whether p is the zero value.
func (p Public) IsZero() bool { return p == Public{} }
// ShortString returns the Tailscale conventional debug representation
// of a public key: the first five base64 digits of the key, in square
// brackets.
func (p Public) ShortString() string {
return "[" + base64.StdEncoding.EncodeToString(p[:])[:5] + "]"
}
// B32 returns k as the *[32]byte type that's used by the
// golang.org/x/crypto packages. This allocates; it might
// not be appropriate for performance-sensitive paths.