summaryrefslogtreecommitdiffstats
path: root/models/webhook.go
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2015-02-10 21:06:59 -0500
committerUnknwon <joe2010xtmf@163.com>2015-02-10 21:06:59 -0500
commit6a23252edc36a3d99b35af69a310fd31f687f3cb (patch)
tree94b1355117f54a54596dad3f9bb2b56f9e6fec19 /models/webhook.go
parente407df54f000bf3e078e67f043571293e4edad5d (diff)
downloadgitea-6a23252edc36a3d99b35af69a310fd31f687f3cb.tar.gz
gitea-6a23252edc36a3d99b35af69a310fd31f687f3cb.zip
able to allow insecure certification of webhook for #891
Diffstat (limited to 'models/webhook.go')
-rw-r--r--models/webhook.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/models/webhook.go b/models/webhook.go
index 8e112ac572..34349bb598 100644
--- a/models/webhook.go
+++ b/models/webhook.go
@@ -5,6 +5,7 @@
package models
import (
+ "crypto/tls"
"encoding/json"
"errors"
"io/ioutil"
@@ -307,13 +308,14 @@ func DeliverHooks() {
defer func() { isShooting = false }()
tasks := make([]*HookTask, 0, 10)
- timeout := time.Duration(setting.WebhookDeliverTimeout) * time.Second
+ timeout := time.Duration(setting.Webhook.DeliverTimeout) * time.Second
x.Where("is_delivered=?", false).Iterate(new(HookTask),
func(idx int, bean interface{}) error {
t := bean.(*HookTask)
req := httplib.Post(t.Url).SetTimeout(timeout, timeout).
Header("X-Gogs-Delivery", t.Uuid).
- Header("X-Gogs-Event", string(t.EventType))
+ Header("X-Gogs-Event", string(t.EventType)).
+ SetTLSClientConfig(&tls.Config{InsecureSkipVerify: setting.Webhook.AllowInsecureCertification})
switch t.ContentType {
case JSON:
@@ -329,7 +331,7 @@ func DeliverHooks() {
case GOGS:
{
if _, err := req.Response(); err != nil {
- log.Error(4, "Delivery: %v", err)
+ log.Error(5, "Delivery: %v", err)
} else {
t.IsSucceed = true
}
@@ -337,15 +339,15 @@ func DeliverHooks() {
case SLACK:
{
if res, err := req.Response(); err != nil {
- log.Error(4, "Delivery: %v", err)
+ log.Error(5, "Delivery: %v", err)
} else {
defer res.Body.Close()
contents, err := ioutil.ReadAll(res.Body)
if err != nil {
- log.Error(4, "%s", err)
+ log.Error(5, "%s", err)
} else {
if string(contents) != "ok" {
- log.Error(4, "slack failed with: %s", string(contents))
+ log.Error(5, "slack failed with: %s", string(contents))
} else {
t.IsSucceed = true
}