MCPcopy Create free account
hub / github.com/coder/wush / NoisePollNetMapHandler

Method NoisePollNetMapHandler

tsserver/server.go:439–476  ·  view source on GitHub ↗
(
	w http.ResponseWriter,
	req *http.Request,
)

Source from the content-addressed store, hash-verified

437}
438
439func (ns *noiseServer) NoisePollNetMapHandler(
440 w http.ResponseWriter,
441 req *http.Request,
442) {
443 ns.logger.Info("got noise poll request")
444
445 mapRequest := tailcfg.MapRequest{}
446 err := json.NewDecoder(req.Body).Decode(&mapRequest)
447 if err != nil {
448 ns.logger.Error("failed to decode map request", "err", err)
449 http.Error(w, err.Error(), http.StatusBadRequest)
450 return
451 }
452
453 node := ns.getSelfNode()
454
455 if node == nil {
456 ns.logger.Info("noise poll request before registration")
457 http.Error(w, "node is nil", http.StatusUnauthorized)
458 return
459 }
460
461 switch parseMapRequestType(&mapRequest) {
462 case mapRequestUnknown:
463 ns.logger.Error("unknown map request type")
464 http.Error(w, "unknown request type", http.StatusBadRequest)
465 return
466
467 case mapRequestStreaming:
468 ns.logger.Info("streaming")
469 ns.handleStreaming(req.Context(), w, &mapRequest)
470
471 case mapRequestEndpointUpdate:
472 ns.logger.Info("endpoint update")
473 ns.handleEndpointUpdate(w, &mapRequest)
474 }
475
476}
477
478func (ns *noiseServer) peerMap() []*tailcfg.Node {
479 peers := []*tailcfg.Node{}

Callers

nothing calls this directly

Calls 4

getSelfNodeMethod · 0.95
handleStreamingMethod · 0.95
handleEndpointUpdateMethod · 0.95
parseMapRequestTypeFunction · 0.85

Tested by

no test coverage detected