summaryrefslogtreecommitdiffstats
path: root/matterhook
diff options
context:
space:
mode:
authorWim <wim@42.be>2015-10-25 01:00:19 +0200
committerWim <wim@42.be>2015-10-25 01:00:19 +0200
commit8b6a00d1c58ee505fa1f5515d561eb909cb8063a (patch)
tree989fd9184a815f8d3581b77f889d0deb73420e3b /matterhook
parent43738dbc89c888967181309002dc46b2c64990a0 (diff)
downloadmatterbridge-msglm-8b6a00d1c58ee505fa1f5515d561eb909cb8063a.tar.gz
matterbridge-msglm-8b6a00d1c58ee505fa1f5515d561eb909cb8063a.tar.bz2
matterbridge-msglm-8b6a00d1c58ee505fa1f5515d561eb909cb8063a.zip
Add SkipTLSVerify option for mattermost, allows selfsigned certificates
Diffstat (limited to 'matterhook')
-rw-r--r--matterhook/matterhook.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/matterhook/matterhook.go b/matterhook/matterhook.go
index ed062499..1ff1f428 100644
--- a/matterhook/matterhook.go
+++ b/matterhook/matterhook.go
@@ -3,6 +3,7 @@ package matterhook
import (
"bytes"
+ "crypto/tls"
"encoding/json"
"fmt"
"github.com/gorilla/schema"
@@ -39,16 +40,18 @@ type IMessage struct {
// Client for Mattermost.
type Client struct {
- url string
- In chan IMessage
- Out chan OMessage
+ url string
+ In chan IMessage
+ Out chan OMessage
+ httpclient *http.Client
Config
}
// Config for client.
type Config struct {
- Port int // Port to listen on.
- Token string // Only allow this token from Mattermost. (Allow everything when empty)
+ Port int // Port to listen on.
+ Token string // Only allow this token from Mattermost. (Allow everything when empty)
+ InsecureSkipVerify bool // disable certificate checking
}
// New Mattermost client.
@@ -57,6 +60,11 @@ func New(url string, config Config) *Client {
if c.Port == 0 {
c.Port = 9999
}
+ tr := &http.Transport{
+ TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify},
+ }
+ c.httpclient = &http.Client{Transport: tr}
+
go c.StartServer()
return c
}
@@ -124,7 +132,7 @@ func (c *Client) Send(msg OMessage) error {
if err != nil {
return err
}
- resp, err := http.Post(c.url, "application/json", bytes.NewReader(buf))
+ resp, err := c.httpclient.Post(c.url, "application/json", bytes.NewReader(buf))
if err != nil {
return err
}