(r *http.Request)
| 554 | var contextKeyPeer = ctxkey.New("peer-capabilities", peerCapabilities{}) |
| 555 | |
| 556 | func (s *Server) setPeer(r *http.Request) (*http.Request, error) { |
| 557 | // TODO(tailscale/corp#16695,sonia): We also call StatusWithoutPeers and |
| 558 | // WhoIs when originally checking for a session from authorizeRequest. |
| 559 | // Would be nice if we could pipe those through to here so we don't end |
| 560 | // up having to re-call them to grab the peer capabilities. |
| 561 | status, err := s.lc.StatusWithoutPeers(r.Context()) |
| 562 | if err != nil { |
| 563 | return nil, err |
| 564 | } |
| 565 | whois, err := s.lc.WhoIs(r.Context(), r.RemoteAddr) |
| 566 | if err != nil { |
| 567 | return nil, err |
| 568 | } |
| 569 | peer, err := toPeerCapabilities(status, whois) |
| 570 | if err != nil { |
| 571 | return nil, err |
| 572 | } |
| 573 | return r.WithContext(contextKeyPeer.WithValue(r.Context(), peer)), nil |
| 574 | } |
| 575 | |
| 576 | func (s *Server) getPeer(ctx context.Context) peerCapabilities { |
| 577 | return contextKeyPeer.Value(ctx) |
no test coverage detected