MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / resolveConfigClaudeKey

Method resolveConfigClaudeKey

sdk/cliproxy/service.go:2184–2221  ·  view source on GitHub ↗
(auth *coreauth.Auth)

Source from the content-addressed store, hash-verified

2182}
2183
2184func (s *Service) resolveConfigClaudeKey(auth *coreauth.Auth) *config.ClaudeKey {
2185 if auth == nil || s.cfg == nil {
2186 return nil
2187 }
2188 var attrKey, attrBase string
2189 if auth.Attributes != nil {
2190 attrKey = strings.TrimSpace(auth.Attributes["api_key"])
2191 attrBase = strings.TrimSpace(auth.Attributes["base_url"])
2192 }
2193 for i := range s.cfg.ClaudeKey {
2194 entry := &s.cfg.ClaudeKey[i]
2195 cfgKey := strings.TrimSpace(entry.APIKey)
2196 cfgBase := strings.TrimSpace(entry.BaseURL)
2197 if attrKey != "" && attrBase != "" {
2198 if strings.EqualFold(cfgKey, attrKey) && strings.EqualFold(cfgBase, attrBase) {
2199 return entry
2200 }
2201 continue
2202 }
2203 if attrKey != "" && strings.EqualFold(cfgKey, attrKey) {
2204 if cfgBase == "" || strings.EqualFold(cfgBase, attrBase) {
2205 return entry
2206 }
2207 }
2208 if attrKey == "" && attrBase != "" && strings.EqualFold(cfgBase, attrBase) {
2209 return entry
2210 }
2211 }
2212 if attrKey != "" {
2213 for i := range s.cfg.ClaudeKey {
2214 entry := &s.cfg.ClaudeKey[i]
2215 if strings.EqualFold(strings.TrimSpace(entry.APIKey), attrKey) {
2216 return entry
2217 }
2218 }
2219 }
2220 return nil
2221}
2222
2223func (s *Service) resolveConfigGeminiKey(auth *coreauth.Auth) *config.GeminiKey {
2224 if auth == nil || s.cfg == nil {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected