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.

webhook.go 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. AllowedHostList string
  16. Types []string
  17. PagingNum int
  18. ProxyURL string
  19. ProxyURLFixed *url.URL
  20. ProxyHosts []string
  21. }{
  22. QueueLength: 1000,
  23. DeliverTimeout: 5,
  24. SkipTLSVerify: false,
  25. PagingNum: 10,
  26. ProxyURL: "",
  27. ProxyHosts: []string{},
  28. }
  29. )
  30. func newWebhookService() {
  31. sec := Cfg.Section("webhook")
  32. Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000)
  33. Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5)
  34. Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
  35. Webhook.AllowedHostList = sec.Key("ALLOWED_HOST_LIST").MustString("")
  36. Webhook.Types = []string{"gitea", "gogs", "slack", "discord", "dingtalk", "telegram", "msteams", "feishu", "matrix", "wechatwork"}
  37. Webhook.PagingNum = sec.Key("PAGING_NUM").MustInt(10)
  38. Webhook.ProxyURL = sec.Key("PROXY_URL").MustString("")
  39. if Webhook.ProxyURL != "" {
  40. var err error
  41. Webhook.ProxyURLFixed, err = url.Parse(Webhook.ProxyURL)
  42. if err != nil {
  43. log.Error("Webhook PROXY_URL is not valid")
  44. Webhook.ProxyURL = ""
  45. }
  46. }
  47. Webhook.ProxyHosts = sec.Key("PROXY_HOSTS").Strings(",")
  48. }