mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-06 08:03:47 +00:00
feat: show upstream key suffix per request
This commit is contained in:
1 parent
6a03be875d
commit
3be4b393c0
7 files changed
+170
-30
No files matched your search
@@ -480,14 +480,30 @@ func (a *AdminServer) handleDebugInference(w http.ResponseWriter, r *http.Reques
|
||||
duration := time.Since(started)
|
||||
requestID := recorder.Header().Get("x-request-id")
|
||||
if requestID != "" {
|
||||
upstream := a.monitor.Snapshot().Upstream.Recent
|
||||
for index := len(upstream) - 1; index >= 0; index-- {
|
||||
if upstream[index].RequestID == requestID {
|
||||
route.Anonymous = upstream[index].Anonymous
|
||||
route.Tier = Tier(upstream[index].Tier)
|
||||
snapshot := a.monitor.Snapshot().Upstream
|
||||
for index := len(snapshot.Requests) - 1; index >= 0; index-- {
|
||||
if snapshot.Requests[index].RequestID == requestID {
|
||||
requestRoute := snapshot.Requests[index]
|
||||
route.Anonymous = requestRoute.Anonymous
|
||||
route.Tier = Tier(requestRoute.Tier)
|
||||
route.KeyID = requestRoute.KeyID
|
||||
route.Channel = requestRoute.Channel
|
||||
route.Attempts = requestRoute.Attempts
|
||||
break
|
||||
}
|
||||
}
|
||||
if route.KeyID == "" {
|
||||
for index := len(snapshot.Recent) - 1; index >= 0; index-- {
|
||||
if snapshot.Recent[index].RequestID == requestID {
|
||||
attempt := snapshot.Recent[index]
|
||||
route.Anonymous = attempt.Anonymous
|
||||
route.Tier = Tier(attempt.Tier)
|
||||
route.KeyID = attempt.KeyID
|
||||
route.Channel = attempt.Channel
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var raw any
|
||||
if json.Unmarshal(recorder.body.Bytes(), &raw) != nil {
|
||||
@@ -655,10 +671,10 @@ func maskSecrets(values []string, proxy bool) []SecretView {
|
||||
|
||||
func maskValue(value string) string {
|
||||
runes := []rune(value)
|
||||
if len(runes) <= 4 {
|
||||
if len(runes) <= 5 {
|
||||
return "••••"
|
||||
}
|
||||
return "••••" + string(runes[len(runes)-4:])
|
||||
return "••••" + string(runes[len(runes)-5:])
|
||||
}
|
||||
|
||||
func resolveSecrets(inputs []SecretInput, existing []string) ([]string, error) {
|
||||
|
||||
Reference in new issue
Block a user