mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-26 17:03:06 +00:00
Implement new machine register parameter
This commit is contained in:
parent
402a76070f
commit
54cc3c067f
3 changed files with 18 additions and 14 deletions
21
api.go
21
api.go
|
@ -154,6 +154,7 @@ func (h *Headscale) RegistrationHandler(ctx *gin.Context) {
|
||||||
)
|
)
|
||||||
|
|
||||||
h.handleMachineRegistrationNew(ctx, machineKey, req)
|
h.handleMachineRegistrationNew(ctx, machineKey, req)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,15 +574,19 @@ func (h *Headscale) handleAuthKey(
|
||||||
nodeKey := NodePublicKeyStripPrefix(registerRequest.NodeKey)
|
nodeKey := NodePublicKeyStripPrefix(registerRequest.NodeKey)
|
||||||
now := time.Now().UTC()
|
now := time.Now().UTC()
|
||||||
|
|
||||||
|
machineToRegister := Machine{
|
||||||
|
Name: registerRequest.Hostinfo.Hostname,
|
||||||
|
NamespaceID: pak.Namespace.ID,
|
||||||
|
MachineKey: machineKeyStr,
|
||||||
|
RegisterMethod: RegisterMethodAuthKey,
|
||||||
|
Expiry: ®isterRequest.Expiry,
|
||||||
|
NodeKey: nodeKey,
|
||||||
|
LastSeen: &now,
|
||||||
|
AuthKeyID: uint(pak.ID),
|
||||||
|
}
|
||||||
|
|
||||||
machine, err := h.RegisterMachine(
|
machine, err := h.RegisterMachine(
|
||||||
registerRequest.Hostinfo.Hostname,
|
machineToRegister,
|
||||||
machineKeyStr,
|
|
||||||
pak.Namespace.Name,
|
|
||||||
RegisterMethodAuthKey,
|
|
||||||
®isterRequest.Expiry,
|
|
||||||
pak,
|
|
||||||
&nodeKey,
|
|
||||||
&now,
|
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
|
|
10
grpcv1.go
10
grpcv1.go
|
@ -415,11 +415,11 @@ func (api headscaleV1APIServer) DebugCreateMachine(
|
||||||
HostInfo: datatypes.JSON(hostinfoJson),
|
HostInfo: datatypes.JSON(hostinfoJson),
|
||||||
}
|
}
|
||||||
|
|
||||||
// log.Trace().Caller().Interface("machine", newMachine).Msg("")
|
api.h.registrationCache.Set(
|
||||||
|
request.GetKey(),
|
||||||
if err := api.h.db.Create(&newMachine).Error; err != nil {
|
newMachine,
|
||||||
return nil, err
|
requestedExpiryCacheExpiration,
|
||||||
}
|
)
|
||||||
|
|
||||||
return &v1.DebugCreateMachineResponse{Machine: newMachine.toProto()}, nil
|
return &v1.DebugCreateMachineResponse{Machine: newMachine.toProto()}, nil
|
||||||
}
|
}
|
||||||
|
|
1
oidc.go
1
oidc.go
|
@ -344,7 +344,6 @@ func (h *Headscale) OIDCCallback(ctx *gin.Context) {
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var content bytes.Buffer
|
var content bytes.Buffer
|
||||||
|
|
Loading…
Reference in a new issue