director makes sure agentIDKey is set on the context in the reverse proxy. This allows the transport to correctly identify which agent to dial to.
(agentID uuid.UUID, prev func(req *http.Request))
| 255 | // director makes sure agentIDKey is set on the context in the reverse proxy. |
| 256 | // This allows the transport to correctly identify which agent to dial to. |
| 257 | func (*ServerTailnet) director(agentID uuid.UUID, prev func(req *http.Request)) func(req *http.Request) { |
| 258 | return func(req *http.Request) { |
| 259 | ctx := context.WithValue(req.Context(), agentIDKey{}, agentID) |
| 260 | *req = *req.WithContext(ctx) |
| 261 | prev(req) |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | func (s *ServerTailnet) dialContext(ctx context.Context, network, addr string) (net.Conn, error) { |
| 266 | agentID, ok := ctx.Value(agentIDKey{}).(uuid.UUID) |
no test coverage detected