gitea源码

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2023 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package setting
  4. import (
  5. "strconv"
  6. "code.gitea.io/gitea/modules/log"
  7. )
  8. var Camo = struct {
  9. Enabled bool
  10. ServerURL string `ini:"SERVER_URL"`
  11. HMACKey string `ini:"HMAC_KEY"`
  12. Always bool
  13. }{}
  14. func loadCamoFrom(rootCfg ConfigProvider) {
  15. mustMapSetting(rootCfg, "camo", &Camo)
  16. if Camo.Enabled {
  17. oldValue := rootCfg.Section("camo").Key("ALLWAYS").MustString("")
  18. if oldValue != "" {
  19. log.Warn("camo.ALLWAYS is deprecated, use camo.ALWAYS instead")
  20. Camo.Always, _ = strconv.ParseBool(oldValue)
  21. }
  22. if Camo.ServerURL == "" || Camo.HMACKey == "" {
  23. log.Fatal(`Camo settings require "SERVER_URL" and HMAC_KEY`)
  24. }
  25. }
  26. }