1// Copyright 2019 The Gitea Authors. All rights reserved.
2// SPDX-License-Identifier: MIT
3
4package setting
5
6import (
7 "net/url"
8
9 "forgejo.org/modules/log"
10)
11
12// Webhook settings
13var Webhook = struct {
14 QueueLength int
15 DeliverTimeout int
16 SkipTLSVerify bool
17 AllowedHostList string
18 PagingNum int
19 ProxyURL string
20 ProxyURLFixed *url.URL
21 ProxyHosts []string
22 PayloadCommitLimit int
23}{
24 QueueLength: 1000,
25 DeliverTimeout: 5,
26 SkipTLSVerify: false,
27 PagingNum: 10,
28 ProxyURL: "",
29 ProxyHosts: []string{},
30 PayloadCommitLimit: 15,
31}
32
33func loadWebhookFrom(rootCfg ConfigProvider) {
34 sec := rootCfg.Section("webhook")
35 Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000)
36 Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5)
37 Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
38 Webhook.AllowedHostList = sec.Key("ALLOWED_HOST_LIST").MustString("")
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 Webhook.PayloadCommitLimit = sec.Key("PAYLOAD_COMMIT_LIMIT").MustInt(15)
51}