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

webhook.go 1.8 kB

3 years ago
3 years ago
3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. "strings"
  8. "code.gitea.io/gitea/modules/log"
  9. )
  10. var (
  11. // Webhook settings
  12. Webhook = struct {
  13. QueueLength int
  14. DeliverTimeout int
  15. SkipTLSVerify bool
  16. Types []string
  17. PagingNum int
  18. ProxyURL string
  19. ProxyURLFixed *url.URL
  20. ProxyHosts []string
  21. Socks5Proxy string
  22. Socks5UserName string
  23. Socks5Password string
  24. Socks5ProxyHosts []string
  25. }{
  26. QueueLength: 1000,
  27. DeliverTimeout: 5,
  28. SkipTLSVerify: false,
  29. PagingNum: 10,
  30. ProxyURL: "",
  31. ProxyHosts: []string{},
  32. }
  33. )
  34. func newWebhookService() {
  35. sec := Cfg.Section("webhook")
  36. Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000)
  37. Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5)
  38. Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
  39. Webhook.Types = []string{"gitea", "gogs", "slack", "discord", "dingtalk", "telegram", "msteams", "feishu", "matrix"}
  40. Webhook.PagingNum = sec.Key("PAGING_NUM").MustInt(10)
  41. Webhook.ProxyURL = sec.Key("PROXY_URL").MustString("")
  42. Webhook.Socks5Proxy = sec.Key("SOCKS5_PROXY_URL").MustString("")
  43. Webhook.Socks5UserName = sec.Key("SOCKS5_USER_NAME").MustString("")
  44. Webhook.Socks5Password = sec.Key("SOCKS5_PASSWORD").MustString("")
  45. Webhook.Socks5ProxyHosts = strings.Split(sec.Key("SOCKS5_PROXY_HOST").MustString(""), ";")
  46. if Webhook.ProxyURL != "" {
  47. var err error
  48. Webhook.ProxyURLFixed, err = url.Parse(Webhook.ProxyURL)
  49. if err != nil {
  50. log.Error("Webhook PROXY_URL is not valid")
  51. Webhook.ProxyURL = ""
  52. }
  53. }
  54. Webhook.ProxyHosts = sec.Key("PROXY_HOSTS").Strings(",")
  55. log.Info("New WebhookService Inited.")
  56. }