Unmarshal keys in the non-deprecated way

This commit is contained in:
Kristoffer Dalby
2021-11-26 23:50:42 +00:00
parent 0012c76170
commit c38f00fab8
7 changed files with 27 additions and 40 deletions

5
api.go
View File

@@ -13,7 +13,6 @@ import (
"github.com/gin-gonic/gin"
"github.com/klauspost/compress/zstd"
"github.com/rs/zerolog/log"
"go4.org/mem"
"gorm.io/gorm"
"tailscale.com/tailcfg"
"tailscale.com/types/key"
@@ -74,7 +73,9 @@ func (h *Headscale) RegisterWebAPI(ctx *gin.Context) {
func (h *Headscale) RegistrationHandler(ctx *gin.Context) {
body, _ := io.ReadAll(ctx.Request.Body)
machineKeyStr := ctx.Param("id")
machineKey, err := key.ParseMachinePublicUntyped(mem.S(machineKeyStr))
var machineKey key.MachinePublic
err := machineKey.UnmarshalText([]byte(machineKeyStr))
if err != nil {
log.Error().
Caller().