( w http.ResponseWriter, req *http.Request, )
| 437 | } |
| 438 | |
| 439 | func (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 | |
| 478 | func (ns *noiseServer) peerMap() []*tailcfg.Node { |
| 479 | peers := []*tailcfg.Node{} |
nothing calls this directly
no test coverage detected