remove readonly case for mapresponse, dont think it is used (#1556)

This commit is contained in:
Kristoffer Dalby 2023-09-25 14:27:24 -07:00 committed by GitHub
parent 64c0a6523f
commit 01b85e5232
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -139,15 +139,6 @@ func (h *Headscale) handlePoll(
return return
} }
// Handle requests not related to continouos updates immediately.
// TODO(kradalby): I am not sure if this has any function based on
// incoming requests from clients.
if mapRequest.ReadOnly && !mapRequest.Stream {
h.handleReadOnly(writer, node, mapRequest, isNoise)
return
}
now := time.Now().UTC() now := time.Now().UTC()
node.LastSeen = &now node.LastSeen = &now
node.Hostname = mapRequest.Hostinfo.Hostname node.Hostname = mapRequest.Hostinfo.Hostname
@ -387,52 +378,6 @@ func closeChanWithLog[C chan []byte | chan struct{} | chan types.StateUpdate](ch
close(channel) close(channel)
} }
// TODO(kradalby): This might not actually be used,
// observing incoming client requests indicates it
// is not.
func (h *Headscale) handleReadOnly(
writer http.ResponseWriter,
node *types.Node,
mapRequest tailcfg.MapRequest,
isNoise bool,
) {
logInfo, logErr := logPollFunc(mapRequest, node, isNoise)
mapp := mapper.NewMapper(
node,
// TODO(kradalby): It might not be acceptable to send
// an empty peer list here.
types.Nodes{},
h.privateKey2019,
isNoise,
h.DERPMap,
h.cfg.BaseDomain,
h.cfg.DNSConfig,
h.cfg.LogTail.Enabled,
h.cfg.RandomizeClientPort,
)
logInfo("Client is starting up. Probably interested in a DERP map")
mapResp, err := mapp.FullMapResponse(mapRequest, node, h.ACLPolicy)
if err != nil {
logErr(err, "Failed to create MapResponse")
http.Error(writer, "", http.StatusInternalServerError)
return
}
writer.Header().Set("Content-Type", "application/json; charset=utf-8")
writer.WriteHeader(http.StatusOK)
_, err = writer.Write(mapResp)
if err != nil {
logErr(err, "Failed to write response")
}
if f, ok := writer.(http.Flusher); ok {
f.Flush()
}
}
func (h *Headscale) handleLiteRequest( func (h *Headscale) handleLiteRequest(
writer http.ResponseWriter, writer http.ResponseWriter,
node *types.Node, node *types.Node,