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

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