Improvements on Noise implementation (#1379)

This commit is contained in:
Juan Font 2023-05-02 08:15:33 +02:00 committed by GitHub
parent a2b760834f
commit 80772033ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 121 additions and 20 deletions

View file

@ -10,7 +10,7 @@ import (
)
// // NoiseRegistrationHandler handles the actual registration process of a machine.
func (t *ts2021App) NoiseRegistrationHandler(
func (ns *noiseServer) NoiseRegistrationHandler(
writer http.ResponseWriter,
req *http.Request,
) {
@ -20,6 +20,11 @@ func (t *ts2021App) NoiseRegistrationHandler(
return
}
log.Trace().
Any("headers", req.Header).
Msg("Headers")
body, _ := io.ReadAll(req.Body)
registerRequest := tailcfg.RegisterRequest{}
if err := json.Unmarshal(body, &registerRequest); err != nil {
@ -33,5 +38,7 @@ func (t *ts2021App) NoiseRegistrationHandler(
return
}
t.headscale.handleRegisterCommon(writer, req, registerRequest, t.conn.Peer(), true)
ns.nodeKey = registerRequest.NodeKey
ns.headscale.handleRegisterCommon(writer, req, registerRequest, ns.conn.Peer(), true)
}