mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-22 08:10:26 +00:00
Add BindAddress option. Closes #4
This commit is contained in:
parent
c1f80383f7
commit
bdac03f725
@ -54,6 +54,8 @@ channel="#matterbridge"
|
|||||||
url="http://mattermost.yourdomain.com/hooks/incomingwebhookkey"
|
url="http://mattermost.yourdomain.com/hooks/incomingwebhookkey"
|
||||||
#port the bridge webserver will listen on
|
#port the bridge webserver will listen on
|
||||||
port=9999
|
port=9999
|
||||||
|
#address the webserver will bind to
|
||||||
|
BindAddress="0.0.0.0"
|
||||||
showjoinpart=true #show irc users joining and parting
|
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.
|
#the token you get from the outgoing webhook in mattermost. If empty no token check will be done.
|
||||||
token=yourtokenfrommattermost
|
token=yourtokenfrommattermost
|
||||||
|
@ -22,6 +22,7 @@ type Config struct {
|
|||||||
Token string
|
Token string
|
||||||
IconURL string
|
IconURL string
|
||||||
SkipTLSVerify bool
|
SkipTLSVerify bool
|
||||||
|
BindAddress string
|
||||||
}
|
}
|
||||||
General struct {
|
General struct {
|
||||||
GiphyAPIKey string
|
GiphyAPIKey string
|
||||||
|
@ -13,6 +13,7 @@ showjoinpart=true
|
|||||||
#token=yourtokenfrommattermost
|
#token=yourtokenfrommattermost
|
||||||
IconURL="http://youricon.png"
|
IconURL="http://youricon.png"
|
||||||
#SkipTLSVerify=true
|
#SkipTLSVerify=true
|
||||||
|
#BindAddress="0.0.0.0"
|
||||||
|
|
||||||
[general]
|
[general]
|
||||||
GiphyAPIKey=dc6zaTOxFJmzC
|
GiphyAPIKey=dc6zaTOxFJmzC
|
||||||
|
@ -22,7 +22,8 @@ func NewBridge(name string, config *Config) *Bridge {
|
|||||||
b.Config = config
|
b.Config = config
|
||||||
b.m = matterhook.New(b.Config.Mattermost.URL,
|
b.m = matterhook.New(b.Config.Mattermost.URL,
|
||||||
matterhook.Config{Port: b.Config.Mattermost.Port, Token: b.Config.Mattermost.Token,
|
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)
|
b.i = b.createIRC(name)
|
||||||
go b.handleMatter()
|
go b.handleMatter()
|
||||||
return b
|
return b
|
||||||
|
@ -52,6 +52,7 @@ type Client struct {
|
|||||||
// Config for client.
|
// Config for client.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Port int // Port to listen on.
|
Port int // Port 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
|
||||||
DisableServer bool // Do not start server for outgoing webhooks from Mattermost.
|
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 {
|
if c.Port == 0 {
|
||||||
c.Port = 9999
|
c.Port = 9999
|
||||||
}
|
}
|
||||||
|
c.BindAddress += ":"
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify},
|
||||||
}
|
}
|
||||||
@ -77,8 +79,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://0.0.0.0:%v...\n", c.Port)
|
log.Printf("Listening on http://%v:%v...\n", c.BindAddress, c.Port)
|
||||||
if err := http.ListenAndServe((":" + strconv.Itoa(c.Port)), mux); err != nil {
|
if err := http.ListenAndServe((c.BindAddress + strconv.Itoa(c.Port)), mux); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user