Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit bdac03f725858fad0f55cd56fc5d72ac07073d79 Author: Wim <wim@42.be> Date: Sat Dec 12 21:26:53 2015 +0000 Add BindAddress option. Closes #4 diff --git a/README.md b/README.md index 1ac2ad0..e7246f8 100644 --- a/README.md +++ b/README.md @@ -546 +548 @@ channel="#matterbridge"  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  #the token you get from the outgoing webhook in mattermost. If empty no token check will be done.  token=yourtokenfrommattermost diff --git a/config.go b/config.go index ecdf65f..38e41a7 100644 --- a/config.go +++ b/config.go @@ -226 +227 @@ type Config struct {   Token string   IconURL string   SkipTLSVerify bool + BindAddress string   }   General struct {   GiphyAPIKey string diff --git a/matterbridge.conf.sample b/matterbridge.conf.sample index f910e01..d581ebe 100644 --- a/matterbridge.conf.sample +++ b/matterbridge.conf.sample @@ -136 +137 @@ showjoinpart=true  #token=yourtokenfrommattermost  IconURL="http://youricon.png"  #SkipTLSVerify=true +#BindAddress="0.0.0.0"    [general]  GiphyAPIKey=dc6zaTOxFJmzC diff --git a/matterbridge.go b/matterbridge.go index 1ab3eac..bd32460 100644 --- a/matterbridge.go +++ b/matterbridge.go @@ -227 +228 @@ func NewBridge(name string, config *Config) *Bridge {   b.Config = config   b.m = matterhook.New(b.Config.Mattermost.URL,   matterhook.Config{Port: b.Config.Mattermost.Port, Token: b.Config.Mattermost.Token, - InsecureSkipVerify: b.Config.Mattermost.SkipTLSVerify}) + InsecureSkipVerify: b.Config.Mattermost.SkipTLSVerify, + BindAddress: b.Config.Mattermost.BindAddress})   b.i = b.createIRC(name)   go b.handleMatter()   return b diff --git a/matterhook/matterhook.go b/matterhook/matterhook.go index f750212..0b023d3 100644 --- a/matterhook/matterhook.go +++ b/matterhook/matterhook.go @@ -526 +527 @@ 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. @@ -636 +647 @@ 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},   } @@ -778 +798 @@ 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)   }  }