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

Method loadFileClients

internal/watcher/clients.go:340–375  ·  view source on GitHub ↗
(cfg *config.Config)

Source from the content-addressed store, hash-verified

338}
339
340func (w *Watcher) loadFileClients(cfg *config.Config) int {
341 authFileCount := 0
342 successfulAuthCount := 0
343
344 authDir, errResolveAuthDir := util.ResolveAuthDir(cfg.AuthDir)
345 if errResolveAuthDir != nil {
346 log.Errorf("failed to resolve auth directory: %v", errResolveAuthDir)
347 return 0
348 }
349 if authDir == "" {
350 return 0
351 }
352
353 entries, errReadDir := os.ReadDir(authDir)
354 if errReadDir != nil {
355 log.Errorf("error reading auth directory: %v", errReadDir)
356 return 0
357 }
358 for _, entry := range entries {
359 if entry == nil || entry.IsDir() {
360 continue
361 }
362 name := entry.Name()
363 if !strings.HasSuffix(strings.ToLower(name), ".json") {
364 continue
365 }
366 authFileCount++
367 log.Debugf("processing auth file %d: %s", authFileCount, name)
368 fullPath := filepath.Join(authDir, name)
369 if data, errReadFile := os.ReadFile(fullPath); errReadFile == nil && len(data) > 0 {
370 successfulAuthCount++
371 }
372 }
373 log.Debugf("auth directory scan complete - found %d .json files, %d readable", authFileCount, successfulAuthCount)
374 return authFileCount
375}
376
377func BuildAPIKeyClients(cfg *config.Config) (int, int, int, int, int) {
378 geminiAPIKeyCount := 0

Callers 2

reloadClientsMethod · 0.95

Calls 2

ResolveAuthDirFunction · 0.92
NameMethod · 0.65

Tested by 1