This commit is contained in:
LiuHanCheng 2022-11-05 16:07:22 +08:00 committed by GitHub
parent bf87b33292
commit 07f92e647c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 47 additions and 35 deletions

View file

@ -1,4 +1,4 @@
//nolint
// nolint
package headscale
import (
@ -12,6 +12,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"tailscale.com/tailcfg"
"tailscale.com/types/key"
)
type headscaleV1APIServer struct { // v1.HeadscaleServiceServer
@ -496,9 +497,14 @@ func (api headscaleV1APIServer) DebugCreateMachine(
HostInfo: HostInfo(hostinfo),
}
nodeKey := key.NodePublic{}
err = nodeKey.UnmarshalText([]byte(request.GetKey()))
if err != nil {
log.Panic().Msg("can not add machine for debug. invalid node key")
}
api.h.registrationCache.Set(
request.GetKey(),
NodePublicKeyStripPrefix(nodeKey),
newMachine,
registerCacheExpiration,
)