anti_degrade_strategies.go 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package service
  2. // Anti-degradation strategy profiles are deliberately data-driven. The
  3. // profile registry describes the runtime knobs that are safe to compare in a
  4. // controlled account test; it does not grant additional upstream permissions
  5. // or alter credentials.
  6. type AntiDegradeStrategyProfile struct {
  7. ID AntiDegradeMode `json:"id"`
  8. Name string `json:"name"`
  9. Description string `json:"description"`
  10. Category string `json:"category"`
  11. IdentityMode string `json:"identity_mode"`
  12. TLSProfile string `json:"tls_profile"`
  13. MaxConcurrency int `json:"max_concurrency"`
  14. Risk string `json:"risk"`
  15. ApplySupported bool `json:"apply_supported"`
  16. RequiresOpenAI bool `json:"requires_openai_oauth"`
  17. DiagnosticOnly bool `json:"diagnostic_only"`
  18. }
  19. var antiDegradeStrategyProfiles = []AntiDegradeStrategyProfile{
  20. {ID: AntiDegradeModeNative, Name: "原生基线", Description: "不改写身份与传输策略,仅使用账号当前配置。", Category: "常用", IdentityMode: "off", TLSProfile: "account", MaxConcurrency: 0, Risk: "低", ApplySupported: false, DiagnosticOnly: true},
  21. {ID: AntiDegradeModeMinimal, Name: "最小兼容", Description: "仅固定账号设备身份,保留独立会话和线程。", Category: "常用", IdentityMode: "device", TLSProfile: "standard", MaxConcurrency: 8, Risk: "低", ApplySupported: true, RequiresOpenAI: true},
  22. {ID: AntiDegradeModeSession, Name: "会话兼容", Description: "固定设备与账号会话,按客户端会话派生线程。", Category: "诊断", IdentityMode: "session", TLSProfile: "standard", MaxConcurrency: 8, Risk: "中", ApplySupported: true, RequiresOpenAI: true, DiagnosticOnly: true},
  23. {ID: AntiDegradeModeLegacy, Name: "初代兼容", Description: "默认策略,复用 sub2 初代的 session 身份和 Node.js 24 传输。", Category: "常用", IdentityMode: "session", TLSProfile: "nodejs24", MaxConcurrency: 16, Risk: "中", ApplySupported: true},
  24. {ID: AntiDegradeMode1, Name: "兼容架构 v3", Description: "稳定设备身份、独立会话、标准传输和并发上限。", Category: "常用", IdentityMode: "device", TLSProfile: "standard", MaxConcurrency: 16, Risk: "中", ApplySupported: true, RequiresOpenAI: true},
  25. {ID: AntiDegradeMode2, Name: "完整收敛", Description: "设备、会话和线程全部收敛,仅用于强对照实验。", Category: "诊断", IdentityMode: "full", TLSProfile: "nodejs22", MaxConcurrency: 8, Risk: "高", ApplySupported: true, RequiresOpenAI: true, DiagnosticOnly: true},
  26. {ID: AntiDegradeModeTLSNode24, Name: "Node.js 24 对照", Description: "保持设备身份,单独对照 Node.js 24 TLS。", Category: "诊断", IdentityMode: "device", TLSProfile: "nodejs24", MaxConcurrency: 8, Risk: "中", ApplySupported: true, RequiresOpenAI: true, DiagnosticOnly: true},
  27. {ID: AntiDegradeModeLowConcurrency, Name: "低并发稳定", Description: "会话兼容配合低并发,用于排查限流和连接复用。", Category: "诊断", IdentityMode: "session", TLSProfile: "standard", MaxConcurrency: 4, Risk: "低", ApplySupported: true, RequiresOpenAI: true, DiagnosticOnly: true},
  28. }
  29. func ListAntiDegradeStrategyProfiles() []AntiDegradeStrategyProfile {
  30. profiles := make([]AntiDegradeStrategyProfile, len(antiDegradeStrategyProfiles))
  31. copy(profiles, antiDegradeStrategyProfiles)
  32. return profiles
  33. }
  34. func antiDegradeStrategyProfile(mode AntiDegradeMode) AntiDegradeStrategyProfile {
  35. for _, profile := range antiDegradeStrategyProfiles {
  36. if profile.ID == mode {
  37. return profile
  38. }
  39. }
  40. return AntiDegradeStrategyProfile{}
  41. }