summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim <wim@42.be>2016-07-11 23:22:56 +0200
committerWim <wim@42.be>2016-07-11 23:22:56 +0200
commitced371bece6bcdadba3f61bb70f5f5aa24bc3c23 (patch)
tree87f6df50e5a6d4428d3fbbfb2f197575c6b86eda
parenta87cac1982c0869fca161b0c417da3cd13742ce9 (diff)
downloadmatterbridge-msglm-ced371bece6bcdadba3f61bb70f5f5aa24bc3c23.tar.gz
matterbridge-msglm-ced371bece6bcdadba3f61bb70f5f5aa24bc3c23.tar.bz2
matterbridge-msglm-ced371bece6bcdadba3f61bb70f5f5aa24bc3c23.zip
Add port to BindAddress
-rw-r--r--README.md21
-rw-r--r--bridge/bridge.go4
-rw-r--r--matterhook/matterhook.go13
3 files changed, 22 insertions, 16 deletions
diff --git a/README.md b/README.md
index 0fff2553..695be1fb 100644
--- a/README.md
+++ b/README.md
@@ -31,8 +31,15 @@ matterbridge
3) Now you can run matterbridge.
```
-Usage of matterbridge:
- -conf="matterbridge.conf": config file
+Usage of ./matterbridge:
+ -conf string
+ config file (default "matterbridge.conf")
+ -debug
+ enable debug
+ -plus
+ running using API instead of webhooks
+ -version
+ show version
```
Matterbridge will:
@@ -66,11 +73,11 @@ IgnoreNicks="ircspammer1 ircspammer2"
[mattermost]
#url is your incoming webhook url (account settings - integrations - incoming webhooks)
url="http://mattermost.yourdomain.com/hooks/incomingwebhookkey"
-#port the bridge webserver will listen on
-port=9999
-#address the webserver will bind to
-BindAddress="0.0.0.0"
-showjoinpart=true #show irc users joining and parting
+#address the webserver (which receives the outgoing webhook from mattermost) will listen on
+#(account settings - integrations - outgoing webhooks)
+BindAddress="0.0.0.0:9999"
+#show irc users joining and parting
+showjoinpart=true
#the token you get from the outgoing webhook in mattermost.
Token="outgoingwebhooktoken1"
#disable certificate checking (selfsigned certificates)
diff --git a/bridge/bridge.go b/bridge/bridge.go
index 7f318c3c..8e2b1393 100644
--- a/bridge/bridge.go
+++ b/bridge/bridge.go
@@ -79,7 +79,7 @@ func NewBridge(name string, config *Config, kind string) *Bridge {
}
if kind == Legacy {
b.mh = matterhook.New(b.Config.Mattermost.URL,
- matterhook.Config{Port: b.Config.Mattermost.Port, Token: b.Config.Mattermost.Token,
+ matterhook.Config{Token: b.Config.Mattermost.Token,
InsecureSkipVerify: b.Config.Mattermost.SkipTLSVerify,
BindAddress: b.Config.Mattermost.BindAddress})
} else {
@@ -182,7 +182,7 @@ func (b *Bridge) ircNickFormat(nick string) string {
}
func (b *Bridge) handlePrivMsg(event *irc.Event) {
- flog.irc.Debugf("handlePrivMsg() %s %s", event.Nick, event.Message)
+ flog.irc.Debugf("handlePrivMsg() %s %s", event.Nick, event.Message())
if b.ignoreMessage(event.Nick, event.Message(), "irc") {
return
}
diff --git a/matterhook/matterhook.go b/matterhook/matterhook.go
index f30d44b7..ef983e7b 100644
--- a/matterhook/matterhook.go
+++ b/matterhook/matterhook.go
@@ -10,8 +10,8 @@ import (
"io"
"io/ioutil"
"log"
+ "net"
"net/http"
- "strconv"
)
// OMessage for mattermost incoming webhook. (send to mattermost)
@@ -51,7 +51,6 @@ type Client struct {
// Config for client.
type Config struct {
- Port int // Port to listen on.
BindAddress string // Address to listen on
Token string // Only allow this token from Mattermost. (Allow everything when empty)
InsecureSkipVerify bool // disable certificate checking
@@ -61,10 +60,10 @@ type Config struct {
// New Mattermost client.
func New(url string, config Config) *Client {
c := &Client{Url: url, In: make(chan IMessage), Out: make(chan OMessage), Config: config}
- if c.Port == 0 {
- c.Port = 9999
+ _, _, err := net.SplitHostPort(c.BindAddress)
+ if err != nil {
+ log.Fatalf("incorrect bindaddress %s", c.BindAddress)
}
- c.BindAddress += ":"
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify},
}
@@ -79,8 +78,8 @@ func New(url string, config Config) *Client {
func (c *Client) StartServer() {
mux := http.NewServeMux()
mux.Handle("/", c)
- log.Printf("Listening on http://%v:%v...\n", c.BindAddress, c.Port)
- if err := http.ListenAndServe((c.BindAddress + strconv.Itoa(c.Port)), mux); err != nil {
+ log.Printf("Listening on http://%v...\n", c.BindAddress)
+ if err := http.ListenAndServe(c.BindAddress, mux); err != nil {
log.Fatal(err)
}
}