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.

51 lines
1.3 KiB

  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package setting
  5. import (
  6. "net/url"
  7. "code.gitea.io/gitea/modules/log"
  8. )
  9. var (
  10. // Webhook settings
  11. Webhook = struct {
  12. QueueLength int
  13. DeliverTimeout int
  14. SkipTLSVerify bool
  15. Types []string
  16. PagingNum int
  17. ProxyURL string
  18. ProxyURLFixed *url.URL
  19. ProxyHosts []string
  20. }{
  21. QueueLength: 1000,
  22. DeliverTimeout: 5,
  23. SkipTLSVerify: false,
  24. PagingNum: 10,
  25. ProxyURL: "",
  26. ProxyHosts: []string{},
  27. }
  28. )
  29. func newWebhookService() {
  30. sec := Cfg.Section("webhook")
  31. Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000)
  32. Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5)
  33. Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
  34. Webhook.Types = []string{"gitea", "gogs", "slack", "discord", "dingtalk", "telegram", "msteams"}
  35. Webhook.PagingNum = sec.Key("PAGING_NUM").MustInt(10)
  36. Webhook.ProxyURL = sec.Key("PROXY_URL").MustString("")
  37. if Webhook.ProxyURL != "" {
  38. var err error
  39. Webhook.ProxyURLFixed, err = url.Parse(Webhook.ProxyURL)
  40. if err != nil {
  41. log.Error("Webhook PROXY_URL is not valid")
  42. Webhook.ProxyURL = ""
  43. }
  44. }
  45. Webhook.ProxyHosts = sec.Key("PROXY_HOSTS").Strings(",")
  46. }