mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-14 07:59:26 +01:00
Add port to BindAddress
This commit is contained in:
parent
a87cac1982
commit
ced371bece
21
README.md
21
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)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user