code.gitea.io/gitea@v1.19.3/modules/setting/webhook.go (about) 1 // Copyright 2019 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package setting 5 6 import ( 7 "net/url" 8 9 "code.gitea.io/gitea/modules/log" 10 ) 11 12 // Webhook settings 13 var Webhook = struct { 14 QueueLength int 15 DeliverTimeout int 16 SkipTLSVerify bool 17 AllowedHostList string 18 Types []string 19 PagingNum int 20 ProxyURL string 21 ProxyURLFixed *url.URL 22 ProxyHosts []string 23 }{ 24 QueueLength: 1000, 25 DeliverTimeout: 5, 26 SkipTLSVerify: false, 27 PagingNum: 10, 28 ProxyURL: "", 29 ProxyHosts: []string{}, 30 } 31 32 func loadWebhookFrom(rootCfg ConfigProvider) { 33 sec := rootCfg.Section("webhook") 34 Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000) 35 Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5) 36 Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool() 37 Webhook.AllowedHostList = sec.Key("ALLOWED_HOST_LIST").MustString("") 38 Webhook.Types = []string{"gitea", "gogs", "slack", "discord", "dingtalk", "telegram", "msteams", "feishu", "matrix", "wechatwork", "packagist"} 39 Webhook.PagingNum = sec.Key("PAGING_NUM").MustInt(10) 40 Webhook.ProxyURL = sec.Key("PROXY_URL").MustString("") 41 if Webhook.ProxyURL != "" { 42 var err error 43 Webhook.ProxyURLFixed, err = url.Parse(Webhook.ProxyURL) 44 if err != nil { 45 log.Error("Webhook PROXY_URL is not valid") 46 Webhook.ProxyURL = "" 47 } 48 } 49 Webhook.ProxyHosts = sec.Key("PROXY_HOSTS").Strings(",") 50 }