summaryrefslogtreecommitdiffstats
path: root/matterhook
diff options
context:
space:
mode:
authorWim <wim@42.be>2015-12-12 21:26:53 +0100
committerWim <wim@42.be>2015-12-12 23:20:13 +0100
commitbdac03f725858fad0f55cd56fc5d72ac07073d79 (patch)
treea3935f4a26fa4b470f25c9bbdba0cf78932c9c10 /matterhook
parentc1f80383f7cb08c108afc8e093023d09864cc5a2 (diff)
downloadmatterbridge-msglm-bdac03f725858fad0f55cd56fc5d72ac07073d79.tar.gz
matterbridge-msglm-bdac03f725858fad0f55cd56fc5d72ac07073d79.tar.bz2
matterbridge-msglm-bdac03f725858fad0f55cd56fc5d72ac07073d79.zip
Add BindAddress option. Closes #4
Diffstat (limited to 'matterhook')
-rw-r--r--matterhook/matterhook.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/matterhook/matterhook.go b/matterhook/matterhook.go
index f750212f..0b023d39 100644
--- a/matterhook/matterhook.go
+++ b/matterhook/matterhook.go
@@ -52,6 +52,7 @@ 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
DisableServer bool // Do not start server for outgoing webhooks from Mattermost.
@@ -63,6 +64,7 @@ func New(url string, config Config) *Client {
if c.Port == 0 {
c.Port = 9999
}
+ c.BindAddress += ":"
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify},
}
@@ -77,8 +79,8 @@ func New(url string, config Config) *Client {
func (c *Client) StartServer() {
mux := http.NewServeMux()
mux.Handle("/", c)
- log.Printf("Listening on http://0.0.0.0:%v...\n", c.Port)
- if err := http.ListenAndServe((":" + strconv.Itoa(c.Port)), mux); err != nil {
+ 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.Fatal(err)
}
}