fix: loosen agent version checking

- warn instead of error when version mismatch
- check for major version only
- better version parsing
This commit is contained in:
yusing
2025-04-26 05:38:59 +08:00
parent e4be403bef
commit 01179adfa8
6 changed files with 130 additions and 40 deletions

View File

@@ -37,9 +37,7 @@ func NewAgentHandler() http.Handler {
mux := ServeMux{http.NewServeMux()}
mux.HandleFunc(agent.EndpointProxyHTTP+"/{path...}", ProxyHTTP)
mux.HandleMethods("GET", agent.EndpointVersion, func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(pkg.GetVersion()))
})
mux.HandleMethods("GET", agent.EndpointVersion, pkg.GetVersionHTTPHandler())
mux.HandleMethods("GET", agent.EndpointName, func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, env.AgentName)
})