From 0c0bc021d705c0d1fc1eab1f28dc2bdbcf48ce79 Mon Sep 17 00:00:00 2001 From: 3405691582 Date: Tue, 21 Apr 2026 15:48:56 +0000 Subject: [PATCH] Add a handler to the WebRTC operator for context. We may be running in environments where only the WebRTC operator is exposed. This can make it difficult to verify information about that environment; for example, is the operator (and cvd, etc.) running in a container, or not? One simple way to do this is to expose an endpoint on the operator for debugging purposes, and one simple way to get information about the environment is to expose the hostname. For now, we just expose the hostname, but it may be worthwhile adding extra fields in the future. --- frontend/src/liboperator/operator/operator.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/frontend/src/liboperator/operator/operator.go b/frontend/src/liboperator/operator/operator.go index 6bd000bdb0a..3a9371f7c28 100644 --- a/frontend/src/liboperator/operator/operator.go +++ b/frontend/src/liboperator/operator/operator.go @@ -174,9 +174,23 @@ func CreateHttpHandlers( router.HandleFunc("/infra_config", func(w http.ResponseWriter, r *http.Request) { ReplyJSONOK(w, config) }).Methods("GET") + router.HandleFunc("/context", func(w http.ResponseWriter, r *http.Request) { + getContext(w, r) + }).Methods("GET") return router } +func getContext(w http.ResponseWriter, r *http.Request) { + hostname, err := os.Hostname() + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + ctx := make(map[string]interface{}) + ctx["hostname"] = hostname + ReplyJSONOK(w, ctx) +} + // Control endpoint func controlEndpoint(c *JSONUnix, pool *DevicePool) { log.Println("Controller connected")