Files
ProxyPilot/internal/watcher/diff/auth_diff.go
RCD a6e817b72f Merge upstream CLIProxyAPI v6.7.47 into ProxyPilot
Changes from v6.7.43-v6.7.47:
- fix(logging): expand tilde in auth-dir and log resolution errors
- feat(pprof): add configurable pprof HTTP debug server
- feat(watcher): log auth field changes on reload
- fix(cliproxy): update auth before model registration
- docs: README updates, AICodeMirror sponsorship

Fixed upstream test bug: TestOpenAIResponsesToOpenAI now correctly expects
built-in tools to be dropped (upstream intentionally changed this behavior).

Upstream: https://github.com/router-for-me/CLIProxyAPI/releases/tag/v6.7.47
2026-02-04 22:50:54 +07:00

45 lines
1.3 KiB
Go

// auth_diff.go computes human-readable diffs for auth file field changes.
package diff
import (
"fmt"
"strings"
coreauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth"
)
// BuildAuthChangeDetails computes a redacted, human-readable list of auth field changes.
// Only prefix, proxy_url, and disabled fields are tracked; sensitive data is never printed.
func BuildAuthChangeDetails(oldAuth, newAuth *coreauth.Auth) []string {
changes := make([]string, 0, 3)
// Handle nil cases by using empty Auth as default
if oldAuth == nil {
oldAuth = &coreauth.Auth{}
}
if newAuth == nil {
return changes
}
// Compare prefix
oldPrefix := strings.TrimSpace(oldAuth.Prefix)
newPrefix := strings.TrimSpace(newAuth.Prefix)
if oldPrefix != newPrefix {
changes = append(changes, fmt.Sprintf("prefix: %s -> %s", oldPrefix, newPrefix))
}
// Compare proxy_url (redacted)
oldProxy := strings.TrimSpace(oldAuth.ProxyURL)
newProxy := strings.TrimSpace(newAuth.ProxyURL)
if oldProxy != newProxy {
changes = append(changes, fmt.Sprintf("proxy_url: %s -> %s", formatProxyURL(oldProxy), formatProxyURL(newProxy)))
}
// Compare disabled
if oldAuth.Disabled != newAuth.Disabled {
changes = append(changes, fmt.Sprintf("disabled: %t -> %t", oldAuth.Disabled, newAuth.Disabled))
}
return changes
}