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

Method resolveConfigVertexCompatKey

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

Source from the content-addressed store, hash-verified

2247}
2248
2249func (s *Service) resolveConfigVertexCompatKey(auth *coreauth.Auth) *config.VertexCompatKey {
2250 if auth == nil || s.cfg == nil {
2251 return nil
2252 }
2253 var attrKey, attrBase string
2254 if auth.Attributes != nil {
2255 attrKey = strings.TrimSpace(auth.Attributes["api_key"])
2256 attrBase = strings.TrimSpace(auth.Attributes["base_url"])
2257 }
2258 for i := range s.cfg.VertexCompatAPIKey {
2259 entry := &s.cfg.VertexCompatAPIKey[i]
2260 cfgKey := strings.TrimSpace(entry.APIKey)
2261 cfgBase := strings.TrimSpace(entry.BaseURL)
2262 if attrKey != "" && strings.EqualFold(cfgKey, attrKey) {
2263 if cfgBase == "" || strings.EqualFold(cfgBase, attrBase) {
2264 return entry
2265 }
2266 continue
2267 }
2268 if attrKey == "" && attrBase != "" && strings.EqualFold(cfgBase, attrBase) {
2269 return entry
2270 }
2271 }
2272 if attrKey != "" {
2273 for i := range s.cfg.VertexCompatAPIKey {
2274 entry := &s.cfg.VertexCompatAPIKey[i]
2275 if strings.EqualFold(strings.TrimSpace(entry.APIKey), attrKey) {
2276 return entry
2277 }
2278 }
2279 }
2280 return nil
2281}
2282
2283func (s *Service) resolveConfigCodexKey(auth *coreauth.Auth) *config.CodexKey {
2284 if auth == nil || s.cfg == nil {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected