Thumbnail

rani/matterbridge.git

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

commit 1c8ccaa79644e5cb07d5c75b8c95efb2979e94fb Author: Wim <wim@42.be> Date: Mon Jul 11 23:22:56 2016 +0000 Add port to BindAddress diff --git a/README.md b/README.md index 0fff255..695be1f 100644 --- a/README.md +++ b/README.md @@ -318 +3115 @@ 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: @@ -6611 +7311 @@ 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 7f318c3..8e2b139 100644 --- a/bridge/bridge.go +++ b/bridge/bridge.go @@ -797 +797 @@ 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 { @@ -1827 +1827 @@ 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 f30d44b..ef983e7 100644 --- a/matterhook/matterhook.go +++ b/matterhook/matterhook.go @@ -108 +108 @@ import (   "io"   "io/ioutil"   "log" + "net"   "net/http" - "strconv"  )    // OMessage for mattermost incoming webhook. (send to mattermost) @@ -517 +516 @@ 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 @@ -6110 +6010 @@ 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},   } @@ -798 +788 @@ 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)   }  }