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

Method UpdateClients

internal/api/server.go:1604–1761  ·  view source on GitHub ↗

UpdateClients updates the server's client list and configuration. This method is called when the configuration or authentication tokens change. Parameters: - clients: The new slice of AI service clients - cfg: The new application configuration

(cfg *config.Config)

Source from the content-addressed store, hash-verified

1602// - clients: The new slice of AI service clients
1603// - cfg: The new application configuration
1604func (s *Server) UpdateClients(cfg *config.Config) {
1605 // Reconstruct old config from YAML snapshot to avoid reference sharing issues
1606 var oldCfg *config.Config
1607 if len(s.oldConfigYaml) > 0 {
1608 _ = yaml.Unmarshal(s.oldConfigYaml, &oldCfg)
1609 }
1610
1611 // Update request logger enabled state if it has changed
1612 previousRequestLog := false
1613 if oldCfg != nil {
1614 previousRequestLog = oldCfg.RequestLog
1615 }
1616 if s.requestLogger != nil && (oldCfg == nil || previousRequestLog != cfg.RequestLog) {
1617 if s.loggerToggle != nil {
1618 s.loggerToggle(cfg.RequestLog)
1619 } else if toggler, ok := s.requestLogger.(interface{ SetEnabled(bool) }); ok {
1620 toggler.SetEnabled(cfg.RequestLog)
1621 }
1622 }
1623
1624 if oldCfg == nil || oldCfg.Home.Enabled != cfg.Home.Enabled {
1625 if setter, ok := s.requestLogger.(interface{ SetHomeEnabled(bool) }); ok {
1626 setter.SetHomeEnabled(cfg.Home.Enabled)
1627 }
1628 }
1629
1630 if oldCfg == nil || oldCfg.LoggingToFile != cfg.LoggingToFile || oldCfg.LogsMaxTotalSizeMB != cfg.LogsMaxTotalSizeMB {
1631 if err := logging.ConfigureLogOutput(cfg); err != nil {
1632 log.Errorf("failed to reconfigure log output: %v", err)
1633 }
1634 }
1635
1636 if oldCfg == nil || oldCfg.UsageStatisticsEnabled != cfg.UsageStatisticsEnabled {
1637 redisqueue.SetUsageStatisticsEnabled(cfg.UsageStatisticsEnabled)
1638 }
1639
1640 if oldCfg == nil || oldCfg.RedisUsageQueueRetentionSeconds != cfg.RedisUsageQueueRetentionSeconds {
1641 redisqueue.SetRetentionSeconds(cfg.RedisUsageQueueRetentionSeconds)
1642 }
1643
1644 if s.requestLogger != nil && (oldCfg == nil || oldCfg.ErrorLogsMaxFiles != cfg.ErrorLogsMaxFiles) {
1645 if setter, ok := s.requestLogger.(interface{ SetErrorLogsMaxFiles(int) }); ok {
1646 setter.SetErrorLogsMaxFiles(cfg.ErrorLogsMaxFiles)
1647 }
1648 }
1649
1650 if oldCfg == nil || oldCfg.DisableCooling != cfg.DisableCooling {
1651 auth.SetQuotaCooldownDisabled(cfg.DisableCooling)
1652 }
1653 if oldCfg == nil || oldCfg.TransientErrorCooldownSeconds != cfg.TransientErrorCooldownSeconds {
1654 auth.SetTransientErrorCooldownSeconds(cfg.TransientErrorCooldownSeconds)
1655 }
1656
1657 if oldCfg != nil && oldCfg.DisableImageGeneration != cfg.DisableImageGeneration {
1658 log.Infof("disable-image-generation updated: %v -> %v", oldCfg.DisableImageGeneration, cfg.DisableImageGeneration)
1659 }
1660
1661 applySignatureCacheConfig(oldCfg, cfg)

Callers

nothing calls this directly

Calls 15

applyAccessConfigMethod · 0.95
ConfigureLogOutputFunction · 0.92
SetRetentionSecondsFunction · 0.92
SetQuotaCooldownDisabledFunction · 0.92
SetLogLevelFunction · 0.92
SetEnabledFunction · 0.92
SetCurrentConfigFunction · 0.92
CountAuthFilesFunction · 0.92

Tested by

no test coverage detected