mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-20 23:41:23 +02:00
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:
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/yusing/go-proxy/internal/metrics/uptime"
|
||||
"github.com/yusing/go-proxy/internal/net/gphttp/httpheaders"
|
||||
"github.com/yusing/go-proxy/internal/utils/strutils"
|
||||
"github.com/yusing/go-proxy/pkg"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -65,7 +66,7 @@ func (mux ServeMux) HandleFunc(methods, endpoint string, h any, requireAuth ...b
|
||||
func NewHandler(cfg config.ConfigInstance) http.Handler {
|
||||
mux := ServeMux{http.NewServeMux(), cfg}
|
||||
mux.HandleFunc("GET", "/v1", v1.Index)
|
||||
mux.HandleFunc("GET", "/v1/version", v1.GetVersion)
|
||||
mux.HandleFunc("GET", "/v1/version", pkg.GetVersionHTTPHandler())
|
||||
|
||||
mux.HandleFunc("GET", "/v1/stats", v1.Stats, true)
|
||||
mux.HandleFunc("POST", "/v1/reload", v1.Reload, true)
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/yusing/go-proxy/internal/net/gphttp"
|
||||
"github.com/yusing/go-proxy/pkg"
|
||||
)
|
||||
|
||||
func GetVersion(w http.ResponseWriter, r *http.Request) {
|
||||
gphttp.WriteBody(w, []byte(pkg.GetVersion()))
|
||||
}
|
||||
@@ -53,7 +53,7 @@ func (mon *HTTPHealthMonitor) CheckHealth() (result *health.HealthCheckResult, e
|
||||
}
|
||||
req.Close = true
|
||||
req.Header.Set("Connection", "close")
|
||||
req.Header.Set("User-Agent", "GoDoxy/"+pkg.GetVersion())
|
||||
req.Header.Set("User-Agent", "GoDoxy/"+pkg.GetVersion().String())
|
||||
|
||||
start := time.Now()
|
||||
resp, respErr := pinger.Do(req)
|
||||
|
||||
Reference in New Issue
Block a user