summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--config.go11
-rw-r--r--matterbridge.conf.sample1
-rw-r--r--matterbridge.go9
-rw-r--r--matterhook/matterhook.go20
5 files changed, 30 insertions, 14 deletions
diff --git a/README.md b/README.md
index 655d4619..5946908f 100644
--- a/README.md
+++ b/README.md
@@ -59,7 +59,8 @@ port=9999
showjoinpart=true #show irc users joining and parting
#the token you get from the outgoing webhook in mattermost. If empty no token check will be done.
token=yourtokenfrommattermost
-
+#disable certificate checking (selfsigned certificates)
+#SkipTLSVerify=true
```
### mattermost
diff --git a/config.go b/config.go
index efd6eaf8..e40b0e9a 100644
--- a/config.go
+++ b/config.go
@@ -16,11 +16,12 @@ type Config struct {
Channel string
}
Mattermost struct {
- URL string
- Port int
- ShowJoinPart bool
- Token string
- IconURL string
+ URL string
+ Port int
+ ShowJoinPart bool
+ Token string
+ IconURL string
+ SkipTLSVerify bool
}
}
diff --git a/matterbridge.conf.sample b/matterbridge.conf.sample
index 231a3c63..bac921ce 100644
--- a/matterbridge.conf.sample
+++ b/matterbridge.conf.sample
@@ -12,3 +12,4 @@ port=9999
showjoinpart=true
#token=yourtokenfrommattermost
IconURL="http://youricon.png"
+#SkipTLSVerify=true
diff --git a/matterbridge.go b/matterbridge.go
index 94d38954..4a36e80b 100644
--- a/matterbridge.go
+++ b/matterbridge.go
@@ -20,7 +20,8 @@ func NewBridge(name string, config *Config) *Bridge {
b := &Bridge{}
b.Config = config
b.m = matterhook.New(b.Config.Mattermost.URL,
- matterhook.Config{Port: b.Config.Mattermost.Port, Token: b.Config.Mattermost.Token})
+ matterhook.Config{Port: b.Config.Mattermost.Port, Token: b.Config.Mattermost.Token,
+ InsecureSkipVerify: b.Config.Mattermost.SkipTLSVerify})
b.i = b.createIRC(name)
go b.handleMatter()
return b
@@ -68,7 +69,11 @@ func (b *Bridge) Send(nick string, message string) error {
matterMessage := matterhook.OMessage{IconURL: b.Config.Mattermost.IconURL}
matterMessage.UserName = nick
matterMessage.Text = message
- b.m.Send(matterMessage)
+ err := b.m.Send(matterMessage)
+ if err != nil {
+ log.Println(err)
+ return err
+ }
return nil
}
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
}