mirror of
https://github.com/42wim/matterbridge.git
synced 2024-12-04 16:32:02 -08: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.
|
3) Now you can run matterbridge.
|
||||||
|
|
||||||
```
|
```
|
||||||
Usage of matterbridge:
|
Usage of ./matterbridge:
|
||||||
-conf="matterbridge.conf": config file
|
-conf string
|
||||||
|
config file (default "matterbridge.conf")
|
||||||
|
-debug
|
||||||
|
enable debug
|
||||||
|
-plus
|
||||||
|
running using API instead of webhooks
|
||||||
|
-version
|
||||||
|
show version
|
||||||
```
|
```
|
||||||
|
|
||||||
Matterbridge will:
|
Matterbridge will:
|
||||||
@ -66,11 +73,11 @@ IgnoreNicks="ircspammer1 ircspammer2"
|
|||||||
[mattermost]
|
[mattermost]
|
||||||
#url is your incoming webhook url (account settings - integrations - incoming webhooks)
|
#url is your incoming webhook url (account settings - integrations - incoming webhooks)
|
||||||
url="http://mattermost.yourdomain.com/hooks/incomingwebhookkey"
|
url="http://mattermost.yourdomain.com/hooks/incomingwebhookkey"
|
||||||
#port the bridge webserver will listen on
|
#address the webserver (which receives the outgoing webhook from mattermost) will listen on
|
||||||
port=9999
|
#(account settings - integrations - outgoing webhooks)
|
||||||
#address the webserver will bind to
|
BindAddress="0.0.0.0:9999"
|
||||||
BindAddress="0.0.0.0"
|
#show irc users joining and parting
|
||||||
showjoinpart=true #show irc users joining and parting
|
showjoinpart=true
|
||||||
#the token you get from the outgoing webhook in mattermost.
|
#the token you get from the outgoing webhook in mattermost.
|
||||||
Token="outgoingwebhooktoken1"
|
Token="outgoingwebhooktoken1"
|
||||||
#disable certificate checking (selfsigned certificates)
|
#disable certificate checking (selfsigned certificates)
|
||||||
|
@ -79,7 +79,7 @@ func NewBridge(name string, config *Config, kind string) *Bridge {
|
|||||||
}
|
}
|
||||||
if kind == Legacy {
|
if kind == Legacy {
|
||||||
b.mh = matterhook.New(b.Config.Mattermost.URL,
|
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,
|
InsecureSkipVerify: b.Config.Mattermost.SkipTLSVerify,
|
||||||
BindAddress: b.Config.Mattermost.BindAddress})
|
BindAddress: b.Config.Mattermost.BindAddress})
|
||||||
} else {
|
} else {
|
||||||
@ -182,7 +182,7 @@ func (b *Bridge) ircNickFormat(nick string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) handlePrivMsg(event *irc.Event) {
|
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") {
|
if b.ignoreMessage(event.Nick, event.Message(), "irc") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// OMessage for mattermost incoming webhook. (send to mattermost)
|
// OMessage for mattermost incoming webhook. (send to mattermost)
|
||||||
@ -51,7 +51,6 @@ type Client struct {
|
|||||||
|
|
||||||
// Config for client.
|
// Config for client.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Port int // Port to listen on.
|
|
||||||
BindAddress string // Address to listen on
|
BindAddress string // Address to listen on
|
||||||
Token string // Only allow this token from Mattermost. (Allow everything when empty)
|
Token string // Only allow this token from Mattermost. (Allow everything when empty)
|
||||||
InsecureSkipVerify bool // disable certificate checking
|
InsecureSkipVerify bool // disable certificate checking
|
||||||
@ -61,10 +60,10 @@ type Config struct {
|
|||||||
// New Mattermost client.
|
// New Mattermost client.
|
||||||
func New(url string, config Config) *Client {
|
func New(url string, config Config) *Client {
|
||||||
c := &Client{Url: url, In: make(chan IMessage), Out: make(chan OMessage), Config: config}
|
c := &Client{Url: url, In: make(chan IMessage), Out: make(chan OMessage), Config: config}
|
||||||
if c.Port == 0 {
|
_, _, err := net.SplitHostPort(c.BindAddress)
|
||||||
c.Port = 9999
|
if err != nil {
|
||||||
|
log.Fatalf("incorrect bindaddress %s", c.BindAddress)
|
||||||
}
|
}
|
||||||
c.BindAddress += ":"
|
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify},
|
||||||
}
|
}
|
||||||
@ -79,8 +78,8 @@ func New(url string, config Config) *Client {
|
|||||||
func (c *Client) StartServer() {
|
func (c *Client) StartServer() {
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
mux.Handle("/", c)
|
mux.Handle("/", c)
|
||||||
log.Printf("Listening on http://%v:%v...\n", c.BindAddress, c.Port)
|
log.Printf("Listening on http://%v...\n", c.BindAddress)
|
||||||
if err := http.ListenAndServe((c.BindAddress + strconv.Itoa(c.Port)), mux); err != nil {
|
if err := http.ListenAndServe(c.BindAddress, mux); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user