You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package setting
  4. import (
  5. "net/url"
  6. "code.gitea.io/gitea/modules/log"
  7. )
  8. // Proxy settings
  9. var Proxy = struct {
  10. Enabled bool
  11. ProxyURL string
  12. ProxyURLFixed *url.URL
  13. ProxyHosts []string
  14. }{
  15. Enabled: false,
  16. ProxyURL: "",
  17. ProxyHosts: []string{},
  18. }
  19. func loadProxyFrom(rootCfg ConfigProvider) {
  20. sec := rootCfg.Section("proxy")
  21. Proxy.Enabled = sec.Key("PROXY_ENABLED").MustBool(false)
  22. Proxy.ProxyURL = sec.Key("PROXY_URL").MustString("")
  23. if Proxy.ProxyURL != "" {
  24. var err error
  25. Proxy.ProxyURLFixed, err = url.Parse(Proxy.ProxyURL)
  26. if err != nil {
  27. log.Error("Global PROXY_URL is not valid")
  28. Proxy.ProxyURL = ""
  29. }
  30. }
  31. Proxy.ProxyHosts = sec.Key("PROXY_HOSTS").Strings(",")
  32. }