mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-06-27 08:49:24 +00:00
Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
30f30364d5 | |||
073d90da88 | |||
c769e23a9a | |||
9db48f4794 | |||
911c597377 | |||
28244ffd9a | |||
3e38c7945c | |||
79ffb76f6e | |||
5fe4b749cf | |||
6991d85da9 | |||
c1c187a1ab | |||
055d12e3ef | |||
b49429d722 | |||
815c7f8d64 | |||
c879f79456 | |||
3bc25f4707 | |||
300cfe044a | |||
fb586f4a96 | |||
ced371bece | |||
a87cac1982 | |||
8fb5c7afa6 | |||
aceb830378 | |||
0f2976c5ce | |||
78b17977c5 | |||
6ec77e06ea | |||
e48db67649 | |||
e03f331f55 | |||
ff5aeeb1e1 |
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
FROM alpine:edge
|
||||||
|
ENTRYPOINT ["/bin/matterbridge"]
|
||||||
|
|
||||||
|
COPY . /go/src/github.com/42wim/matterbridge
|
||||||
|
RUN apk update && apk add go git gcc musl-dev \
|
||||||
|
&& cd /go/src/github.com/42wim/matterbridge \
|
||||||
|
&& export GOPATH=/go \
|
||||||
|
&& go get \
|
||||||
|
&& go build -o /bin/matterbridge \
|
||||||
|
&& rm -rf /go \
|
||||||
|
&& apk del --purge git go
|
109
README.md
109
README.md
@ -1,14 +1,25 @@
|
|||||||
# matterbridge
|
# matterbridge
|
||||||
|
|
||||||
Simple bridge between mattermost and IRC. Uses the in/outgoing webhooks.
|
Simple bridge between mattermost and IRC.
|
||||||
Relays public channel messages between mattermost and IRC.
|
|
||||||
|
|
||||||
Requires mattermost 1.2.0+
|
* Relays public channel messages between mattermost and IRC.
|
||||||
|
* Supports multiple mattermost and irc channels.
|
||||||
|
* Matterbridge -plus also works with private groups on your mattermost.
|
||||||
|
|
||||||
There is also [matterbridge-plus] (https://github.com/42wim/matterbridge-plus) which uses the mattermost API and needs a dedicated user (bot). But requires no incoming/outgoing webhook setup.
|
This project has now [matterbridge-plus](https://github.com/42wim/matterbridge-plus/) merged in.
|
||||||
|
Breaking changes for matterbridge can be found in [migration](https://github.com/42wim/matterbridge/blob/master/migration.md)
|
||||||
|
|
||||||
|
## Requirements:
|
||||||
|
* [Mattermost] (https://github.com/mattermost/platform/) 3.x (stable, not a dev build)
|
||||||
|
|
||||||
|
### Webhooks version
|
||||||
|
* Configured incoming/outgoing [webhooks](https://www.mattermost.org/webhooks/) on your mattermost instance.
|
||||||
|
|
||||||
|
### Plus (API) version
|
||||||
|
* A dedicated user(bot) on your mattermost instance.
|
||||||
|
|
||||||
## binaries
|
## binaries
|
||||||
Binaries can be found [here] (https://github.com/42wim/matterbridge/releases/tag/v0.4)
|
Binaries can be found [here] (https://github.com/42wim/matterbridge/releases/tag/v0.5.0)
|
||||||
|
|
||||||
## building
|
## building
|
||||||
Go 1.6+ is required. Make sure you have [Go](https://golang.org/doc/install) properly installed, including setting up your [GOPATH] (https://golang.org/doc/code.html#GOPATH)
|
Go 1.6+ is required. Make sure you have [Go](https://golang.org/doc/install) properly installed, including setting up your [GOPATH] (https://golang.org/doc/code.html#GOPATH)
|
||||||
@ -31,73 +42,26 @@ 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:
|
|
||||||
* start a webserver listening on the port specified in the configuration.
|
|
||||||
* connect to specified irc server and channel.
|
|
||||||
* send messages from mattermost to irc and vice versa, messages in mattermost will appear with irc-nick
|
|
||||||
|
|
||||||
## config
|
## config
|
||||||
### matterbridge
|
### matterbridge
|
||||||
matterbridge looks for matterbridge.conf in current directory. (use -conf to specify another file)
|
matterbridge looks for matterbridge.conf in current directory. (use -conf to specify another file)
|
||||||
|
|
||||||
Look at matterbridge.conf.sample for an example
|
Look at [matterbridge.conf.sample] (https://github.com/42wim/matterbridge/blob/master/matterbridge.conf.sample) for an example.
|
||||||
|
|
||||||
|
|
||||||
```
|
|
||||||
[IRC]
|
|
||||||
server="irc.freenode.net"
|
|
||||||
port=6667
|
|
||||||
UseTLS=false
|
|
||||||
SkipTLSVerify=true
|
|
||||||
nick="matterbot"
|
|
||||||
channel="#matterbridge"
|
|
||||||
UseSlackCircumfix=false
|
|
||||||
|
|
||||||
[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
|
|
||||||
#the token you get from the outgoing webhook in mattermost. If empty no token check will be done.
|
|
||||||
#if you use multiple IRC channel (see below, this must be empty!)
|
|
||||||
token=yourtokenfrommattermost
|
|
||||||
#disable certificate checking (selfsigned certificates)
|
|
||||||
#SkipTLSVerify=true
|
|
||||||
#whether to prefix messages from IRC to mattermost with the sender's nick. Useful if username overrides for incoming webhooks isn't enabled on the mattermost server
|
|
||||||
PrefixMessagesWithNick=false
|
|
||||||
#how to format the list of IRC nicks when displayed in mattermost. Possible options are "table" and "plain"
|
|
||||||
NickFormatter=plain
|
|
||||||
#how many nicks to list per row for formatters that support this
|
|
||||||
NicksPerRow=4
|
|
||||||
#Freenode nickserv
|
|
||||||
NickServNick="nickserv"
|
|
||||||
#Password for nickserv
|
|
||||||
NickServPassword="secret"
|
|
||||||
|
|
||||||
#multiple channel config
|
|
||||||
#token you can find in your outgoing webhook
|
|
||||||
[Token "outgoingwebhooktoken1"]
|
|
||||||
IRCChannel="#off-topic"
|
|
||||||
MMChannel="off-topic"
|
|
||||||
|
|
||||||
[Token "outgoingwebhooktoken2"]
|
|
||||||
IRCChannel="#testing"
|
|
||||||
MMChannel="testing"
|
|
||||||
|
|
||||||
[general]
|
|
||||||
#request your API key on https://github.com/giphy/GiphyAPI. This is a public beta key
|
|
||||||
GiphyApiKey="dc6zaTOxFJmzC"
|
|
||||||
```
|
|
||||||
|
|
||||||
### mattermost
|
### mattermost
|
||||||
You'll have to configure the incoming en outgoing webhooks.
|
#### webhooks version
|
||||||
|
You'll have to configure the incoming and outgoing webhooks.
|
||||||
|
|
||||||
* incoming webhooks
|
* incoming webhooks
|
||||||
Go to "account settings" - integrations - "incoming webhooks".
|
Go to "account settings" - integrations - "incoming webhooks".
|
||||||
@ -108,5 +72,20 @@ This URL should be set in the matterbridge.conf in the [mattermost] section (see
|
|||||||
Go to "account settings" - integrations - "outgoing webhooks".
|
Go to "account settings" - integrations - "outgoing webhooks".
|
||||||
Choose a channel (the same as the one from incoming webhooks) and fill in the address and port of the server matterbridge will run on.
|
Choose a channel (the same as the one from incoming webhooks) and fill in the address and port of the server matterbridge will run on.
|
||||||
|
|
||||||
e.g. http://192.168.1.1:9999 (9999 is the port specified in [mattermost] section of matterbridge.conf)
|
e.g. http://192.168.1.1:9999 (192.168.1.1:9999 is the BindAddress specified in [mattermost] section of matterbridge.conf)
|
||||||
|
|
||||||
|
#### plus version
|
||||||
|
You'll have to create a new dedicated user on your mattermost instance.
|
||||||
|
Specify the login and password in [mattermost] section of matterbridge.conf
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
Please look at [matterbridge.conf.sample] (https://github.com/42wim/matterbridge/blob/master/matterbridge.conf.sample) for more information first.
|
||||||
|
### Mattermost doesn't show the IRC nicks
|
||||||
|
If you're running the webhooks version, this can be fixed by either:
|
||||||
|
* enabling "override usernames". See [mattermost documentation](http://docs.mattermost.com/developer/webhooks-incoming.html#enabling-incoming-webhooks)
|
||||||
|
* setting ```PrefixMessagesWithNick``` to ```true``` in ```mattermost``` section of your matterbridge.conf.
|
||||||
|
|
||||||
|
If you're running the plus version you'll need to:
|
||||||
|
* setting ```PrefixMessagesWithNick``` to ```true``` in ```mattermost``` section of your matterbridge.conf.
|
||||||
|
|
||||||
|
Also look at the ```RemoteNickFormat``` setting.
|
||||||
|
407
bridge/bridge.go
Normal file
407
bridge/bridge.go
Normal file
@ -0,0 +1,407 @@
|
|||||||
|
package bridge
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"github.com/42wim/matterbridge/matterclient"
|
||||||
|
"github.com/42wim/matterbridge/matterhook"
|
||||||
|
log "github.com/Sirupsen/logrus"
|
||||||
|
"github.com/peterhellberg/giphy"
|
||||||
|
ircm "github.com/sorcix/irc"
|
||||||
|
"github.com/thoj/go-ircevent"
|
||||||
|
"regexp"
|
||||||
|
"sort"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
//type Bridge struct {
|
||||||
|
type MMhook struct {
|
||||||
|
mh *matterhook.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
type MMapi struct {
|
||||||
|
mc *matterclient.MMClient
|
||||||
|
mmMap map[string]string
|
||||||
|
mmIgnoreNicks []string
|
||||||
|
}
|
||||||
|
|
||||||
|
type MMirc struct {
|
||||||
|
i *irc.Connection
|
||||||
|
ircNick string
|
||||||
|
ircMap map[string]string
|
||||||
|
names map[string][]string
|
||||||
|
ircIgnoreNicks []string
|
||||||
|
}
|
||||||
|
|
||||||
|
type MMMessage struct {
|
||||||
|
Text string
|
||||||
|
Channel string
|
||||||
|
Username string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Bridge struct {
|
||||||
|
MMhook
|
||||||
|
MMapi
|
||||||
|
MMirc
|
||||||
|
*Config
|
||||||
|
kind string
|
||||||
|
}
|
||||||
|
|
||||||
|
type FancyLog struct {
|
||||||
|
irc *log.Entry
|
||||||
|
mm *log.Entry
|
||||||
|
}
|
||||||
|
|
||||||
|
var flog FancyLog
|
||||||
|
|
||||||
|
const Legacy = "legacy"
|
||||||
|
|
||||||
|
func initFLog() {
|
||||||
|
flog.irc = log.WithFields(log.Fields{"module": "irc"})
|
||||||
|
flog.mm = log.WithFields(log.Fields{"module": "mattermost"})
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewBridge(name string, config *Config, kind string) *Bridge {
|
||||||
|
initFLog()
|
||||||
|
b := &Bridge{}
|
||||||
|
b.Config = config
|
||||||
|
b.kind = kind
|
||||||
|
b.ircNick = b.Config.IRC.Nick
|
||||||
|
b.ircMap = make(map[string]string)
|
||||||
|
b.mmMap = make(map[string]string)
|
||||||
|
b.MMirc.names = make(map[string][]string)
|
||||||
|
b.ircIgnoreNicks = strings.Fields(b.Config.IRC.IgnoreNicks)
|
||||||
|
b.mmIgnoreNicks = strings.Fields(b.Config.Mattermost.IgnoreNicks)
|
||||||
|
for _, val := range b.Config.Channel {
|
||||||
|
b.ircMap[val.IRC] = val.Mattermost
|
||||||
|
b.mmMap[val.Mattermost] = val.IRC
|
||||||
|
}
|
||||||
|
if kind == Legacy {
|
||||||
|
b.mh = matterhook.New(b.Config.Mattermost.URL,
|
||||||
|
matterhook.Config{InsecureSkipVerify: b.Config.Mattermost.SkipTLSVerify,
|
||||||
|
BindAddress: b.Config.Mattermost.BindAddress})
|
||||||
|
} else {
|
||||||
|
b.mc = matterclient.New(b.Config.Mattermost.Login, b.Config.Mattermost.Password,
|
||||||
|
b.Config.Mattermost.Team, b.Config.Mattermost.Server)
|
||||||
|
b.mc.SkipTLSVerify = b.Config.Mattermost.SkipTLSVerify
|
||||||
|
b.mc.NoTLS = b.Config.Mattermost.NoTLS
|
||||||
|
flog.mm.Infof("Trying login %s (team: %s) on %s", b.Config.Mattermost.Login, b.Config.Mattermost.Team, b.Config.Mattermost.Server)
|
||||||
|
err := b.mc.Login()
|
||||||
|
if err != nil {
|
||||||
|
flog.mm.Fatal("Can not connect", err)
|
||||||
|
}
|
||||||
|
flog.mm.Info("Login ok")
|
||||||
|
b.mc.JoinChannel(b.Config.Mattermost.Channel)
|
||||||
|
for _, val := range b.Config.Channel {
|
||||||
|
b.mc.JoinChannel(val.Mattermost)
|
||||||
|
}
|
||||||
|
go b.mc.WsReceiver()
|
||||||
|
}
|
||||||
|
flog.irc.Info("Trying IRC connection")
|
||||||
|
b.i = b.createIRC(name)
|
||||||
|
flog.irc.Info("Connection succeeded")
|
||||||
|
go b.handleMatter()
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) createIRC(name string) *irc.Connection {
|
||||||
|
i := irc.IRC(b.Config.IRC.Nick, b.Config.IRC.Nick)
|
||||||
|
i.UseTLS = b.Config.IRC.UseTLS
|
||||||
|
i.UseSASL = b.Config.IRC.UseSASL
|
||||||
|
i.SASLLogin = b.Config.IRC.NickServNick
|
||||||
|
i.SASLPassword = b.Config.IRC.NickServPassword
|
||||||
|
i.TLSConfig = &tls.Config{InsecureSkipVerify: b.Config.IRC.SkipTLSVerify}
|
||||||
|
if b.Config.IRC.Password != "" {
|
||||||
|
i.Password = b.Config.IRC.Password
|
||||||
|
}
|
||||||
|
i.AddCallback(ircm.RPL_WELCOME, b.handleNewConnection)
|
||||||
|
err := i.Connect(b.Config.IRC.Server)
|
||||||
|
if err != nil {
|
||||||
|
flog.irc.Fatal(err)
|
||||||
|
}
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) handleNewConnection(event *irc.Event) {
|
||||||
|
flog.irc.Info("Registering callbacks")
|
||||||
|
i := b.i
|
||||||
|
b.ircNick = event.Arguments[0]
|
||||||
|
i.AddCallback("PRIVMSG", b.handlePrivMsg)
|
||||||
|
i.AddCallback("CTCP_ACTION", b.handlePrivMsg)
|
||||||
|
i.AddCallback(ircm.RPL_ENDOFNAMES, b.endNames)
|
||||||
|
i.AddCallback(ircm.RPL_NAMREPLY, b.storeNames)
|
||||||
|
i.AddCallback(ircm.RPL_TOPICWHOTIME, b.handleTopicWhoTime)
|
||||||
|
i.AddCallback(ircm.NOTICE, b.handleNotice)
|
||||||
|
i.AddCallback(ircm.RPL_MYINFO, func(e *irc.Event) { flog.irc.Infof("%s: %s", e.Code, strings.Join(e.Arguments[1:], " ")) })
|
||||||
|
i.AddCallback("PING", func(e *irc.Event) {
|
||||||
|
i.SendRaw("PONG :" + e.Message())
|
||||||
|
flog.irc.Debugf("PING/PONG")
|
||||||
|
})
|
||||||
|
if b.Config.Mattermost.ShowJoinPart {
|
||||||
|
i.AddCallback("JOIN", b.handleJoinPart)
|
||||||
|
i.AddCallback("PART", b.handleJoinPart)
|
||||||
|
}
|
||||||
|
i.AddCallback("*", b.handleOther)
|
||||||
|
b.setupChannels()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) setupChannels() {
|
||||||
|
i := b.i
|
||||||
|
for _, val := range b.Config.Channel {
|
||||||
|
flog.irc.Infof("Joining %s as %s", val.IRC, b.ircNick)
|
||||||
|
i.Join(val.IRC)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) handleIrcBotCommand(event *irc.Event) bool {
|
||||||
|
parts := strings.Fields(event.Message())
|
||||||
|
exp, _ := regexp.Compile("[:,]+$")
|
||||||
|
channel := event.Arguments[0]
|
||||||
|
command := ""
|
||||||
|
if len(parts) == 2 {
|
||||||
|
command = parts[1]
|
||||||
|
}
|
||||||
|
if exp.ReplaceAllString(parts[0], "") == b.ircNick {
|
||||||
|
switch command {
|
||||||
|
case "users":
|
||||||
|
usernames := b.mc.UsernamesInChannel(b.getMMChannel(channel))
|
||||||
|
sort.Strings(usernames)
|
||||||
|
b.i.Privmsg(channel, "Users on Mattermost: "+strings.Join(usernames, ", "))
|
||||||
|
default:
|
||||||
|
b.i.Privmsg(channel, "Valid commands are: [users, help]")
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) ircNickFormat(nick string) string {
|
||||||
|
if nick == b.ircNick {
|
||||||
|
return nick
|
||||||
|
}
|
||||||
|
if b.Config.Mattermost.RemoteNickFormat == nil {
|
||||||
|
return "irc-" + nick
|
||||||
|
}
|
||||||
|
return strings.Replace(*b.Config.Mattermost.RemoteNickFormat, "{NICK}", nick, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) handlePrivMsg(event *irc.Event) {
|
||||||
|
flog.irc.Debugf("handlePrivMsg() %s %s", event.Nick, event.Message())
|
||||||
|
if b.ignoreMessage(event.Nick, event.Message(), "irc") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if b.handleIrcBotCommand(event) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
msg := ""
|
||||||
|
if event.Code == "CTCP_ACTION" {
|
||||||
|
msg = event.Nick + " "
|
||||||
|
}
|
||||||
|
msg += event.Message()
|
||||||
|
b.Send(b.ircNickFormat(event.Nick), msg, b.getMMChannel(event.Arguments[0]))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) handleJoinPart(event *irc.Event) {
|
||||||
|
b.Send(b.ircNick, b.ircNickFormat(event.Nick)+" "+strings.ToLower(event.Code)+"s "+event.Message(), b.getMMChannel(event.Arguments[0]))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) handleNotice(event *irc.Event) {
|
||||||
|
if strings.Contains(event.Message(), "This nickname is registered") {
|
||||||
|
b.i.Privmsg(b.Config.IRC.NickServNick, "IDENTIFY "+b.Config.IRC.NickServPassword)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) nicksPerRow() int {
|
||||||
|
if b.Config.Mattermost.NicksPerRow < 1 {
|
||||||
|
return 4
|
||||||
|
}
|
||||||
|
return b.Config.Mattermost.NicksPerRow
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) formatnicks(nicks []string, continued bool) string {
|
||||||
|
switch b.Config.Mattermost.NickFormatter {
|
||||||
|
case "table":
|
||||||
|
return tableformatter(nicks, b.nicksPerRow(), continued)
|
||||||
|
default:
|
||||||
|
return plainformatter(nicks, b.nicksPerRow())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) storeNames(event *irc.Event) {
|
||||||
|
channel := event.Arguments[2]
|
||||||
|
b.MMirc.names[channel] = append(
|
||||||
|
b.MMirc.names[channel],
|
||||||
|
strings.Split(strings.TrimSpace(event.Message()), " ")...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) endNames(event *irc.Event) {
|
||||||
|
channel := event.Arguments[1]
|
||||||
|
sort.Strings(b.MMirc.names[channel])
|
||||||
|
maxNamesPerPost := (300 / b.nicksPerRow()) * b.nicksPerRow()
|
||||||
|
continued := false
|
||||||
|
for len(b.MMirc.names[channel]) > maxNamesPerPost {
|
||||||
|
b.Send(
|
||||||
|
b.ircNick,
|
||||||
|
b.formatnicks(b.MMirc.names[channel][0:maxNamesPerPost], continued),
|
||||||
|
b.getMMChannel(channel))
|
||||||
|
b.MMirc.names[channel] = b.MMirc.names[channel][maxNamesPerPost:]
|
||||||
|
continued = true
|
||||||
|
}
|
||||||
|
b.Send(b.ircNick, b.formatnicks(b.MMirc.names[channel], continued), b.getMMChannel(channel))
|
||||||
|
b.MMirc.names[channel] = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) handleTopicWhoTime(event *irc.Event) {
|
||||||
|
parts := strings.Split(event.Arguments[2], "!")
|
||||||
|
t, err := strconv.ParseInt(event.Arguments[3], 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
flog.irc.Errorf("Invalid time stamp: %s", event.Arguments[3])
|
||||||
|
}
|
||||||
|
user := parts[0]
|
||||||
|
if len(parts) > 1 {
|
||||||
|
user += " [" + parts[1] + "]"
|
||||||
|
}
|
||||||
|
flog.irc.Infof("%s: Topic set by %s [%s]", event.Code, user, time.Unix(t, 0))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) handleOther(event *irc.Event) {
|
||||||
|
flog.irc.Debugf("%#v", event)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) Send(nick string, message string, channel string) error {
|
||||||
|
return b.SendType(nick, message, channel, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) SendType(nick string, message string, channel string, mtype string) error {
|
||||||
|
if b.Config.Mattermost.PrefixMessagesWithNick {
|
||||||
|
if IsMarkup(message) {
|
||||||
|
message = nick + "\n\n" + message
|
||||||
|
} else {
|
||||||
|
message = nick + " " + message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if b.kind == Legacy {
|
||||||
|
matterMessage := matterhook.OMessage{IconURL: b.Config.Mattermost.IconURL}
|
||||||
|
matterMessage.Channel = channel
|
||||||
|
matterMessage.UserName = nick
|
||||||
|
matterMessage.Type = mtype
|
||||||
|
matterMessage.Text = message
|
||||||
|
err := b.mh.Send(matterMessage)
|
||||||
|
if err != nil {
|
||||||
|
flog.mm.Info(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
flog.mm.Debug("->mattermost channel: ", channel, " ", message)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
flog.mm.Debug("->mattermost channel: ", channel, " ", message)
|
||||||
|
b.mc.PostMessage(channel, message)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) handleMatterHook(mchan chan *MMMessage) {
|
||||||
|
for {
|
||||||
|
message := b.mh.Receive()
|
||||||
|
flog.mm.Debugf("receiving from matterhook %#v", message)
|
||||||
|
m := &MMMessage{}
|
||||||
|
m.Username = message.UserName
|
||||||
|
m.Text = message.Text
|
||||||
|
m.Channel = message.ChannelName
|
||||||
|
mchan <- m
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) handleMatterClient(mchan chan *MMMessage) {
|
||||||
|
for message := range b.mc.MessageChan {
|
||||||
|
// do not post our own messages back to irc
|
||||||
|
if message.Raw.Action == "posted" && b.mc.User.Username != message.Username {
|
||||||
|
flog.mm.Debugf("receiving from matterclient %#v", message)
|
||||||
|
m := &MMMessage{}
|
||||||
|
m.Username = message.Username
|
||||||
|
m.Channel = message.Channel
|
||||||
|
m.Text = message.Text
|
||||||
|
mchan <- m
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) handleMatter() {
|
||||||
|
flog.mm.Infof("Choosing Mattermost connection type %s", b.kind)
|
||||||
|
mchan := make(chan *MMMessage)
|
||||||
|
if b.kind == Legacy {
|
||||||
|
go b.handleMatterHook(mchan)
|
||||||
|
} else {
|
||||||
|
go b.handleMatterClient(mchan)
|
||||||
|
}
|
||||||
|
flog.mm.Info("Start listening for Mattermost messages")
|
||||||
|
for message := range mchan {
|
||||||
|
var username string
|
||||||
|
if b.ignoreMessage(message.Username, message.Text, "mattermost") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
username = message.Username + ": "
|
||||||
|
if b.Config.IRC.RemoteNickFormat != "" {
|
||||||
|
username = strings.Replace(b.Config.IRC.RemoteNickFormat, "{NICK}", message.Username, -1)
|
||||||
|
}
|
||||||
|
cmds := strings.Fields(message.Text)
|
||||||
|
// empty message
|
||||||
|
if len(cmds) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
cmd := cmds[0]
|
||||||
|
switch cmd {
|
||||||
|
case "!users":
|
||||||
|
flog.mm.Info("Received !users from ", message.Username)
|
||||||
|
b.i.SendRaw("NAMES " + b.getIRCChannel(message.Channel))
|
||||||
|
continue
|
||||||
|
case "!gif":
|
||||||
|
message.Text = b.giphyRandom(strings.Fields(strings.Replace(message.Text, "!gif ", "", 1)))
|
||||||
|
b.Send(b.ircNick, message.Text, b.getIRCChannel(message.Channel))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
texts := strings.Split(message.Text, "\n")
|
||||||
|
for _, text := range texts {
|
||||||
|
flog.mm.Debug("Sending message from " + message.Username + " to " + message.Channel)
|
||||||
|
b.i.Privmsg(b.getIRCChannel(message.Channel), username+text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) giphyRandom(query []string) string {
|
||||||
|
g := giphy.DefaultClient
|
||||||
|
if b.Config.General.GiphyAPIKey != "" {
|
||||||
|
g.APIKey = b.Config.General.GiphyAPIKey
|
||||||
|
}
|
||||||
|
res, err := g.Random(query)
|
||||||
|
if err != nil {
|
||||||
|
return "error"
|
||||||
|
}
|
||||||
|
return res.Data.FixedHeightDownsampledURL
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) getMMChannel(ircChannel string) string {
|
||||||
|
mmChannel := b.ircMap[ircChannel]
|
||||||
|
if b.kind == Legacy {
|
||||||
|
return mmChannel
|
||||||
|
}
|
||||||
|
return b.mc.GetChannelId(mmChannel, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) getIRCChannel(mmChannel string) string {
|
||||||
|
return b.mmMap[mmChannel]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) ignoreMessage(nick string, message string, protocol string) bool {
|
||||||
|
var ignoreNicks = b.mmIgnoreNicks
|
||||||
|
if protocol == "irc" {
|
||||||
|
ignoreNicks = b.ircIgnoreNicks
|
||||||
|
}
|
||||||
|
// should we discard messages ?
|
||||||
|
for _, entry := range ignoreNicks {
|
||||||
|
if nick == entry {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
61
bridge/config.go
Normal file
61
bridge/config.go
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package bridge
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gopkg.in/gcfg.v1"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
IRC struct {
|
||||||
|
UseTLS bool
|
||||||
|
UseSASL bool
|
||||||
|
SkipTLSVerify bool
|
||||||
|
Server string
|
||||||
|
Nick string
|
||||||
|
Password string
|
||||||
|
Channel string
|
||||||
|
NickServNick string
|
||||||
|
NickServPassword string
|
||||||
|
RemoteNickFormat string
|
||||||
|
IgnoreNicks string
|
||||||
|
}
|
||||||
|
Mattermost struct {
|
||||||
|
URL string
|
||||||
|
ShowJoinPart bool
|
||||||
|
IconURL string
|
||||||
|
SkipTLSVerify bool
|
||||||
|
BindAddress string
|
||||||
|
Channel string
|
||||||
|
PrefixMessagesWithNick bool
|
||||||
|
NicksPerRow int
|
||||||
|
NickFormatter string
|
||||||
|
Server string
|
||||||
|
Team string
|
||||||
|
Login string
|
||||||
|
Password string
|
||||||
|
RemoteNickFormat *string
|
||||||
|
IgnoreNicks string
|
||||||
|
NoTLS bool
|
||||||
|
}
|
||||||
|
Channel map[string]*struct {
|
||||||
|
IRC string
|
||||||
|
Mattermost string
|
||||||
|
}
|
||||||
|
General struct {
|
||||||
|
GiphyAPIKey string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewConfig(cfgfile string) *Config {
|
||||||
|
var cfg Config
|
||||||
|
content, err := ioutil.ReadFile(cfgfile)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
err = gcfg.ReadStringInto(&cfg, string(content))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Failed to parse "+cfgfile+":", err)
|
||||||
|
}
|
||||||
|
return &cfg
|
||||||
|
}
|
59
bridge/helper.go
Normal file
59
bridge/helper.go
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package bridge
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func tableformatter(nicks []string, nicksPerRow int, continued bool) string {
|
||||||
|
result := "|IRC users"
|
||||||
|
if continued {
|
||||||
|
result = "|(continued)"
|
||||||
|
}
|
||||||
|
for i := 0; i < 2; i++ {
|
||||||
|
for j := 1; j <= nicksPerRow && j <= len(nicks); j++ {
|
||||||
|
if i == 0 {
|
||||||
|
result += "|"
|
||||||
|
} else {
|
||||||
|
result += ":-|"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result += "\r\n|"
|
||||||
|
}
|
||||||
|
result += nicks[0] + "|"
|
||||||
|
for i := 1; i < len(nicks); i++ {
|
||||||
|
if i%nicksPerRow == 0 {
|
||||||
|
result += "\r\n|" + nicks[i] + "|"
|
||||||
|
} else {
|
||||||
|
result += nicks[i] + "|"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func plainformatter(nicks []string, nicksPerRow int) string {
|
||||||
|
return strings.Join(nicks, ", ") + " currently on IRC"
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsMarkup(message string) bool {
|
||||||
|
switch message[0] {
|
||||||
|
case '|':
|
||||||
|
fallthrough
|
||||||
|
case '#':
|
||||||
|
fallthrough
|
||||||
|
case '_':
|
||||||
|
fallthrough
|
||||||
|
case '*':
|
||||||
|
fallthrough
|
||||||
|
case '~':
|
||||||
|
fallthrough
|
||||||
|
case '-':
|
||||||
|
fallthrough
|
||||||
|
case ':':
|
||||||
|
fallthrough
|
||||||
|
case '>':
|
||||||
|
fallthrough
|
||||||
|
case '=':
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
@ -1,37 +1,148 @@
|
|||||||
|
#This is configuration for matterbridge.
|
||||||
|
###################################################################
|
||||||
|
#IRC section
|
||||||
|
###################################################################
|
||||||
[IRC]
|
[IRC]
|
||||||
server="irc.freenode.net"
|
#irc server to connect to.
|
||||||
port=6667
|
#REQUIRED
|
||||||
|
Server="irc.freenode.net:6667"
|
||||||
|
|
||||||
|
#Enable to use TLS connection to your irc server.
|
||||||
|
#OPTIONAL (default false)
|
||||||
UseTLS=false
|
UseTLS=false
|
||||||
|
|
||||||
|
#Enable SASL (PLAIN) authentication. (freenode requires this from eg AWS hosts)
|
||||||
|
#It uses NickServNick and NickServPassword as login and password
|
||||||
|
#OPTIONAL (deefault false)
|
||||||
|
UseSASL=false
|
||||||
|
|
||||||
|
#Enable to not verify the certificate on your irc server. i
|
||||||
|
#e.g. when using selfsigned certificates
|
||||||
|
#OPTIONAL (default false)
|
||||||
SkipTLSVerify=true
|
SkipTLSVerify=true
|
||||||
nick="matterbot"
|
|
||||||
channel="#matterbridge"
|
#Your nick on irc.
|
||||||
UseSlackCircumfix=false
|
#REQUIRED
|
||||||
|
Nick="matterbot"
|
||||||
|
|
||||||
|
#If you registered your bot with a service like Nickserv on freenode.
|
||||||
|
#Also being used when UseSASL=true
|
||||||
|
#OPTIONAL
|
||||||
|
NickServNick="nickserv"
|
||||||
|
NickServPassword="secret"
|
||||||
|
|
||||||
|
#RemoteNickFormat defines how Mattermost users appear on irc
|
||||||
|
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
|
||||||
|
#OPTIONAL (default NICK:)
|
||||||
|
RemoteNickFormat="{NICK}: "
|
||||||
|
|
||||||
|
#Nicks you want to ignore.
|
||||||
|
#Messages from those users will not be sent to mattermost.
|
||||||
|
#OPTIONAL
|
||||||
|
IgnoreNicks="ircspammer1 ircspammer2"
|
||||||
|
|
||||||
|
###################################################################
|
||||||
|
#mattermost section
|
||||||
|
###################################################################
|
||||||
|
|
||||||
[mattermost]
|
[mattermost]
|
||||||
url="http://yourdomain/hooks/yourhookkey"
|
#### Settings for webhook matterbridge.
|
||||||
port=9999
|
#### These settings will not be used when using -plus switch which doesn't use
|
||||||
showjoinpart=true
|
#### webhooks.
|
||||||
#remove token when using multiple channels!
|
|
||||||
token=yourtokenfrommattermost
|
#Url is your incoming webhook url as specified in mattermost.
|
||||||
|
#See account settings - integrations - incoming webhooks on mattermost.
|
||||||
|
#REQUIRED
|
||||||
|
URL="https://yourdomain/hooks/yourhookkey"
|
||||||
|
|
||||||
|
#Address to listen on for outgoing webhook requests from mattermost.
|
||||||
|
#See account settings - integrations - outgoing webhooks on mattermost.
|
||||||
|
#This setting will not be used when using -plus switch which doesn't use
|
||||||
|
#webhooks
|
||||||
|
#REQUIRED
|
||||||
|
BindAddress="0.0.0.0:9999"
|
||||||
|
|
||||||
|
#Icon that will be showed in mattermost.
|
||||||
|
#OPTIONAL
|
||||||
IconURL="http://youricon.png"
|
IconURL="http://youricon.png"
|
||||||
#SkipTLSVerify=true
|
|
||||||
#BindAddress="0.0.0.0"
|
#### Settings for matterbridge -plus
|
||||||
|
#### Thse settings will only be used when using the -plus switch.
|
||||||
|
|
||||||
|
#The mattermost hostname.
|
||||||
|
#REQUIRED
|
||||||
|
Server="yourmattermostserver.domain"
|
||||||
|
|
||||||
|
#Your team on mattermost.
|
||||||
|
#REQUIRED
|
||||||
|
Team="yourteam"
|
||||||
|
|
||||||
|
#login/pass of your bot.
|
||||||
|
#Use a dedicated user for this and not your own!
|
||||||
|
#REQUIRED
|
||||||
|
Login="yourlogin"
|
||||||
|
Password="yourpass"
|
||||||
|
|
||||||
|
#Disable to make a http connection to your mattermost.
|
||||||
|
#OPTIONAL (default false)
|
||||||
|
NoTLS=false
|
||||||
|
|
||||||
|
#### Shared settings for matterbridge and -plus
|
||||||
|
|
||||||
|
#Enable to not verify the certificate on your mattermost server.
|
||||||
|
#e.g. when using selfsigned certificates
|
||||||
|
#OPTIONAL (default false)
|
||||||
|
SkipTLSVerify=true
|
||||||
|
|
||||||
|
#Enable to show IRC joins/parts in mattermost.
|
||||||
|
#OPTIONAL (default false)
|
||||||
|
ShowJoinPart=false
|
||||||
|
|
||||||
|
#Whether to prefix messages from IRC to mattermost with the sender's nick.
|
||||||
|
#Useful if username overrides for incoming webhooks isn't enabled on the
|
||||||
|
#mattermost server. If you set PrefixMessagesWithNick to true, each message
|
||||||
|
#from IRC to Mattermost will by default be prefixed by "irc-" + nick. You can,
|
||||||
|
#however, modify how the messages appear, by setting (and modifying) RemoteNickFormat
|
||||||
|
#OPTIONAL (default false)
|
||||||
PrefixMessagesWithNick=false
|
PrefixMessagesWithNick=false
|
||||||
|
|
||||||
|
#RemoteNickFormat defines how IRC users appear on Mattermost.
|
||||||
|
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
|
||||||
|
#OPTIONAL (default irc-NICK)
|
||||||
|
RemoteNickFormat="irc-{NICK}"
|
||||||
|
|
||||||
|
#how to format the list of IRC nicks when displayed in mattermost.
|
||||||
|
#Possible options are "table" and "plain"
|
||||||
|
#OPTIONAL (default plain)
|
||||||
NickFormatter=plain
|
NickFormatter=plain
|
||||||
|
#How many nicks to list per row for formatters that support this.
|
||||||
|
#OPTIONAL (default 4)
|
||||||
NicksPerRow=4
|
NicksPerRow=4
|
||||||
#NickServNick="nickserv"
|
|
||||||
#NickServPassword="secret"
|
|
||||||
|
|
||||||
[general]
|
#Nicks you want to ignore. Messages from those users will not be sent to IRC.
|
||||||
GiphyAPIKey=dc6zaTOxFJmzC
|
#OPTIONAL
|
||||||
|
IgnoreNicks="mmbot spammer2"
|
||||||
|
|
||||||
|
###################################################################
|
||||||
#multiple channel config
|
#multiple channel config
|
||||||
#token you can find in your outgoing webhook
|
###################################################################
|
||||||
[Token "outgoingwebhooktoken1"]
|
#You can specify multiple channels.
|
||||||
IRCChannel="#off-topic"
|
#The name is just an identifier for you.
|
||||||
MMChannel="off-topic"
|
#REQUIRED (at least 1 channel)
|
||||||
|
[Channel "channel1"]
|
||||||
|
#Choose the IRC channel to send mattermost messages to.
|
||||||
|
IRC="#off-topic"
|
||||||
|
#Choose the mattermost channel to send IRC messages to.
|
||||||
|
mattermost="off-topic"
|
||||||
|
|
||||||
[Token "outgoingwebhooktoken2"]
|
[Channel "testchannel"]
|
||||||
IRCChannel="#testing"
|
IRC="#testing"
|
||||||
MMChannel="testing"
|
mattermost="testing"
|
||||||
|
|
||||||
|
###################################################################
|
||||||
|
#general
|
||||||
|
###################################################################
|
||||||
|
[general]
|
||||||
|
#request your API key on https://github.com/giphy/GiphyAPI. This is a public beta key.
|
||||||
|
#OPTIONAL
|
||||||
|
GiphyApiKey="dc6zaTOxFJmzC"
|
||||||
|
@ -2,10 +2,13 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"github.com/42wim/matterbridge-plus/bridge"
|
"fmt"
|
||||||
|
"github.com/42wim/matterbridge/bridge"
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var version = "0.5.0-beta2"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
log.SetFormatter(&log.TextFormatter{FullTimestamp: true})
|
log.SetFormatter(&log.TextFormatter{FullTimestamp: true})
|
||||||
}
|
}
|
||||||
@ -13,11 +16,23 @@ func init() {
|
|||||||
func main() {
|
func main() {
|
||||||
flagConfig := flag.String("conf", "matterbridge.conf", "config file")
|
flagConfig := flag.String("conf", "matterbridge.conf", "config file")
|
||||||
flagDebug := flag.Bool("debug", false, "enable debug")
|
flagDebug := flag.Bool("debug", false, "enable debug")
|
||||||
|
flagVersion := flag.Bool("version", false, "show version")
|
||||||
|
flagPlus := flag.Bool("plus", false, "running using API instead of webhooks")
|
||||||
|
flag.Parse()
|
||||||
|
if *flagVersion {
|
||||||
|
fmt.Println("version:", version)
|
||||||
|
return
|
||||||
|
}
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if *flagDebug {
|
if *flagDebug {
|
||||||
log.Info("enabling debug")
|
log.Info("enabling debug")
|
||||||
log.SetLevel(log.DebugLevel)
|
log.SetLevel(log.DebugLevel)
|
||||||
}
|
}
|
||||||
|
fmt.Println("running version", version)
|
||||||
|
if *flagPlus {
|
||||||
|
bridge.NewBridge("matterbot", bridge.NewConfig(*flagConfig), "")
|
||||||
|
} else {
|
||||||
bridge.NewBridge("matterbot", bridge.NewConfig(*flagConfig), "legacy")
|
bridge.NewBridge("matterbot", bridge.NewConfig(*flagConfig), "legacy")
|
||||||
|
}
|
||||||
select {}
|
select {}
|
||||||
}
|
}
|
||||||
|
570
matterclient/matterclient.go
Normal file
570
matterclient/matterclient.go
Normal file
@ -0,0 +1,570 @@
|
|||||||
|
package matterclient
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"net/http/cookiejar"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
log "github.com/Sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/gorilla/websocket"
|
||||||
|
"github.com/jpillora/backoff"
|
||||||
|
"github.com/mattermost/platform/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Credentials struct {
|
||||||
|
Login string
|
||||||
|
Team string
|
||||||
|
Pass string
|
||||||
|
Server string
|
||||||
|
NoTLS bool
|
||||||
|
SkipTLSVerify bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type Message struct {
|
||||||
|
Raw *model.Message
|
||||||
|
Post *model.Post
|
||||||
|
Team string
|
||||||
|
Channel string
|
||||||
|
Username string
|
||||||
|
Text string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Team struct {
|
||||||
|
Team *model.Team
|
||||||
|
Id string
|
||||||
|
Channels *model.ChannelList
|
||||||
|
MoreChannels *model.ChannelList
|
||||||
|
Users map[string]*model.User
|
||||||
|
}
|
||||||
|
|
||||||
|
type MMClient struct {
|
||||||
|
sync.RWMutex
|
||||||
|
*Credentials
|
||||||
|
Team *Team
|
||||||
|
OtherTeams []*Team
|
||||||
|
Client *model.Client
|
||||||
|
WsClient *websocket.Conn
|
||||||
|
WsQuit bool
|
||||||
|
WsAway bool
|
||||||
|
WsConnected bool
|
||||||
|
User *model.User
|
||||||
|
Users map[string]*model.User
|
||||||
|
MessageChan chan *Message
|
||||||
|
log *log.Entry
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(login, pass, team, server string) *MMClient {
|
||||||
|
cred := &Credentials{Login: login, Pass: pass, Team: team, Server: server}
|
||||||
|
mmclient := &MMClient{Credentials: cred, MessageChan: make(chan *Message, 100), Users: make(map[string]*model.User)}
|
||||||
|
mmclient.log = log.WithFields(log.Fields{"module": "matterclient"})
|
||||||
|
log.SetFormatter(&log.TextFormatter{FullTimestamp: true})
|
||||||
|
return mmclient
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) SetLogLevel(level string) {
|
||||||
|
l, err := log.ParseLevel(level)
|
||||||
|
if err != nil {
|
||||||
|
log.SetLevel(log.InfoLevel)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.SetLevel(l)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) Login() error {
|
||||||
|
m.WsConnected = false
|
||||||
|
if m.WsQuit {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
b := &backoff.Backoff{
|
||||||
|
Min: time.Second,
|
||||||
|
Max: 5 * time.Minute,
|
||||||
|
Jitter: true,
|
||||||
|
}
|
||||||
|
uriScheme := "https://"
|
||||||
|
wsScheme := "wss://"
|
||||||
|
if m.NoTLS {
|
||||||
|
uriScheme = "http://"
|
||||||
|
wsScheme = "ws://"
|
||||||
|
}
|
||||||
|
// login to mattermost
|
||||||
|
m.Client = model.NewClient(uriScheme + m.Credentials.Server)
|
||||||
|
m.Client.HttpClient.Transport = &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: m.SkipTLSVerify}}
|
||||||
|
var myinfo *model.Result
|
||||||
|
var appErr *model.AppError
|
||||||
|
var logmsg = "trying login"
|
||||||
|
for {
|
||||||
|
m.log.Debugf("%s %s %s %s", logmsg, m.Credentials.Team, m.Credentials.Login, m.Credentials.Server)
|
||||||
|
if strings.Contains(m.Credentials.Pass, model.SESSION_COOKIE_TOKEN) {
|
||||||
|
m.log.Debugf(logmsg+" with %s", model.SESSION_COOKIE_TOKEN)
|
||||||
|
token := strings.Split(m.Credentials.Pass, model.SESSION_COOKIE_TOKEN+"=")
|
||||||
|
if len(token) != 2 {
|
||||||
|
return errors.New("incorrect MMAUTHTOKEN. valid input is MMAUTHTOKEN=yourtoken")
|
||||||
|
}
|
||||||
|
m.Client.HttpClient.Jar = m.createCookieJar(token[1])
|
||||||
|
m.Client.MockSession(token[1])
|
||||||
|
myinfo, appErr = m.Client.GetMe("")
|
||||||
|
if appErr != nil {
|
||||||
|
return errors.New(appErr.DetailedError)
|
||||||
|
}
|
||||||
|
if myinfo.Data.(*model.User) == nil {
|
||||||
|
m.log.Errorf("LOGIN TOKEN: %s is invalid", m.Credentials.Pass)
|
||||||
|
return errors.New("invalid " + model.SESSION_COOKIE_TOKEN)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
myinfo, appErr = m.Client.Login(m.Credentials.Login, m.Credentials.Pass)
|
||||||
|
}
|
||||||
|
if appErr != nil {
|
||||||
|
d := b.Duration()
|
||||||
|
m.log.Debug(appErr.DetailedError)
|
||||||
|
if !strings.Contains(appErr.DetailedError, "connection refused") &&
|
||||||
|
!strings.Contains(appErr.DetailedError, "invalid character") {
|
||||||
|
if appErr.Message == "" {
|
||||||
|
return errors.New(appErr.DetailedError)
|
||||||
|
}
|
||||||
|
return errors.New(appErr.Message)
|
||||||
|
}
|
||||||
|
m.log.Debugf("LOGIN: %s, reconnecting in %s", appErr, d)
|
||||||
|
time.Sleep(d)
|
||||||
|
logmsg = "retrying login"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
// reset timer
|
||||||
|
b.Reset()
|
||||||
|
|
||||||
|
err := m.initUser()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.Team == nil {
|
||||||
|
return errors.New("team not found")
|
||||||
|
}
|
||||||
|
// set our team id as default route
|
||||||
|
m.Client.SetTeamId(m.Team.Id)
|
||||||
|
|
||||||
|
// setup websocket connection
|
||||||
|
wsurl := wsScheme + m.Credentials.Server + "/api/v3/users/websocket"
|
||||||
|
header := http.Header{}
|
||||||
|
header.Set(model.HEADER_AUTH, "BEARER "+m.Client.AuthToken)
|
||||||
|
|
||||||
|
m.log.Debug("WsClient: making connection")
|
||||||
|
for {
|
||||||
|
wsDialer := &websocket.Dialer{Proxy: http.ProxyFromEnvironment, TLSClientConfig: &tls.Config{InsecureSkipVerify: m.SkipTLSVerify}}
|
||||||
|
m.WsClient, _, err = wsDialer.Dial(wsurl, header)
|
||||||
|
if err != nil {
|
||||||
|
d := b.Duration()
|
||||||
|
m.log.Debugf("WSS: %s, reconnecting in %s", err, d)
|
||||||
|
time.Sleep(d)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
b.Reset()
|
||||||
|
|
||||||
|
// only start to parse WS messages when login is completely done
|
||||||
|
m.WsConnected = true
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) Logout() error {
|
||||||
|
m.log.Debugf("logout as %s (team: %s) on %s", m.Credentials.Login, m.Credentials.Team, m.Credentials.Server)
|
||||||
|
m.WsQuit = true
|
||||||
|
m.WsClient.Close()
|
||||||
|
m.WsClient.UnderlyingConn().Close()
|
||||||
|
m.WsClient = nil
|
||||||
|
_, err := m.Client.Logout()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) WsReceiver() {
|
||||||
|
for {
|
||||||
|
var rmsg model.Message
|
||||||
|
if m.WsQuit {
|
||||||
|
m.log.Debug("exiting WsReceiver")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := m.WsClient.ReadJSON(&rmsg); err != nil {
|
||||||
|
m.log.Error("error:", err)
|
||||||
|
// reconnect
|
||||||
|
m.Login()
|
||||||
|
}
|
||||||
|
// we're not fully logged in yet.
|
||||||
|
if !m.WsConnected {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if rmsg.Action == "ping" {
|
||||||
|
m.handleWsPing()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
msg := &Message{Raw: &rmsg, Team: m.Credentials.Team}
|
||||||
|
m.parseMessage(msg)
|
||||||
|
m.MessageChan <- msg
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) handleWsPing() {
|
||||||
|
m.log.Debug("Ws PING")
|
||||||
|
if !m.WsQuit && !m.WsAway {
|
||||||
|
m.log.Debug("Ws PONG")
|
||||||
|
m.WsClient.WriteMessage(websocket.PongMessage, []byte{})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) parseMessage(rmsg *Message) {
|
||||||
|
switch rmsg.Raw.Action {
|
||||||
|
case model.ACTION_POSTED:
|
||||||
|
m.parseActionPost(rmsg)
|
||||||
|
/*
|
||||||
|
case model.ACTION_USER_REMOVED:
|
||||||
|
m.handleWsActionUserRemoved(&rmsg)
|
||||||
|
case model.ACTION_USER_ADDED:
|
||||||
|
m.handleWsActionUserAdded(&rmsg)
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) parseActionPost(rmsg *Message) {
|
||||||
|
data := model.PostFromJson(strings.NewReader(rmsg.Raw.Props["post"]))
|
||||||
|
// we don't have the user, refresh the userlist
|
||||||
|
if m.GetUser(data.UserId) == nil {
|
||||||
|
m.UpdateUsers()
|
||||||
|
}
|
||||||
|
rmsg.Username = m.GetUser(data.UserId).Username
|
||||||
|
rmsg.Channel = m.GetChannelName(data.ChannelId)
|
||||||
|
rmsg.Team = m.GetTeamName(rmsg.Raw.TeamId)
|
||||||
|
// direct message
|
||||||
|
if data.Type == "D" {
|
||||||
|
rmsg.Channel = m.GetUser(data.UserId).Username
|
||||||
|
}
|
||||||
|
rmsg.Text = data.Message
|
||||||
|
rmsg.Post = data
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) UpdateUsers() error {
|
||||||
|
mmusers, _ := m.Client.GetProfilesForDirectMessageList(m.Team.Id)
|
||||||
|
m.Lock()
|
||||||
|
m.Users = mmusers.Data.(map[string]*model.User)
|
||||||
|
m.Unlock()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) UpdateChannels() error {
|
||||||
|
mmchannels, _ := m.Client.GetChannels("")
|
||||||
|
mmchannels2, _ := m.Client.GetMoreChannels("")
|
||||||
|
m.Lock()
|
||||||
|
m.Team.Channels = mmchannels.Data.(*model.ChannelList)
|
||||||
|
m.Team.MoreChannels = mmchannels2.Data.(*model.ChannelList)
|
||||||
|
m.Unlock()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) GetChannelName(channelId string) string {
|
||||||
|
m.RLock()
|
||||||
|
defer m.RUnlock()
|
||||||
|
for _, t := range m.OtherTeams {
|
||||||
|
for _, channel := range append(t.Channels.Channels, t.MoreChannels.Channels...) {
|
||||||
|
if channel.Id == channelId {
|
||||||
|
return channel.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) GetChannelId(name string, teamId string) string {
|
||||||
|
m.RLock()
|
||||||
|
defer m.RUnlock()
|
||||||
|
if teamId == "" {
|
||||||
|
teamId = m.Team.Id
|
||||||
|
}
|
||||||
|
for _, t := range m.OtherTeams {
|
||||||
|
if t.Id == teamId {
|
||||||
|
for _, channel := range append(t.Channels.Channels, t.MoreChannels.Channels...) {
|
||||||
|
if channel.Name == name {
|
||||||
|
return channel.Id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) GetChannelHeader(channelId string) string {
|
||||||
|
m.RLock()
|
||||||
|
defer m.RUnlock()
|
||||||
|
for _, t := range m.OtherTeams {
|
||||||
|
for _, channel := range append(t.Channels.Channels, t.MoreChannels.Channels...) {
|
||||||
|
if channel.Id == channelId {
|
||||||
|
return channel.Header
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) PostMessage(channelId string, text string) {
|
||||||
|
post := &model.Post{ChannelId: channelId, Message: text}
|
||||||
|
m.Client.CreatePost(post)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) JoinChannel(channelId string) error {
|
||||||
|
m.RLock()
|
||||||
|
defer m.RUnlock()
|
||||||
|
for _, c := range m.Team.Channels.Channels {
|
||||||
|
if c.Id == channelId {
|
||||||
|
m.log.Debug("Not joining ", channelId, " already joined.")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m.log.Debug("Joining ", channelId)
|
||||||
|
_, err := m.Client.JoinChannel(channelId)
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("failed to join")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) GetPostsSince(channelId string, time int64) *model.PostList {
|
||||||
|
res, err := m.Client.GetPostsSince(channelId, time)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return res.Data.(*model.PostList)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) SearchPosts(query string) *model.PostList {
|
||||||
|
res, err := m.Client.SearchPosts(query, false)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return res.Data.(*model.PostList)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) GetPosts(channelId string, limit int) *model.PostList {
|
||||||
|
res, err := m.Client.GetPosts(channelId, 0, limit, "")
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return res.Data.(*model.PostList)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) GetPublicLink(filename string) string {
|
||||||
|
res, err := m.Client.GetPublicLink(filename)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return res.Data.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) GetPublicLinks(filenames []string) []string {
|
||||||
|
var output []string
|
||||||
|
for _, f := range filenames {
|
||||||
|
res, err := m.Client.GetPublicLink(f)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
output = append(output, res.Data.(string))
|
||||||
|
}
|
||||||
|
return output
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) UpdateChannelHeader(channelId string, header string) {
|
||||||
|
data := make(map[string]string)
|
||||||
|
data["channel_id"] = channelId
|
||||||
|
data["channel_header"] = header
|
||||||
|
m.log.Debugf("updating channelheader %#v, %#v", channelId, header)
|
||||||
|
_, err := m.Client.UpdateChannelHeader(data)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) UpdateLastViewed(channelId string) {
|
||||||
|
m.log.Debugf("posting lastview %#v", channelId)
|
||||||
|
_, err := m.Client.UpdateLastViewedAt(channelId)
|
||||||
|
if err != nil {
|
||||||
|
m.log.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) UsernamesInChannel(channelId string) []string {
|
||||||
|
ceiRes, err := m.Client.GetChannelExtraInfo(channelId, 5000, "")
|
||||||
|
if err != nil {
|
||||||
|
m.log.Errorf("UsernamesInChannel(%s) failed: %s", channelId, err)
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
extra := ceiRes.Data.(*model.ChannelExtra)
|
||||||
|
result := []string{}
|
||||||
|
for _, member := range extra.Members {
|
||||||
|
result = append(result, member.Username)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) createCookieJar(token string) *cookiejar.Jar {
|
||||||
|
var cookies []*http.Cookie
|
||||||
|
jar, _ := cookiejar.New(nil)
|
||||||
|
firstCookie := &http.Cookie{
|
||||||
|
Name: "MMAUTHTOKEN",
|
||||||
|
Value: token,
|
||||||
|
Path: "/",
|
||||||
|
Domain: m.Credentials.Server,
|
||||||
|
}
|
||||||
|
cookies = append(cookies, firstCookie)
|
||||||
|
cookieURL, _ := url.Parse("https://" + m.Credentials.Server)
|
||||||
|
jar.SetCookies(cookieURL, cookies)
|
||||||
|
return jar
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendDirectMessage sends a direct message to specified user
|
||||||
|
func (m *MMClient) SendDirectMessage(toUserId string, msg string) {
|
||||||
|
m.log.Debugf("SendDirectMessage to %s, msg %s", toUserId, msg)
|
||||||
|
// create DM channel (only happens on first message)
|
||||||
|
_, err := m.Client.CreateDirectChannel(toUserId)
|
||||||
|
if err != nil {
|
||||||
|
m.log.Debugf("SendDirectMessage to %#v failed: %s", toUserId, err)
|
||||||
|
}
|
||||||
|
channelName := model.GetDMNameFromIds(toUserId, m.User.Id)
|
||||||
|
|
||||||
|
// update our channels
|
||||||
|
mmchannels, _ := m.Client.GetChannels("")
|
||||||
|
m.Lock()
|
||||||
|
m.Team.Channels = mmchannels.Data.(*model.ChannelList)
|
||||||
|
m.Unlock()
|
||||||
|
|
||||||
|
// build & send the message
|
||||||
|
msg = strings.Replace(msg, "\r", "", -1)
|
||||||
|
post := &model.Post{ChannelId: m.GetChannelId(channelName, ""), Message: msg}
|
||||||
|
m.Client.CreatePost(post)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTeamName returns the name of the specified teamId
|
||||||
|
func (m *MMClient) GetTeamName(teamId string) string {
|
||||||
|
m.RLock()
|
||||||
|
defer m.RUnlock()
|
||||||
|
for _, t := range m.OtherTeams {
|
||||||
|
if t.Id == teamId {
|
||||||
|
return t.Team.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetChannels returns all channels we're members off
|
||||||
|
func (m *MMClient) GetChannels() []*model.Channel {
|
||||||
|
m.RLock()
|
||||||
|
defer m.RUnlock()
|
||||||
|
var channels []*model.Channel
|
||||||
|
// our primary team channels first
|
||||||
|
channels = append(channels, m.Team.Channels.Channels...)
|
||||||
|
for _, t := range m.OtherTeams {
|
||||||
|
if t.Id != m.Team.Id {
|
||||||
|
channels = append(channels, t.Channels.Channels...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return channels
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetMoreChannels returns existing channels where we're not a member off.
|
||||||
|
func (m *MMClient) GetMoreChannels() []*model.Channel {
|
||||||
|
m.RLock()
|
||||||
|
defer m.RUnlock()
|
||||||
|
var channels []*model.Channel
|
||||||
|
for _, t := range m.OtherTeams {
|
||||||
|
channels = append(channels, t.MoreChannels.Channels...)
|
||||||
|
}
|
||||||
|
return channels
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTeamFromChannel returns teamId belonging to channel (DM channels have no teamId).
|
||||||
|
func (m *MMClient) GetTeamFromChannel(channelId string) string {
|
||||||
|
m.RLock()
|
||||||
|
defer m.RUnlock()
|
||||||
|
var channels []*model.Channel
|
||||||
|
for _, t := range m.OtherTeams {
|
||||||
|
channels = append(channels, t.Channels.Channels...)
|
||||||
|
for _, c := range channels {
|
||||||
|
if c.Id == channelId {
|
||||||
|
return t.Id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) GetLastViewedAt(channelId string) int64 {
|
||||||
|
m.RLock()
|
||||||
|
defer m.RUnlock()
|
||||||
|
for _, t := range m.OtherTeams {
|
||||||
|
if _, ok := t.Channels.Members[channelId]; ok {
|
||||||
|
return t.Channels.Members[channelId].LastViewedAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) GetUsers() map[string]*model.User {
|
||||||
|
users := make(map[string]*model.User)
|
||||||
|
m.RLock()
|
||||||
|
defer m.RUnlock()
|
||||||
|
for k, v := range m.Users {
|
||||||
|
users[k] = v
|
||||||
|
}
|
||||||
|
return users
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) GetUser(userId string) *model.User {
|
||||||
|
m.RLock()
|
||||||
|
defer m.RUnlock()
|
||||||
|
return m.Users[userId]
|
||||||
|
}
|
||||||
|
|
||||||
|
// initialize user and teams
|
||||||
|
func (m *MMClient) initUser() error {
|
||||||
|
m.Lock()
|
||||||
|
defer m.Unlock()
|
||||||
|
m.log.Debug("initUser()")
|
||||||
|
initLoad, err := m.Client.GetInitialLoad()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
initData := initLoad.Data.(*model.InitialLoad)
|
||||||
|
m.User = initData.User
|
||||||
|
// we only load all team data on initial login.
|
||||||
|
// all other updates are for channels from our (primary) team only.
|
||||||
|
m.log.Debug("initUser(): loading all team data")
|
||||||
|
for _, v := range initData.Teams {
|
||||||
|
m.Client.SetTeamId(v.Id)
|
||||||
|
mmusers, _ := m.Client.GetProfiles(v.Id, "")
|
||||||
|
t := &Team{Team: v, Users: mmusers.Data.(map[string]*model.User), Id: v.Id}
|
||||||
|
mmchannels, _ := m.Client.GetChannels("")
|
||||||
|
t.Channels = mmchannels.Data.(*model.ChannelList)
|
||||||
|
mmchannels, _ = m.Client.GetMoreChannels("")
|
||||||
|
t.MoreChannels = mmchannels.Data.(*model.ChannelList)
|
||||||
|
m.OtherTeams = append(m.OtherTeams, t)
|
||||||
|
if v.Name == m.Credentials.Team {
|
||||||
|
m.Team = t
|
||||||
|
m.log.Debugf("initUser(): found our team %s (id: %s)", v.Name, v.Id)
|
||||||
|
}
|
||||||
|
// add all users
|
||||||
|
for k, v := range t.Users {
|
||||||
|
m.Users[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
@ -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)
|
||||||
@ -31,11 +31,11 @@ type IMessage struct {
|
|||||||
TeamID string `schema:"team_id"`
|
TeamID string `schema:"team_id"`
|
||||||
TeamDomain string `schema:"team_domain"`
|
TeamDomain string `schema:"team_domain"`
|
||||||
ChannelID string `schema:"channel_id"`
|
ChannelID string `schema:"channel_id"`
|
||||||
ServiceID string `schema:"service_id"`
|
|
||||||
ChannelName string `schema:"channel_name"`
|
ChannelName string `schema:"channel_name"`
|
||||||
Timestamp string `schema:"timestamp"`
|
Timestamp string `schema:"timestamp"`
|
||||||
UserID string `schema:"user_id"`
|
UserID string `schema:"user_id"`
|
||||||
UserName string `schema:"user_name"`
|
UserName string `schema:"user_name"`
|
||||||
|
PostId string `schema:"post_id"`
|
||||||
Text string `schema:"text"`
|
Text string `schema:"text"`
|
||||||
TriggerWord string `schema:"trigger_word"`
|
TriggerWord string `schema:"trigger_word"`
|
||||||
}
|
}
|
||||||
@ -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,15 +60,15 @@ 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 {
|
|
||||||
c.Port = 9999
|
|
||||||
}
|
|
||||||
c.BindAddress += ":"
|
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify},
|
||||||
}
|
}
|
||||||
c.httpclient = &http.Client{Transport: tr}
|
c.httpclient = &http.Client{Transport: tr}
|
||||||
if !c.DisableServer {
|
if !c.DisableServer {
|
||||||
|
_, _, err := net.SplitHostPort(c.BindAddress)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("incorrect bindaddress %s", c.BindAddress)
|
||||||
|
}
|
||||||
go c.StartServer()
|
go c.StartServer()
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
50
migration.md
Normal file
50
migration.md
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# Breaking changes from 0.4 to 0.5 for matterbridge (webhooks version)
|
||||||
|
## IRC section
|
||||||
|
### Server
|
||||||
|
Port removed, added to server
|
||||||
|
```
|
||||||
|
server="irc.freenode.net"
|
||||||
|
port=6667
|
||||||
|
```
|
||||||
|
changed to
|
||||||
|
```
|
||||||
|
server="irc.freenode.net:6667"
|
||||||
|
```
|
||||||
|
### Channel
|
||||||
|
Removed see Channels section below
|
||||||
|
|
||||||
|
### UseSlackCircumfix=true
|
||||||
|
Removed, can be done by using ```RemoteNickFormat="<{NICK}> "```
|
||||||
|
|
||||||
|
## Mattermost section
|
||||||
|
### BindAddress
|
||||||
|
Port removed, added to BindAddress
|
||||||
|
|
||||||
|
```
|
||||||
|
BindAddress="0.0.0.0"
|
||||||
|
port=9999
|
||||||
|
```
|
||||||
|
|
||||||
|
changed to
|
||||||
|
|
||||||
|
```
|
||||||
|
BindAddress="0.0.0.0:9999"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Token
|
||||||
|
Removed
|
||||||
|
|
||||||
|
## Channels section
|
||||||
|
```
|
||||||
|
[Token "outgoingwebhooktoken1"]
|
||||||
|
IRCChannel="#off-topic"
|
||||||
|
MMChannel="off-topic"
|
||||||
|
```
|
||||||
|
|
||||||
|
changed to
|
||||||
|
|
||||||
|
```
|
||||||
|
[Channel "channelnameofchoice"]
|
||||||
|
IRC="#off-topic"
|
||||||
|
Mattermost="off-topic"
|
||||||
|
```
|
155
vendor/github.com/42wim/matterbridge-plus/bridge/bridge.go
generated
vendored
155
vendor/github.com/42wim/matterbridge-plus/bridge/bridge.go
generated
vendored
@ -23,6 +23,7 @@ type MMhook struct {
|
|||||||
type MMapi struct {
|
type MMapi struct {
|
||||||
mc *matterclient.MMClient
|
mc *matterclient.MMClient
|
||||||
mmMap map[string]string
|
mmMap map[string]string
|
||||||
|
mmIgnoreNicks []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type MMirc struct {
|
type MMirc struct {
|
||||||
@ -30,6 +31,7 @@ type MMirc struct {
|
|||||||
ircNick string
|
ircNick string
|
||||||
ircMap map[string]string
|
ircMap map[string]string
|
||||||
names map[string][]string
|
names map[string][]string
|
||||||
|
ircIgnoreNicks []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type MMMessage struct {
|
type MMMessage struct {
|
||||||
@ -53,6 +55,8 @@ type FancyLog struct {
|
|||||||
|
|
||||||
var flog FancyLog
|
var flog FancyLog
|
||||||
|
|
||||||
|
const Legacy = "legacy"
|
||||||
|
|
||||||
func initFLog() {
|
func initFLog() {
|
||||||
flog.irc = log.WithFields(log.Fields{"module": "irc"})
|
flog.irc = log.WithFields(log.Fields{"module": "irc"})
|
||||||
flog.mm = log.WithFields(log.Fields{"module": "mattermost"})
|
flog.mm = log.WithFields(log.Fields{"module": "mattermost"})
|
||||||
@ -66,7 +70,9 @@ func NewBridge(name string, config *Config, kind string) *Bridge {
|
|||||||
b.ircNick = b.Config.IRC.Nick
|
b.ircNick = b.Config.IRC.Nick
|
||||||
b.ircMap = make(map[string]string)
|
b.ircMap = make(map[string]string)
|
||||||
b.MMirc.names = make(map[string][]string)
|
b.MMirc.names = make(map[string][]string)
|
||||||
if kind == "legacy" {
|
b.ircIgnoreNicks = strings.Fields(b.Config.IRC.IgnoreNicks)
|
||||||
|
b.mmIgnoreNicks = strings.Fields(b.Config.Mattermost.IgnoreNicks)
|
||||||
|
if kind == Legacy {
|
||||||
if len(b.Config.Token) > 0 {
|
if len(b.Config.Token) > 0 {
|
||||||
for _, val := range b.Config.Token {
|
for _, val := range b.Config.Token {
|
||||||
b.ircMap[val.IRCChannel] = val.MMChannel
|
b.ircMap[val.IRCChannel] = val.MMChannel
|
||||||
@ -87,10 +93,14 @@ func NewBridge(name string, config *Config, kind string) *Bridge {
|
|||||||
}
|
}
|
||||||
b.mc = matterclient.New(b.Config.Mattermost.Login, b.Config.Mattermost.Password,
|
b.mc = matterclient.New(b.Config.Mattermost.Login, b.Config.Mattermost.Password,
|
||||||
b.Config.Mattermost.Team, b.Config.Mattermost.Server)
|
b.Config.Mattermost.Team, b.Config.Mattermost.Server)
|
||||||
|
b.mc.SkipTLSVerify = b.Config.Mattermost.SkipTLSVerify
|
||||||
|
b.mc.NoTLS = b.Config.Mattermost.NoTLS
|
||||||
|
flog.mm.Infof("Trying login %s (team: %s) on %s", b.Config.Mattermost.Login, b.Config.Mattermost.Team, b.Config.Mattermost.Server)
|
||||||
err := b.mc.Login()
|
err := b.mc.Login()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
flog.mm.Fatal("can not connect", err)
|
flog.mm.Fatal("Can not connect", err)
|
||||||
}
|
}
|
||||||
|
flog.mm.Info("Login ok")
|
||||||
b.mc.JoinChannel(b.Config.Mattermost.Channel)
|
b.mc.JoinChannel(b.Config.Mattermost.Channel)
|
||||||
if len(b.Config.Channel) > 0 {
|
if len(b.Config.Channel) > 0 {
|
||||||
for _, val := range b.Config.Channel {
|
for _, val := range b.Config.Channel {
|
||||||
@ -99,7 +109,9 @@ func NewBridge(name string, config *Config, kind string) *Bridge {
|
|||||||
}
|
}
|
||||||
go b.mc.WsReceiver()
|
go b.mc.WsReceiver()
|
||||||
}
|
}
|
||||||
|
flog.irc.Info("Trying IRC connection")
|
||||||
b.i = b.createIRC(name)
|
b.i = b.createIRC(name)
|
||||||
|
flog.irc.Info("Connection succeeded")
|
||||||
go b.handleMatter()
|
go b.handleMatter()
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
@ -111,37 +123,51 @@ func (b *Bridge) createIRC(name string) *irc.Connection {
|
|||||||
if b.Config.IRC.Password != "" {
|
if b.Config.IRC.Password != "" {
|
||||||
i.Password = b.Config.IRC.Password
|
i.Password = b.Config.IRC.Password
|
||||||
}
|
}
|
||||||
i.AddCallback("*", b.handleOther)
|
i.AddCallback(ircm.RPL_WELCOME, b.handleNewConnection)
|
||||||
i.Connect(b.Config.IRC.Server + ":" + strconv.Itoa(b.Config.IRC.Port))
|
i.Connect(b.Config.IRC.Server + ":" + strconv.Itoa(b.Config.IRC.Port))
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) handleNewConnection(event *irc.Event) {
|
func (b *Bridge) handleNewConnection(event *irc.Event) {
|
||||||
|
flog.irc.Info("Registering callbacks")
|
||||||
|
i := b.i
|
||||||
b.ircNick = event.Arguments[0]
|
b.ircNick = event.Arguments[0]
|
||||||
|
i.AddCallback("PRIVMSG", b.handlePrivMsg)
|
||||||
|
i.AddCallback("CTCP_ACTION", b.handlePrivMsg)
|
||||||
|
i.AddCallback(ircm.RPL_ENDOFNAMES, b.endNames)
|
||||||
|
i.AddCallback(ircm.RPL_NAMREPLY, b.storeNames)
|
||||||
|
i.AddCallback(ircm.RPL_TOPICWHOTIME, b.handleTopicWhoTime)
|
||||||
|
i.AddCallback(ircm.NOTICE, b.handleNotice)
|
||||||
|
i.AddCallback(ircm.RPL_MYINFO, func(e *irc.Event) { flog.irc.Infof("%s: %s", e.Code, strings.Join(e.Arguments[1:], " ")) })
|
||||||
|
i.AddCallback("PING", func(e *irc.Event) {
|
||||||
|
i.SendRaw("PONG :" + e.Message())
|
||||||
|
flog.irc.Debugf("PING/PONG")
|
||||||
|
})
|
||||||
|
if b.Config.Mattermost.ShowJoinPart {
|
||||||
|
i.AddCallback("JOIN", b.handleJoinPart)
|
||||||
|
i.AddCallback("PART", b.handleJoinPart)
|
||||||
|
}
|
||||||
|
i.AddCallback("*", b.handleOther)
|
||||||
b.setupChannels()
|
b.setupChannels()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) setupChannels() {
|
func (b *Bridge) setupChannels() {
|
||||||
i := b.i
|
i := b.i
|
||||||
flog.irc.Info("Joining ", b.Config.IRC.Channel, " as ", b.ircNick)
|
if b.Config.IRC.Channel != "" {
|
||||||
|
flog.irc.Infof("Joining %s as %s", b.Config.IRC.Channel, b.ircNick)
|
||||||
i.Join(b.Config.IRC.Channel)
|
i.Join(b.Config.IRC.Channel)
|
||||||
if b.kind == "legacy" {
|
}
|
||||||
|
if b.kind == Legacy {
|
||||||
for _, val := range b.Config.Token {
|
for _, val := range b.Config.Token {
|
||||||
flog.irc.Info("Joining ", val.IRCChannel, " as ", b.ircNick)
|
flog.irc.Infof("Joining %s as %s", val.IRCChannel, b.ircNick)
|
||||||
i.Join(val.IRCChannel)
|
i.Join(val.IRCChannel)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for _, val := range b.Config.Channel {
|
for _, val := range b.Config.Channel {
|
||||||
flog.irc.Info("Joining ", val.IRC, " as ", b.ircNick)
|
flog.irc.Infof("Joining %s as %s", val.IRC, b.ircNick)
|
||||||
i.Join(val.IRC)
|
i.Join(val.IRC)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i.AddCallback("PRIVMSG", b.handlePrivMsg)
|
|
||||||
i.AddCallback("CTCP_ACTION", b.handlePrivMsg)
|
|
||||||
if b.Config.Mattermost.ShowJoinPart {
|
|
||||||
i.AddCallback("JOIN", b.handleJoinPart)
|
|
||||||
i.AddCallback("PART", b.handleJoinPart)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) handleIrcBotCommand(event *irc.Event) bool {
|
func (b *Bridge) handleIrcBotCommand(event *irc.Event) bool {
|
||||||
@ -177,6 +203,9 @@ func (b *Bridge) ircNickFormat(nick string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) handlePrivMsg(event *irc.Event) {
|
func (b *Bridge) handlePrivMsg(event *irc.Event) {
|
||||||
|
if b.ignoreMessage(event.Nick, event.Message(), "irc") {
|
||||||
|
return
|
||||||
|
}
|
||||||
if b.handleIrcBotCommand(event) {
|
if b.handleIrcBotCommand(event) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -238,81 +267,21 @@ func (b *Bridge) endNames(event *irc.Event) {
|
|||||||
b.MMirc.names[channel] = nil
|
b.MMirc.names[channel] = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) handleTopicWhoTime(event *irc.Event) bool {
|
func (b *Bridge) handleTopicWhoTime(event *irc.Event) {
|
||||||
parts := strings.Split(event.Arguments[2], "!")
|
parts := strings.Split(event.Arguments[2], "!")
|
||||||
t_i, err := strconv.ParseInt(event.Arguments[3], 10, 64)
|
t, err := strconv.ParseInt(event.Arguments[3], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
flog.irc.Errorf("Invalid time stamp: %s", event.Arguments[3])
|
flog.irc.Errorf("Invalid time stamp: %s", event.Arguments[3])
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
user := parts[0]
|
user := parts[0]
|
||||||
if len(parts) > 1 {
|
if len(parts) > 1 {
|
||||||
user += " [" + parts[1] + "]"
|
user += " [" + parts[1] + "]"
|
||||||
}
|
}
|
||||||
flog.irc.Infof("%s: Topic set by %s [%s]", event.Code, user, time.Unix(t_i, 0))
|
flog.irc.Infof("%s: Topic set by %s [%s]", event.Code, user, time.Unix(t, 0))
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) handleOther(event *irc.Event) {
|
func (b *Bridge) handleOther(event *irc.Event) {
|
||||||
flog.irc.Debugf("%#v", event)
|
flog.irc.Debugf("%#v", event)
|
||||||
switch event.Code {
|
|
||||||
case ircm.RPL_WELCOME:
|
|
||||||
b.handleNewConnection(event)
|
|
||||||
case ircm.RPL_ENDOFNAMES:
|
|
||||||
b.endNames(event)
|
|
||||||
case ircm.RPL_NAMREPLY:
|
|
||||||
b.storeNames(event)
|
|
||||||
case ircm.RPL_ISUPPORT:
|
|
||||||
fallthrough
|
|
||||||
case ircm.RPL_LUSEROP:
|
|
||||||
fallthrough
|
|
||||||
case ircm.RPL_LUSERUNKNOWN:
|
|
||||||
fallthrough
|
|
||||||
case ircm.RPL_LUSERCHANNELS:
|
|
||||||
fallthrough
|
|
||||||
case ircm.RPL_MYINFO:
|
|
||||||
flog.irc.Infof("%s: %s", event.Code, strings.Join(event.Arguments[1:], " "))
|
|
||||||
case ircm.RPL_YOURHOST:
|
|
||||||
fallthrough
|
|
||||||
case ircm.RPL_CREATED:
|
|
||||||
fallthrough
|
|
||||||
case ircm.RPL_STATSDLINE:
|
|
||||||
fallthrough
|
|
||||||
case ircm.RPL_LUSERCLIENT:
|
|
||||||
fallthrough
|
|
||||||
case ircm.RPL_LUSERME:
|
|
||||||
fallthrough
|
|
||||||
case ircm.RPL_LOCALUSERS:
|
|
||||||
fallthrough
|
|
||||||
case ircm.RPL_GLOBALUSERS:
|
|
||||||
fallthrough
|
|
||||||
case ircm.RPL_MOTD:
|
|
||||||
flog.irc.Infof("%s: %s", event.Code, event.Message())
|
|
||||||
// flog.irc.Info(event.Message())
|
|
||||||
case ircm.RPL_TOPIC:
|
|
||||||
flog.irc.Infof("%s: Topic for %s: %s", event.Code, event.Arguments[1], event.Message())
|
|
||||||
case ircm.RPL_TOPICWHOTIME:
|
|
||||||
if !b.handleTopicWhoTime(event) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case ircm.MODE:
|
|
||||||
flog.irc.Infof("%s: %s %s", event.Code, event.Arguments[1], event.Arguments[0])
|
|
||||||
case ircm.JOIN:
|
|
||||||
fallthrough
|
|
||||||
case ircm.PING:
|
|
||||||
fallthrough
|
|
||||||
case ircm.PONG:
|
|
||||||
flog.irc.Infof("%s: %s", event.Code, event.Message())
|
|
||||||
case ircm.RPL_ENDOFMOTD:
|
|
||||||
case ircm.RPL_MOTDSTART:
|
|
||||||
case ircm.ERR_NICKNAMEINUSE:
|
|
||||||
flog.irc.Warn(event.Message())
|
|
||||||
case ircm.NOTICE:
|
|
||||||
b.handleNotice(event)
|
|
||||||
default:
|
|
||||||
flog.irc.Infof("UNKNOWN EVENT: %#v", event)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) Send(nick string, message string, channel string) error {
|
func (b *Bridge) Send(nick string, message string, channel string) error {
|
||||||
@ -327,7 +296,7 @@ func (b *Bridge) SendType(nick string, message string, channel string, mtype str
|
|||||||
message = nick + " " + message
|
message = nick + " " + message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if b.kind == "legacy" {
|
if b.kind == Legacy {
|
||||||
matterMessage := matterhook.OMessage{IconURL: b.Config.Mattermost.IconURL}
|
matterMessage := matterhook.OMessage{IconURL: b.Config.Mattermost.IconURL}
|
||||||
matterMessage.Channel = channel
|
matterMessage.Channel = channel
|
||||||
matterMessage.UserName = nick
|
matterMessage.UserName = nick
|
||||||
@ -371,24 +340,34 @@ func (b *Bridge) handleMatterClient(mchan chan *MMMessage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) handleMatter() {
|
func (b *Bridge) handleMatter() {
|
||||||
|
flog.mm.Infof("Choosing Mattermost connection type %s", b.kind)
|
||||||
mchan := make(chan *MMMessage)
|
mchan := make(chan *MMMessage)
|
||||||
if b.kind == "legacy" {
|
if b.kind == Legacy {
|
||||||
go b.handleMatterHook(mchan)
|
go b.handleMatterHook(mchan)
|
||||||
} else {
|
} else {
|
||||||
go b.handleMatterClient(mchan)
|
go b.handleMatterClient(mchan)
|
||||||
}
|
}
|
||||||
|
flog.mm.Info("Start listening for Mattermost messages")
|
||||||
for message := range mchan {
|
for message := range mchan {
|
||||||
var username string
|
var username string
|
||||||
|
if b.ignoreMessage(message.Username, message.Text, "mattermost") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
username = message.Username + ": "
|
username = message.Username + ": "
|
||||||
if b.Config.IRC.RemoteNickFormat != "" {
|
if b.Config.IRC.RemoteNickFormat != "" {
|
||||||
username = strings.Replace(b.Config.IRC.RemoteNickFormat, "{NICK}", message.Username, -1)
|
username = strings.Replace(b.Config.IRC.RemoteNickFormat, "{NICK}", message.Username, -1)
|
||||||
} else if b.Config.IRC.UseSlackCircumfix {
|
} else if b.Config.IRC.UseSlackCircumfix {
|
||||||
username = "<" + message.Username + "> "
|
username = "<" + message.Username + "> "
|
||||||
}
|
}
|
||||||
cmd := strings.Fields(message.Text)[0]
|
cmds := strings.Fields(message.Text)
|
||||||
|
// empty message
|
||||||
|
if len(cmds) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
cmd := cmds[0]
|
||||||
switch cmd {
|
switch cmd {
|
||||||
case "!users":
|
case "!users":
|
||||||
flog.mm.Info("received !users from ", message.Username)
|
flog.mm.Info("Received !users from ", message.Username)
|
||||||
b.i.SendRaw("NAMES " + b.getIRCChannel(message.Channel))
|
b.i.SendRaw("NAMES " + b.getIRCChannel(message.Channel))
|
||||||
continue
|
continue
|
||||||
case "!gif":
|
case "!gif":
|
||||||
@ -425,7 +404,7 @@ func (b *Bridge) getMMChannel(ircChannel string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) getIRCChannel(channel string) string {
|
func (b *Bridge) getIRCChannel(channel string) string {
|
||||||
if b.kind == "legacy" {
|
if b.kind == Legacy {
|
||||||
ircchannel := b.Config.IRC.Channel
|
ircchannel := b.Config.IRC.Channel
|
||||||
_, ok := b.Config.Token[channel]
|
_, ok := b.Config.Token[channel]
|
||||||
if ok {
|
if ok {
|
||||||
@ -439,3 +418,17 @@ func (b *Bridge) getIRCChannel(channel string) string {
|
|||||||
}
|
}
|
||||||
return ircchannel
|
return ircchannel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) ignoreMessage(nick string, message string, protocol string) bool {
|
||||||
|
var ignoreNicks = b.mmIgnoreNicks
|
||||||
|
if protocol == "irc" {
|
||||||
|
ignoreNicks = b.ircIgnoreNicks
|
||||||
|
}
|
||||||
|
// should we discard messages ?
|
||||||
|
for _, entry := range ignoreNicks {
|
||||||
|
if nick == entry {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
3
vendor/github.com/42wim/matterbridge-plus/bridge/config.go
generated
vendored
3
vendor/github.com/42wim/matterbridge-plus/bridge/config.go
generated
vendored
@ -19,6 +19,7 @@ type Config struct {
|
|||||||
NickServNick string
|
NickServNick string
|
||||||
NickServPassword string
|
NickServPassword string
|
||||||
RemoteNickFormat string
|
RemoteNickFormat string
|
||||||
|
IgnoreNicks string
|
||||||
}
|
}
|
||||||
Mattermost struct {
|
Mattermost struct {
|
||||||
URL string
|
URL string
|
||||||
@ -37,6 +38,8 @@ type Config struct {
|
|||||||
Login string
|
Login string
|
||||||
Password string
|
Password string
|
||||||
RemoteNickFormat *string
|
RemoteNickFormat *string
|
||||||
|
IgnoreNicks string
|
||||||
|
NoTLS bool
|
||||||
}
|
}
|
||||||
Token map[string]*struct {
|
Token map[string]*struct {
|
||||||
IRCChannel string
|
IRCChannel string
|
||||||
|
155
vendor/github.com/42wim/matterbridge-plus/matterclient/matterclient.go
generated
vendored
155
vendor/github.com/42wim/matterbridge-plus/matterclient/matterclient.go
generated
vendored
@ -1,9 +1,12 @@
|
|||||||
package matterclient
|
package matterclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/cookiejar"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -18,6 +21,7 @@ type Credentials struct {
|
|||||||
Pass string
|
Pass string
|
||||||
Server string
|
Server string
|
||||||
NoTLS bool
|
NoTLS bool
|
||||||
|
SkipTLSVerify bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Message struct {
|
type Message struct {
|
||||||
@ -33,6 +37,8 @@ type MMClient struct {
|
|||||||
*Credentials
|
*Credentials
|
||||||
Client *model.Client
|
Client *model.Client
|
||||||
WsClient *websocket.Conn
|
WsClient *websocket.Conn
|
||||||
|
WsQuit bool
|
||||||
|
WsAway bool
|
||||||
Channels *model.ChannelList
|
Channels *model.ChannelList
|
||||||
MoreChannels *model.ChannelList
|
MoreChannels *model.ChannelList
|
||||||
User *model.User
|
User *model.User
|
||||||
@ -60,6 +66,9 @@ func (m *MMClient) SetLogLevel(level string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *MMClient) Login() error {
|
func (m *MMClient) Login() error {
|
||||||
|
if m.WsQuit {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
b := &backoff.Backoff{
|
b := &backoff.Backoff{
|
||||||
Min: time.Second,
|
Min: time.Second,
|
||||||
Max: 5 * time.Minute,
|
Max: 5 * time.Minute,
|
||||||
@ -73,12 +82,25 @@ func (m *MMClient) Login() error {
|
|||||||
}
|
}
|
||||||
// login to mattermost
|
// login to mattermost
|
||||||
m.Client = model.NewClient(uriScheme + m.Credentials.Server)
|
m.Client = model.NewClient(uriScheme + m.Credentials.Server)
|
||||||
|
m.Client.HttpClient.Transport = &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: m.SkipTLSVerify}}
|
||||||
var myinfo *model.Result
|
var myinfo *model.Result
|
||||||
var appErr *model.AppError
|
var appErr *model.AppError
|
||||||
var logmsg = "trying login"
|
var logmsg = "trying login"
|
||||||
for {
|
for {
|
||||||
m.log.Debugf(logmsg+" %s %s %s", m.Credentials.Team, m.Credentials.Login, m.Credentials.Server)
|
m.log.Debugf("%s %s %s %s", logmsg, m.Credentials.Team, m.Credentials.Login, m.Credentials.Server)
|
||||||
|
if strings.Contains(m.Credentials.Pass, model.SESSION_COOKIE_TOKEN) {
|
||||||
|
m.log.Debugf(logmsg+" with ", model.SESSION_COOKIE_TOKEN)
|
||||||
|
token := strings.Split(m.Credentials.Pass, model.SESSION_COOKIE_TOKEN+"=")
|
||||||
|
m.Client.HttpClient.Jar = m.createCookieJar(token[1])
|
||||||
|
m.Client.MockSession(token[1])
|
||||||
|
myinfo, appErr = m.Client.GetMe("")
|
||||||
|
if myinfo.Data.(*model.User) == nil {
|
||||||
|
m.log.Errorf("LOGIN TOKEN: %s is invalid", m.Credentials.Pass)
|
||||||
|
return errors.New("invalid " + model.SESSION_COOKIE_TOKEN)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
myinfo, appErr = m.Client.Login(m.Credentials.Login, m.Credentials.Pass)
|
myinfo, appErr = m.Client.Login(m.Credentials.Login, m.Credentials.Pass)
|
||||||
|
}
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
d := b.Duration()
|
d := b.Duration()
|
||||||
m.log.Debug(appErr.DetailedError)
|
m.log.Debug(appErr.DetailedError)
|
||||||
@ -89,7 +111,7 @@ func (m *MMClient) Login() error {
|
|||||||
}
|
}
|
||||||
return errors.New(appErr.Message)
|
return errors.New(appErr.Message)
|
||||||
}
|
}
|
||||||
m.log.Debug("LOGIN: %s, reconnecting in %s", appErr, d)
|
m.log.Debugf("LOGIN: %s, reconnecting in %s", appErr, d)
|
||||||
time.Sleep(d)
|
time.Sleep(d)
|
||||||
logmsg = "retrying login"
|
logmsg = "retrying login"
|
||||||
continue
|
continue
|
||||||
@ -98,15 +120,16 @@ func (m *MMClient) Login() error {
|
|||||||
}
|
}
|
||||||
// reset timer
|
// reset timer
|
||||||
b.Reset()
|
b.Reset()
|
||||||
m.User = myinfo.Data.(*model.User)
|
|
||||||
|
|
||||||
teamdata, _ := m.Client.GetAllTeamListings()
|
initLoad, _ := m.Client.GetInitialLoad()
|
||||||
teams := teamdata.Data.(map[string]*model.Team)
|
initData := initLoad.Data.(*model.InitialLoad)
|
||||||
for k, v := range teams {
|
m.User = initData.User
|
||||||
|
for _, v := range initData.Teams {
|
||||||
|
m.log.Debugf("trying %s (id: %s)", v.Name, v.Id)
|
||||||
if v.Name == m.Credentials.Team {
|
if v.Name == m.Credentials.Team {
|
||||||
m.Client.SetTeamId(k)
|
m.Client.SetTeamId(v.Id)
|
||||||
m.Team = v
|
m.Team = v
|
||||||
m.log.Debug("GetallTeamListings: found id ", k)
|
m.log.Debugf("GetallTeamListings: found id %s for team %s", v.Id, v.Name)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,13 +142,14 @@ func (m *MMClient) Login() error {
|
|||||||
header := http.Header{}
|
header := http.Header{}
|
||||||
header.Set(model.HEADER_AUTH, "BEARER "+m.Client.AuthToken)
|
header.Set(model.HEADER_AUTH, "BEARER "+m.Client.AuthToken)
|
||||||
|
|
||||||
var WsClient *websocket.Conn
|
m.log.Debug("WsClient: making connection")
|
||||||
var err error
|
var err error
|
||||||
for {
|
for {
|
||||||
WsClient, _, err = websocket.DefaultDialer.Dial(wsurl, header)
|
wsDialer := &websocket.Dialer{Proxy: http.ProxyFromEnvironment, TLSClientConfig: &tls.Config{InsecureSkipVerify: m.SkipTLSVerify}}
|
||||||
|
m.WsClient, _, err = wsDialer.Dial(wsurl, header)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d := b.Duration()
|
d := b.Duration()
|
||||||
log.Printf("WSS: %s, reconnecting in %s", err, d)
|
m.log.Debugf("WSS: %s, reconnecting in %s", err, d)
|
||||||
time.Sleep(d)
|
time.Sleep(d)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -133,8 +157,6 @@ func (m *MMClient) Login() error {
|
|||||||
}
|
}
|
||||||
b.Reset()
|
b.Reset()
|
||||||
|
|
||||||
m.WsClient = WsClient
|
|
||||||
|
|
||||||
// populating users
|
// populating users
|
||||||
m.UpdateUsers()
|
m.UpdateUsers()
|
||||||
|
|
||||||
@ -147,12 +169,19 @@ func (m *MMClient) Login() error {
|
|||||||
func (m *MMClient) WsReceiver() {
|
func (m *MMClient) WsReceiver() {
|
||||||
var rmsg model.Message
|
var rmsg model.Message
|
||||||
for {
|
for {
|
||||||
|
if m.WsQuit {
|
||||||
|
m.log.Debug("exiting WsReceiver")
|
||||||
|
return
|
||||||
|
}
|
||||||
if err := m.WsClient.ReadJSON(&rmsg); err != nil {
|
if err := m.WsClient.ReadJSON(&rmsg); err != nil {
|
||||||
log.Println("error:", err)
|
m.log.Error("error:", err)
|
||||||
// reconnect
|
// reconnect
|
||||||
m.Login()
|
m.Login()
|
||||||
}
|
}
|
||||||
//log.Printf("WsReceiver: %#v", rmsg)
|
if rmsg.Action == "ping" {
|
||||||
|
m.handleWsPing()
|
||||||
|
continue
|
||||||
|
}
|
||||||
msg := &Message{Raw: &rmsg, Team: m.Credentials.Team}
|
msg := &Message{Raw: &rmsg, Team: m.Credentials.Team}
|
||||||
m.parseMessage(msg)
|
m.parseMessage(msg)
|
||||||
m.MessageChan <- msg
|
m.MessageChan <- msg
|
||||||
@ -160,6 +189,14 @@ func (m *MMClient) WsReceiver() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) handleWsPing() {
|
||||||
|
m.log.Debug("Ws PING")
|
||||||
|
if !m.WsQuit && !m.WsAway {
|
||||||
|
m.log.Debug("Ws PONG")
|
||||||
|
m.WsClient.WriteMessage(websocket.PongMessage, []byte{})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MMClient) parseMessage(rmsg *Message) {
|
func (m *MMClient) parseMessage(rmsg *Message) {
|
||||||
switch rmsg.Raw.Action {
|
switch rmsg.Raw.Action {
|
||||||
case model.ACTION_POSTED:
|
case model.ACTION_POSTED:
|
||||||
@ -198,7 +235,7 @@ func (m *MMClient) parseActionPost(rmsg *Message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *MMClient) UpdateUsers() error {
|
func (m *MMClient) UpdateUsers() error {
|
||||||
mmusers, _ := m.Client.GetProfiles(m.Client.GetTeamId(), "")
|
mmusers, _ := m.Client.GetProfilesForDirectMessageList(m.Team.Id)
|
||||||
m.Users = mmusers.Data.(map[string]*model.User)
|
m.Users = mmusers.Data.(map[string]*model.User)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -294,29 +331,49 @@ func (m *MMClient) GetPosts(channelId string, limit int) *model.PostList {
|
|||||||
return res.Data.(*model.PostList)
|
return res.Data.(*model.PostList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) GetPublicLink(filename string) string {
|
||||||
|
res, err := m.Client.GetPublicLink(filename)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return res.Data.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) GetPublicLinks(filenames []string) []string {
|
||||||
|
var output []string
|
||||||
|
for _, f := range filenames {
|
||||||
|
res, err := m.Client.GetPublicLink(f)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
output = append(output, res.Data.(string))
|
||||||
|
}
|
||||||
|
return output
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MMClient) UpdateChannelHeader(channelId string, header string) {
|
func (m *MMClient) UpdateChannelHeader(channelId string, header string) {
|
||||||
data := make(map[string]string)
|
data := make(map[string]string)
|
||||||
data["channel_id"] = channelId
|
data["channel_id"] = channelId
|
||||||
data["channel_header"] = header
|
data["channel_header"] = header
|
||||||
log.Printf("updating channelheader %#v, %#v", channelId, header)
|
m.log.Debugf("updating channelheader %#v, %#v", channelId, header)
|
||||||
_, err := m.Client.UpdateChannelHeader(data)
|
_, err := m.Client.UpdateChannelHeader(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MMClient) UpdateLastViewed(channelId string) {
|
func (m *MMClient) UpdateLastViewed(channelId string) {
|
||||||
log.Printf("posting lastview %#v", channelId)
|
m.log.Debugf("posting lastview %#v", channelId)
|
||||||
_, err := m.Client.UpdateLastViewedAt(channelId)
|
_, err := m.Client.UpdateLastViewedAt(channelId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
m.log.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MMClient) UsernamesInChannel(channelName string) []string {
|
func (m *MMClient) UsernamesInChannel(channelName string) []string {
|
||||||
ceiRes, err := m.Client.GetChannelExtraInfo(m.GetChannelId(channelName), 5000, "")
|
ceiRes, err := m.Client.GetChannelExtraInfo(m.GetChannelId(channelName), 5000, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("UsernamesInChannel(%s) failed: %s", channelName, err)
|
m.log.Errorf("UsernamesInChannel(%s) failed: %s", channelName, err)
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
extra := ceiRes.Data.(*model.ChannelExtra)
|
extra := ceiRes.Data.(*model.ChannelExtra)
|
||||||
@ -326,3 +383,59 @@ func (m *MMClient) UsernamesInChannel(channelName string) []string {
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) createCookieJar(token string) *cookiejar.Jar {
|
||||||
|
var cookies []*http.Cookie
|
||||||
|
jar, _ := cookiejar.New(nil)
|
||||||
|
firstCookie := &http.Cookie{
|
||||||
|
Name: "MMAUTHTOKEN",
|
||||||
|
Value: token,
|
||||||
|
Path: "/",
|
||||||
|
Domain: m.Credentials.Server,
|
||||||
|
}
|
||||||
|
cookies = append(cookies, firstCookie)
|
||||||
|
cookieURL, _ := url.Parse("https://" + m.Credentials.Server)
|
||||||
|
jar.SetCookies(cookieURL, cookies)
|
||||||
|
return jar
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) GetOtherUserDM(channel string) *model.User {
|
||||||
|
m.UpdateUsers()
|
||||||
|
var rcvuser *model.User
|
||||||
|
if strings.Contains(channel, "__") {
|
||||||
|
rcvusers := strings.Split(channel, "__")
|
||||||
|
if rcvusers[0] != m.User.Id {
|
||||||
|
rcvuser = m.Users[rcvusers[0]]
|
||||||
|
} else {
|
||||||
|
rcvuser = m.Users[rcvusers[1]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rcvuser
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) SendDirectMessage(toUserId string, msg string) {
|
||||||
|
m.log.Debugf("SendDirectMessage to %s, msg %s", toUserId, msg)
|
||||||
|
var channel string
|
||||||
|
// We don't have a DM with this user yet.
|
||||||
|
if m.GetChannelId(toUserId+"__"+m.User.Id) == "" && m.GetChannelId(m.User.Id+"__"+toUserId) == "" {
|
||||||
|
// create DM channel
|
||||||
|
_, err := m.Client.CreateDirectChannel(toUserId)
|
||||||
|
if err != nil {
|
||||||
|
m.log.Debugf("SendDirectMessage to %#v failed: %s", toUserId, err)
|
||||||
|
}
|
||||||
|
// update our channels
|
||||||
|
mmchannels, _ := m.Client.GetChannels("")
|
||||||
|
m.Channels = mmchannels.Data.(*model.ChannelList)
|
||||||
|
}
|
||||||
|
|
||||||
|
// build the channel name
|
||||||
|
if toUserId > m.User.Id {
|
||||||
|
channel = m.User.Id + "__" + toUserId
|
||||||
|
} else {
|
||||||
|
channel = toUserId + "__" + m.User.Id
|
||||||
|
}
|
||||||
|
// build & send the message
|
||||||
|
msg = strings.Replace(msg, "\r", "", -1)
|
||||||
|
post := &model.Post{ChannelId: m.GetChannelId(channel), Message: msg}
|
||||||
|
m.Client.CreatePost(post)
|
||||||
|
}
|
||||||
|
202
vendor/github.com/42wim/matterbridge/matterhook/LICENSE
generated
vendored
202
vendor/github.com/42wim/matterbridge/matterhook/LICENSE
generated
vendored
@ -1,202 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright {yyyy} {name of copyright owner}
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
154
vendor/github.com/42wim/matterbridge/matterhook/matterhook.go
generated
vendored
154
vendor/github.com/42wim/matterbridge/matterhook/matterhook.go
generated
vendored
@ -1,154 +0,0 @@
|
|||||||
//Package matterhook provides interaction with mattermost incoming/outgoing webhooks
|
|
||||||
package matterhook
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"crypto/tls"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"github.com/gorilla/schema"
|
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
)
|
|
||||||
|
|
||||||
// OMessage for mattermost incoming webhook. (send to mattermost)
|
|
||||||
type OMessage struct {
|
|
||||||
Channel string `json:"channel,omitempty"`
|
|
||||||
IconURL string `json:"icon_url,omitempty"`
|
|
||||||
IconEmoji string `json:"icon_emoji,omitempty"`
|
|
||||||
UserName string `json:"username,omitempty"`
|
|
||||||
Text string `json:"text"`
|
|
||||||
Attachments interface{} `json:"attachments,omitempty"`
|
|
||||||
Type string `json:"type,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// IMessage for mattermost outgoing webhook. (received from mattermost)
|
|
||||||
type IMessage struct {
|
|
||||||
Token string `schema:"token"`
|
|
||||||
TeamID string `schema:"team_id"`
|
|
||||||
TeamDomain string `schema:"team_domain"`
|
|
||||||
ChannelID string `schema:"channel_id"`
|
|
||||||
ServiceID string `schema:"service_id"`
|
|
||||||
ChannelName string `schema:"channel_name"`
|
|
||||||
Timestamp string `schema:"timestamp"`
|
|
||||||
UserID string `schema:"user_id"`
|
|
||||||
UserName string `schema:"user_name"`
|
|
||||||
Text string `schema:"text"`
|
|
||||||
TriggerWord string `schema:"trigger_word"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Client for Mattermost.
|
|
||||||
type Client struct {
|
|
||||||
Url string // URL for incoming webhooks on mattermost.
|
|
||||||
In chan IMessage
|
|
||||||
Out chan OMessage
|
|
||||||
httpclient *http.Client
|
|
||||||
Config
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
c.BindAddress += ":"
|
|
||||||
tr := &http.Transport{
|
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify},
|
|
||||||
}
|
|
||||||
c.httpclient = &http.Client{Transport: tr}
|
|
||||||
if !c.DisableServer {
|
|
||||||
go c.StartServer()
|
|
||||||
}
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
// StartServer starts a webserver listening for incoming mattermost POSTS.
|
|
||||||
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.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServeHTTP implementation.
|
|
||||||
func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
||||||
if r.Method != "POST" {
|
|
||||||
log.Println("invalid " + r.Method + " connection from " + r.RemoteAddr)
|
|
||||||
http.NotFound(w, r)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
msg := IMessage{}
|
|
||||||
err := r.ParseForm()
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
http.NotFound(w, r)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer r.Body.Close()
|
|
||||||
decoder := schema.NewDecoder()
|
|
||||||
err = decoder.Decode(&msg, r.PostForm)
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
http.NotFound(w, r)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if msg.Token == "" {
|
|
||||||
log.Println("no token from " + r.RemoteAddr)
|
|
||||||
http.NotFound(w, r)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if c.Token != "" {
|
|
||||||
if msg.Token != c.Token {
|
|
||||||
log.Println("invalid token " + msg.Token + " from " + r.RemoteAddr)
|
|
||||||
http.NotFound(w, r)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c.In <- msg
|
|
||||||
}
|
|
||||||
|
|
||||||
// Receive returns an incoming message from mattermost outgoing webhooks URL.
|
|
||||||
func (c *Client) Receive() IMessage {
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case msg := <-c.In:
|
|
||||||
return msg
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send sends a msg to mattermost incoming webhooks URL.
|
|
||||||
func (c *Client) Send(msg OMessage) error {
|
|
||||||
buf, err := json.Marshal(msg)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
resp, err := c.httpclient.Post(c.Url, "application/json", bytes.NewReader(buf))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
// Read entire body to completion to re-use keep-alive connections.
|
|
||||||
io.Copy(ioutil.Discard, resp.Body)
|
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
|
||||||
return fmt.Errorf("unexpected status code: %d", resp.StatusCode)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
22
vendor/github.com/mattermost/platform/einterfaces/emoji.go
generated
vendored
Normal file
22
vendor/github.com/mattermost/platform/einterfaces/emoji.go
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See License.txt for license information.
|
||||||
|
|
||||||
|
package einterfaces
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/mattermost/platform/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type EmojiInterface interface {
|
||||||
|
CanUserCreateEmoji(string, []*model.TeamMember) bool
|
||||||
|
}
|
||||||
|
|
||||||
|
var theEmojiInterface EmojiInterface
|
||||||
|
|
||||||
|
func RegisterEmojiInterface(newInterface EmojiInterface) {
|
||||||
|
theEmojiInterface = newInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetEmojiInterface() EmojiInterface {
|
||||||
|
return theEmojiInterface
|
||||||
|
}
|
2
vendor/github.com/mattermost/platform/einterfaces/ldap.go
generated
vendored
2
vendor/github.com/mattermost/platform/einterfaces/ldap.go
generated
vendored
@ -13,6 +13,8 @@ type LdapInterface interface {
|
|||||||
CheckPassword(id string, password string) *model.AppError
|
CheckPassword(id string, password string) *model.AppError
|
||||||
SwitchToLdap(userId, ldapId, ldapPassword string) *model.AppError
|
SwitchToLdap(userId, ldapId, ldapPassword string) *model.AppError
|
||||||
ValidateFilter(filter string) *model.AppError
|
ValidateFilter(filter string) *model.AppError
|
||||||
|
Syncronize() *model.AppError
|
||||||
|
StartLdapSyncJob()
|
||||||
}
|
}
|
||||||
|
|
||||||
var theLdapInterface LdapInterface
|
var theLdapInterface LdapInterface
|
||||||
|
25
vendor/github.com/mattermost/platform/einterfaces/saml.go
generated
vendored
Normal file
25
vendor/github.com/mattermost/platform/einterfaces/saml.go
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See License.txt for license information.
|
||||||
|
|
||||||
|
package einterfaces
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/mattermost/platform/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SamlInterface interface {
|
||||||
|
ConfigureSP() *model.AppError
|
||||||
|
BuildRequest(relayState string) (*model.SamlAuthRequest, *model.AppError)
|
||||||
|
DoLogin(encodedXML string, relayState map[string]string) (*model.User, *model.AppError)
|
||||||
|
GetMetadata() (string, *model.AppError)
|
||||||
|
}
|
||||||
|
|
||||||
|
var theSamlInterface SamlInterface
|
||||||
|
|
||||||
|
func RegisterSamlInterface(newInterface SamlInterface) {
|
||||||
|
theSamlInterface = newInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSamlInterface() SamlInterface {
|
||||||
|
return theSamlInterface
|
||||||
|
}
|
377
vendor/github.com/mattermost/platform/model/client.go
generated
vendored
377
vendor/github.com/mattermost/platform/model/client.go
generated
vendored
File diff suppressed because it is too large
Load Diff
5
vendor/github.com/mattermost/platform/model/command.go
generated
vendored
5
vendor/github.com/mattermost/platform/model/command.go
generated
vendored
@ -6,11 +6,14 @@ package model
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
COMMAND_METHOD_POST = "P"
|
COMMAND_METHOD_POST = "P"
|
||||||
COMMAND_METHOD_GET = "G"
|
COMMAND_METHOD_GET = "G"
|
||||||
|
MIN_TRIGGER_LENGTH = 1
|
||||||
|
MAX_TRIGGER_LENGTH = 128
|
||||||
)
|
)
|
||||||
|
|
||||||
type Command struct {
|
type Command struct {
|
||||||
@ -99,7 +102,7 @@ func (o *Command) IsValid() *AppError {
|
|||||||
return NewLocAppError("Command.IsValid", "model.command.is_valid.team_id.app_error", nil, "")
|
return NewLocAppError("Command.IsValid", "model.command.is_valid.team_id.app_error", nil, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(o.Trigger) == 0 || len(o.Trigger) > 128 {
|
if len(o.Trigger) < MIN_TRIGGER_LENGTH || len(o.Trigger) > MAX_TRIGGER_LENGTH || strings.Index(o.Trigger, "/") == 0 || strings.Contains(o.Trigger, " ") {
|
||||||
return NewLocAppError("Command.IsValid", "model.command.is_valid.trigger.app_error", nil, "")
|
return NewLocAppError("Command.IsValid", "model.command.is_valid.trigger.app_error", nil, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
395
vendor/github.com/mattermost/platform/model/config.go
generated
vendored
395
vendor/github.com/mattermost/platform/model/config.go
generated
vendored
@ -19,6 +19,9 @@ const (
|
|||||||
DATABASE_DRIVER_MYSQL = "mysql"
|
DATABASE_DRIVER_MYSQL = "mysql"
|
||||||
DATABASE_DRIVER_POSTGRES = "postgres"
|
DATABASE_DRIVER_POSTGRES = "postgres"
|
||||||
|
|
||||||
|
PASSWORD_MAXIMUM_LENGTH = 64
|
||||||
|
PASSWORD_MINIMUM_LENGTH = 5
|
||||||
|
|
||||||
SERVICE_GITLAB = "gitlab"
|
SERVICE_GITLAB = "gitlab"
|
||||||
SERVICE_GOOGLE = "google"
|
SERVICE_GOOGLE = "google"
|
||||||
|
|
||||||
@ -32,7 +35,15 @@ const (
|
|||||||
DIRECT_MESSAGE_ANY = "any"
|
DIRECT_MESSAGE_ANY = "any"
|
||||||
DIRECT_MESSAGE_TEAM = "team"
|
DIRECT_MESSAGE_TEAM = "team"
|
||||||
|
|
||||||
|
PERMISSIONS_ALL = "all"
|
||||||
|
PERMISSIONS_TEAM_ADMIN = "team_admin"
|
||||||
|
PERMISSIONS_SYSTEM_ADMIN = "system_admin"
|
||||||
|
|
||||||
FAKE_SETTING = "********************************"
|
FAKE_SETTING = "********************************"
|
||||||
|
|
||||||
|
RESTRICT_EMOJI_CREATION_ALL = "all"
|
||||||
|
RESTRICT_EMOJI_CREATION_ADMIN = "admin"
|
||||||
|
RESTRICT_EMOJI_CREATION_SYSTEM_ADMIN = "system_admin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ServiceSettings struct {
|
type ServiceSettings struct {
|
||||||
@ -60,6 +71,8 @@ type ServiceSettings struct {
|
|||||||
WebsocketSecurePort *int
|
WebsocketSecurePort *int
|
||||||
WebsocketPort *int
|
WebsocketPort *int
|
||||||
WebserverMode *string
|
WebserverMode *string
|
||||||
|
EnableCustomEmoji *bool
|
||||||
|
RestrictCustomEmojiCreation *string
|
||||||
}
|
}
|
||||||
|
|
||||||
type SSOSettings struct {
|
type SSOSettings struct {
|
||||||
@ -89,9 +102,19 @@ type LogSettings struct {
|
|||||||
FileLevel string
|
FileLevel string
|
||||||
FileFormat string
|
FileFormat string
|
||||||
FileLocation string
|
FileLocation string
|
||||||
|
EnableWebhookDebugging bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type PasswordSettings struct {
|
||||||
|
MinimumLength *int
|
||||||
|
Lowercase *bool
|
||||||
|
Number *bool
|
||||||
|
Uppercase *bool
|
||||||
|
Symbol *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileSettings struct {
|
type FileSettings struct {
|
||||||
|
MaxFileSize *int64
|
||||||
DriverName string
|
DriverName string
|
||||||
Directory string
|
Directory string
|
||||||
EnablePublicLink bool
|
EnablePublicLink bool
|
||||||
@ -121,6 +144,7 @@ type EmailSettings struct {
|
|||||||
RequireEmailVerification bool
|
RequireEmailVerification bool
|
||||||
FeedbackName string
|
FeedbackName string
|
||||||
FeedbackEmail string
|
FeedbackEmail string
|
||||||
|
FeedbackOrganization *string
|
||||||
SMTPUsername string
|
SMTPUsername string
|
||||||
SMTPPassword string
|
SMTPPassword string
|
||||||
SMTPServer string
|
SMTPServer string
|
||||||
@ -166,6 +190,9 @@ type TeamSettings struct {
|
|||||||
EnableCustomBrand *bool
|
EnableCustomBrand *bool
|
||||||
CustomBrandText *string
|
CustomBrandText *string
|
||||||
RestrictDirectMessage *string
|
RestrictDirectMessage *string
|
||||||
|
RestrictTeamInvite *string
|
||||||
|
RestrictPublicChannelManagement *string
|
||||||
|
RestrictPrivateChannelManagement *string
|
||||||
}
|
}
|
||||||
|
|
||||||
type LdapSettings struct {
|
type LdapSettings struct {
|
||||||
@ -189,9 +216,13 @@ type LdapSettings struct {
|
|||||||
NicknameAttribute *string
|
NicknameAttribute *string
|
||||||
IdAttribute *string
|
IdAttribute *string
|
||||||
|
|
||||||
|
// Syncronization
|
||||||
|
SyncIntervalMinutes *int
|
||||||
|
|
||||||
// Advanced
|
// Advanced
|
||||||
SkipCertificateVerification *bool
|
SkipCertificateVerification *bool
|
||||||
QueryTimeout *int
|
QueryTimeout *int
|
||||||
|
MaxPageSize *int
|
||||||
|
|
||||||
// Customization
|
// Customization
|
||||||
LoginFieldName *string
|
LoginFieldName *string
|
||||||
@ -203,11 +234,43 @@ type ComplianceSettings struct {
|
|||||||
EnableDaily *bool
|
EnableDaily *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LocalizationSettings struct {
|
||||||
|
DefaultServerLocale *string
|
||||||
|
DefaultClientLocale *string
|
||||||
|
AvailableLocales *string
|
||||||
|
}
|
||||||
|
|
||||||
|
type SamlSettings struct {
|
||||||
|
// Basic
|
||||||
|
Enable *bool
|
||||||
|
Verify *bool
|
||||||
|
Encrypt *bool
|
||||||
|
|
||||||
|
IdpUrl *string
|
||||||
|
IdpDescriptorUrl *string
|
||||||
|
AssertionConsumerServiceURL *string
|
||||||
|
|
||||||
|
IdpCertificateFile *string
|
||||||
|
PublicCertificateFile *string
|
||||||
|
PrivateKeyFile *string
|
||||||
|
|
||||||
|
// User Mapping
|
||||||
|
FirstNameAttribute *string
|
||||||
|
LastNameAttribute *string
|
||||||
|
EmailAttribute *string
|
||||||
|
UsernameAttribute *string
|
||||||
|
NicknameAttribute *string
|
||||||
|
LocaleAttribute *string
|
||||||
|
|
||||||
|
LoginButtonText *string
|
||||||
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
ServiceSettings ServiceSettings
|
ServiceSettings ServiceSettings
|
||||||
TeamSettings TeamSettings
|
TeamSettings TeamSettings
|
||||||
SqlSettings SqlSettings
|
SqlSettings SqlSettings
|
||||||
LogSettings LogSettings
|
LogSettings LogSettings
|
||||||
|
PasswordSettings PasswordSettings
|
||||||
FileSettings FileSettings
|
FileSettings FileSettings
|
||||||
EmailSettings EmailSettings
|
EmailSettings EmailSettings
|
||||||
RateLimitSettings RateLimitSettings
|
RateLimitSettings RateLimitSettings
|
||||||
@ -217,6 +280,8 @@ type Config struct {
|
|||||||
GoogleSettings SSOSettings
|
GoogleSettings SSOSettings
|
||||||
LdapSettings LdapSettings
|
LdapSettings LdapSettings
|
||||||
ComplianceSettings ComplianceSettings
|
ComplianceSettings ComplianceSettings
|
||||||
|
LocalizationSettings LocalizationSettings
|
||||||
|
SamlSettings SamlSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Config) ToJson() string {
|
func (o *Config) ToJson() string {
|
||||||
@ -256,6 +321,11 @@ func (o *Config) SetDefaults() {
|
|||||||
o.SqlSettings.AtRestEncryptKey = NewRandomString(32)
|
o.SqlSettings.AtRestEncryptKey = NewRandomString(32)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if o.FileSettings.MaxFileSize == nil {
|
||||||
|
o.FileSettings.MaxFileSize = new(int64)
|
||||||
|
*o.FileSettings.MaxFileSize = 52428800 // 50 MB
|
||||||
|
}
|
||||||
|
|
||||||
if len(o.FileSettings.PublicLinkSalt) == 0 {
|
if len(o.FileSettings.PublicLinkSalt) == 0 {
|
||||||
o.FileSettings.PublicLinkSalt = NewRandomString(32)
|
o.FileSettings.PublicLinkSalt = NewRandomString(32)
|
||||||
}
|
}
|
||||||
@ -298,6 +368,31 @@ func (o *Config) SetDefaults() {
|
|||||||
*o.ServiceSettings.EnableMultifactorAuthentication = false
|
*o.ServiceSettings.EnableMultifactorAuthentication = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if o.PasswordSettings.MinimumLength == nil {
|
||||||
|
o.PasswordSettings.MinimumLength = new(int)
|
||||||
|
*o.PasswordSettings.MinimumLength = PASSWORD_MINIMUM_LENGTH
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.PasswordSettings.Lowercase == nil {
|
||||||
|
o.PasswordSettings.Lowercase = new(bool)
|
||||||
|
*o.PasswordSettings.Lowercase = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.PasswordSettings.Number == nil {
|
||||||
|
o.PasswordSettings.Number = new(bool)
|
||||||
|
*o.PasswordSettings.Number = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.PasswordSettings.Uppercase == nil {
|
||||||
|
o.PasswordSettings.Uppercase = new(bool)
|
||||||
|
*o.PasswordSettings.Uppercase = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.PasswordSettings.Symbol == nil {
|
||||||
|
o.PasswordSettings.Symbol = new(bool)
|
||||||
|
*o.PasswordSettings.Symbol = false
|
||||||
|
}
|
||||||
|
|
||||||
if o.TeamSettings.RestrictTeamNames == nil {
|
if o.TeamSettings.RestrictTeamNames == nil {
|
||||||
o.TeamSettings.RestrictTeamNames = new(bool)
|
o.TeamSettings.RestrictTeamNames = new(bool)
|
||||||
*o.TeamSettings.RestrictTeamNames = true
|
*o.TeamSettings.RestrictTeamNames = true
|
||||||
@ -323,6 +418,21 @@ func (o *Config) SetDefaults() {
|
|||||||
*o.TeamSettings.RestrictDirectMessage = DIRECT_MESSAGE_ANY
|
*o.TeamSettings.RestrictDirectMessage = DIRECT_MESSAGE_ANY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if o.TeamSettings.RestrictTeamInvite == nil {
|
||||||
|
o.TeamSettings.RestrictTeamInvite = new(string)
|
||||||
|
*o.TeamSettings.RestrictTeamInvite = PERMISSIONS_ALL
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.TeamSettings.RestrictPublicChannelManagement == nil {
|
||||||
|
o.TeamSettings.RestrictPublicChannelManagement = new(string)
|
||||||
|
*o.TeamSettings.RestrictPublicChannelManagement = PERMISSIONS_ALL
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.TeamSettings.RestrictPrivateChannelManagement == nil {
|
||||||
|
o.TeamSettings.RestrictPrivateChannelManagement = new(string)
|
||||||
|
*o.TeamSettings.RestrictPrivateChannelManagement = PERMISSIONS_ALL
|
||||||
|
}
|
||||||
|
|
||||||
if o.EmailSettings.EnableSignInWithEmail == nil {
|
if o.EmailSettings.EnableSignInWithEmail == nil {
|
||||||
o.EmailSettings.EnableSignInWithEmail = new(bool)
|
o.EmailSettings.EnableSignInWithEmail = new(bool)
|
||||||
|
|
||||||
@ -353,6 +463,11 @@ func (o *Config) SetDefaults() {
|
|||||||
*o.EmailSettings.PushNotificationContents = GENERIC_NOTIFICATION
|
*o.EmailSettings.PushNotificationContents = GENERIC_NOTIFICATION
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if o.EmailSettings.FeedbackOrganization == nil {
|
||||||
|
o.EmailSettings.FeedbackOrganization = new(string)
|
||||||
|
*o.EmailSettings.FeedbackOrganization = ""
|
||||||
|
}
|
||||||
|
|
||||||
if !IsSafeLink(o.SupportSettings.TermsOfServiceLink) {
|
if !IsSafeLink(o.SupportSettings.TermsOfServiceLink) {
|
||||||
o.SupportSettings.TermsOfServiceLink = nil
|
o.SupportSettings.TermsOfServiceLink = nil
|
||||||
}
|
}
|
||||||
@ -403,24 +518,94 @@ func (o *Config) SetDefaults() {
|
|||||||
*o.SupportSettings.SupportEmail = "feedback@mattermost.com"
|
*o.SupportSettings.SupportEmail = "feedback@mattermost.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if o.LdapSettings.Enable == nil {
|
||||||
|
o.LdapSettings.Enable = new(bool)
|
||||||
|
*o.LdapSettings.Enable = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.LdapSettings.LdapServer == nil {
|
||||||
|
o.LdapSettings.LdapServer = new(string)
|
||||||
|
*o.LdapSettings.LdapServer = ""
|
||||||
|
}
|
||||||
|
|
||||||
if o.LdapSettings.LdapPort == nil {
|
if o.LdapSettings.LdapPort == nil {
|
||||||
o.LdapSettings.LdapPort = new(int)
|
o.LdapSettings.LdapPort = new(int)
|
||||||
*o.LdapSettings.LdapPort = 389
|
*o.LdapSettings.LdapPort = 389
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if o.LdapSettings.ConnectionSecurity == nil {
|
||||||
|
o.LdapSettings.ConnectionSecurity = new(string)
|
||||||
|
*o.LdapSettings.ConnectionSecurity = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.LdapSettings.BaseDN == nil {
|
||||||
|
o.LdapSettings.BaseDN = new(string)
|
||||||
|
*o.LdapSettings.BaseDN = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.LdapSettings.BindUsername == nil {
|
||||||
|
o.LdapSettings.BindUsername = new(string)
|
||||||
|
*o.LdapSettings.BindUsername = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.LdapSettings.BindPassword == nil {
|
||||||
|
o.LdapSettings.BindPassword = new(string)
|
||||||
|
*o.LdapSettings.BindPassword = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.LdapSettings.UserFilter == nil {
|
||||||
|
o.LdapSettings.UserFilter = new(string)
|
||||||
|
*o.LdapSettings.UserFilter = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.LdapSettings.FirstNameAttribute == nil {
|
||||||
|
o.LdapSettings.FirstNameAttribute = new(string)
|
||||||
|
*o.LdapSettings.FirstNameAttribute = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.LdapSettings.LastNameAttribute == nil {
|
||||||
|
o.LdapSettings.LastNameAttribute = new(string)
|
||||||
|
*o.LdapSettings.LastNameAttribute = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.LdapSettings.EmailAttribute == nil {
|
||||||
|
o.LdapSettings.EmailAttribute = new(string)
|
||||||
|
*o.LdapSettings.EmailAttribute = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.LdapSettings.UsernameAttribute == nil {
|
||||||
|
o.LdapSettings.UsernameAttribute = new(string)
|
||||||
|
*o.LdapSettings.UsernameAttribute = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.LdapSettings.NicknameAttribute == nil {
|
||||||
|
o.LdapSettings.NicknameAttribute = new(string)
|
||||||
|
*o.LdapSettings.NicknameAttribute = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.LdapSettings.IdAttribute == nil {
|
||||||
|
o.LdapSettings.IdAttribute = new(string)
|
||||||
|
*o.LdapSettings.IdAttribute = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.LdapSettings.SyncIntervalMinutes == nil {
|
||||||
|
o.LdapSettings.SyncIntervalMinutes = new(int)
|
||||||
|
*o.LdapSettings.SyncIntervalMinutes = 60
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.LdapSettings.SkipCertificateVerification == nil {
|
||||||
|
o.LdapSettings.SkipCertificateVerification = new(bool)
|
||||||
|
*o.LdapSettings.SkipCertificateVerification = false
|
||||||
|
}
|
||||||
|
|
||||||
if o.LdapSettings.QueryTimeout == nil {
|
if o.LdapSettings.QueryTimeout == nil {
|
||||||
o.LdapSettings.QueryTimeout = new(int)
|
o.LdapSettings.QueryTimeout = new(int)
|
||||||
*o.LdapSettings.QueryTimeout = 60
|
*o.LdapSettings.QueryTimeout = 60
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.LdapSettings.Enable == nil {
|
if o.LdapSettings.MaxPageSize == nil {
|
||||||
o.LdapSettings.Enable = new(bool)
|
o.LdapSettings.MaxPageSize = new(int)
|
||||||
*o.LdapSettings.Enable = false
|
*o.LdapSettings.MaxPageSize = 0
|
||||||
}
|
|
||||||
|
|
||||||
if o.LdapSettings.UserFilter == nil {
|
|
||||||
o.LdapSettings.UserFilter = new(string)
|
|
||||||
*o.LdapSettings.UserFilter = ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.LdapSettings.LoginFieldName == nil {
|
if o.LdapSettings.LoginFieldName == nil {
|
||||||
@ -475,7 +660,19 @@ func (o *Config) SetDefaults() {
|
|||||||
|
|
||||||
if o.ServiceSettings.WebserverMode == nil {
|
if o.ServiceSettings.WebserverMode == nil {
|
||||||
o.ServiceSettings.WebserverMode = new(string)
|
o.ServiceSettings.WebserverMode = new(string)
|
||||||
*o.ServiceSettings.WebserverMode = "regular"
|
*o.ServiceSettings.WebserverMode = "gzip"
|
||||||
|
} else if *o.ServiceSettings.WebserverMode == "regular" {
|
||||||
|
*o.ServiceSettings.WebserverMode = "gzip"
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.ServiceSettings.EnableCustomEmoji == nil {
|
||||||
|
o.ServiceSettings.EnableCustomEmoji = new(bool)
|
||||||
|
*o.ServiceSettings.EnableCustomEmoji = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.ServiceSettings.RestrictCustomEmojiCreation == nil {
|
||||||
|
o.ServiceSettings.RestrictCustomEmojiCreation = new(string)
|
||||||
|
*o.ServiceSettings.RestrictCustomEmojiCreation = RESTRICT_EMOJI_CREATION_ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.ComplianceSettings.Enable == nil {
|
if o.ComplianceSettings.Enable == nil {
|
||||||
@ -493,19 +690,99 @@ func (o *Config) SetDefaults() {
|
|||||||
*o.ComplianceSettings.EnableDaily = false
|
*o.ComplianceSettings.EnableDaily = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.LdapSettings.ConnectionSecurity == nil {
|
if o.LocalizationSettings.DefaultServerLocale == nil {
|
||||||
o.LdapSettings.ConnectionSecurity = new(string)
|
o.LocalizationSettings.DefaultServerLocale = new(string)
|
||||||
*o.LdapSettings.ConnectionSecurity = ""
|
*o.LocalizationSettings.DefaultServerLocale = DEFAULT_LOCALE
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.LdapSettings.SkipCertificateVerification == nil {
|
if o.LocalizationSettings.DefaultClientLocale == nil {
|
||||||
o.LdapSettings.SkipCertificateVerification = new(bool)
|
o.LocalizationSettings.DefaultClientLocale = new(string)
|
||||||
*o.LdapSettings.SkipCertificateVerification = false
|
*o.LocalizationSettings.DefaultClientLocale = DEFAULT_LOCALE
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.LdapSettings.NicknameAttribute == nil {
|
if o.LocalizationSettings.AvailableLocales == nil {
|
||||||
o.LdapSettings.NicknameAttribute = new(string)
|
o.LocalizationSettings.AvailableLocales = new(string)
|
||||||
*o.LdapSettings.NicknameAttribute = ""
|
*o.LocalizationSettings.AvailableLocales = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.Enable == nil {
|
||||||
|
o.SamlSettings.Enable = new(bool)
|
||||||
|
*o.SamlSettings.Enable = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.Verify == nil {
|
||||||
|
o.SamlSettings.Verify = new(bool)
|
||||||
|
*o.SamlSettings.Verify = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.Encrypt == nil {
|
||||||
|
o.SamlSettings.Encrypt = new(bool)
|
||||||
|
*o.SamlSettings.Encrypt = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.IdpUrl == nil {
|
||||||
|
o.SamlSettings.IdpUrl = new(string)
|
||||||
|
*o.SamlSettings.IdpUrl = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.IdpDescriptorUrl == nil {
|
||||||
|
o.SamlSettings.IdpDescriptorUrl = new(string)
|
||||||
|
*o.SamlSettings.IdpDescriptorUrl = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.IdpCertificateFile == nil {
|
||||||
|
o.SamlSettings.IdpCertificateFile = new(string)
|
||||||
|
*o.SamlSettings.IdpCertificateFile = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.PublicCertificateFile == nil {
|
||||||
|
o.SamlSettings.PublicCertificateFile = new(string)
|
||||||
|
*o.SamlSettings.PublicCertificateFile = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.PrivateKeyFile == nil {
|
||||||
|
o.SamlSettings.PrivateKeyFile = new(string)
|
||||||
|
*o.SamlSettings.PrivateKeyFile = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.AssertionConsumerServiceURL == nil {
|
||||||
|
o.SamlSettings.AssertionConsumerServiceURL = new(string)
|
||||||
|
*o.SamlSettings.AssertionConsumerServiceURL = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.LoginButtonText == nil || *o.SamlSettings.LoginButtonText == "" {
|
||||||
|
o.SamlSettings.LoginButtonText = new(string)
|
||||||
|
*o.SamlSettings.LoginButtonText = USER_AUTH_SERVICE_SAML_TEXT
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.FirstNameAttribute == nil {
|
||||||
|
o.SamlSettings.FirstNameAttribute = new(string)
|
||||||
|
*o.SamlSettings.FirstNameAttribute = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.LastNameAttribute == nil {
|
||||||
|
o.SamlSettings.LastNameAttribute = new(string)
|
||||||
|
*o.SamlSettings.LastNameAttribute = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.EmailAttribute == nil {
|
||||||
|
o.SamlSettings.EmailAttribute = new(string)
|
||||||
|
*o.SamlSettings.EmailAttribute = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.UsernameAttribute == nil {
|
||||||
|
o.SamlSettings.UsernameAttribute = new(string)
|
||||||
|
*o.SamlSettings.UsernameAttribute = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.NicknameAttribute == nil {
|
||||||
|
o.SamlSettings.NicknameAttribute = new(string)
|
||||||
|
*o.SamlSettings.NicknameAttribute = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.LocaleAttribute == nil {
|
||||||
|
o.SamlSettings.LocaleAttribute = new(string)
|
||||||
|
*o.SamlSettings.LocaleAttribute = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,6 +824,10 @@ func (o *Config) IsValid() *AppError {
|
|||||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.sql_max_conn.app_error", nil, "")
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.sql_max_conn.app_error", nil, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *o.FileSettings.MaxFileSize <= 0 {
|
||||||
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.max_file_size.app_error", nil, "")
|
||||||
|
}
|
||||||
|
|
||||||
if !(o.FileSettings.DriverName == IMAGE_DRIVER_LOCAL || o.FileSettings.DriverName == IMAGE_DRIVER_S3) {
|
if !(o.FileSettings.DriverName == IMAGE_DRIVER_LOCAL || o.FileSettings.DriverName == IMAGE_DRIVER_S3) {
|
||||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.file_driver.app_error", nil, "")
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.file_driver.app_error", nil, "")
|
||||||
}
|
}
|
||||||
@ -603,6 +884,82 @@ func (o *Config) IsValid() *AppError {
|
|||||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_security.app_error", nil, "")
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_security.app_error", nil, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *o.LdapSettings.SyncIntervalMinutes <= 0 {
|
||||||
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_sync_interval.app_error", nil, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
if *o.LdapSettings.MaxPageSize < 0 {
|
||||||
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_max_page_size.app_error", nil, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
if *o.LdapSettings.Enable {
|
||||||
|
if *o.LdapSettings.LdapServer == "" ||
|
||||||
|
*o.LdapSettings.BaseDN == "" ||
|
||||||
|
*o.LdapSettings.BindUsername == "" ||
|
||||||
|
*o.LdapSettings.BindPassword == "" ||
|
||||||
|
*o.LdapSettings.FirstNameAttribute == "" ||
|
||||||
|
*o.LdapSettings.LastNameAttribute == "" ||
|
||||||
|
*o.LdapSettings.EmailAttribute == "" ||
|
||||||
|
*o.LdapSettings.UsernameAttribute == "" ||
|
||||||
|
*o.LdapSettings.IdAttribute == "" {
|
||||||
|
return NewLocAppError("Config.IsValid", "Required LDAP field missing", nil, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if *o.SamlSettings.Enable {
|
||||||
|
if len(*o.SamlSettings.IdpUrl) == 0 {
|
||||||
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_idp_url.app_error", nil, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(*o.SamlSettings.IdpDescriptorUrl) == 0 || !IsValidHttpUrl(*o.SamlSettings.IdpDescriptorUrl) {
|
||||||
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_idp_descriptor_url.app_error", nil, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(*o.SamlSettings.IdpCertificateFile) == 0 {
|
||||||
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_idp_cert.app_error", nil, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(*o.SamlSettings.EmailAttribute) == 0 {
|
||||||
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_email_attribute.app_error", nil, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(*o.SamlSettings.UsernameAttribute) == 0 {
|
||||||
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_username_attribute.app_error", nil, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(*o.SamlSettings.FirstNameAttribute) == 0 {
|
||||||
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_first_name_attribute.app_error", nil, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(*o.SamlSettings.LastNameAttribute) == 0 {
|
||||||
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_last_name_attribute.app_error", nil, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
if *o.SamlSettings.Verify {
|
||||||
|
if len(*o.SamlSettings.AssertionConsumerServiceURL) == 0 || !IsValidHttpUrl(*o.SamlSettings.AssertionConsumerServiceURL) {
|
||||||
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_assertion_consumer_service_url.app_error", nil, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if *o.SamlSettings.Encrypt {
|
||||||
|
if len(*o.SamlSettings.PrivateKeyFile) == 0 {
|
||||||
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_private_key.app_error", nil, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(*o.SamlSettings.PublicCertificateFile) == 0 {
|
||||||
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_public_cert.app_error", nil, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(*o.SamlSettings.EmailAttribute) == 0 {
|
||||||
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_email_attribute.app_error", nil, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if *o.PasswordSettings.MinimumLength < PASSWORD_MINIMUM_LENGTH || *o.PasswordSettings.MinimumLength > PASSWORD_MAXIMUM_LENGTH {
|
||||||
|
return NewLocAppError("Config.IsValid", "model.config.is_valid.password_length.app_error", map[string]interface{}{"MinLength": PASSWORD_MINIMUM_LENGTH, "MaxLength": PASSWORD_MAXIMUM_LENGTH}, "")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,7 +972,7 @@ func (o *Config) GetSanitizeOptions() map[string]bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (o *Config) Sanitize() {
|
func (o *Config) Sanitize() {
|
||||||
if &o.LdapSettings != nil && len(*o.LdapSettings.BindPassword) > 0 {
|
if o.LdapSettings.BindPassword != nil && len(*o.LdapSettings.BindPassword) > 0 {
|
||||||
*o.LdapSettings.BindPassword = FAKE_SETTING
|
*o.LdapSettings.BindPassword = FAKE_SETTING
|
||||||
}
|
}
|
||||||
|
|
||||||
|
95
vendor/github.com/mattermost/platform/model/emoji.go
generated
vendored
Normal file
95
vendor/github.com/mattermost/platform/model/emoji.go
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See License.txt for license information.
|
||||||
|
|
||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Emoji struct {
|
||||||
|
Id string `json:"id"`
|
||||||
|
CreateAt int64 `json:"create_at"`
|
||||||
|
UpdateAt int64 `json:"update_at"`
|
||||||
|
DeleteAt int64 `json:"delete_at"`
|
||||||
|
CreatorId string `json:"creator_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (emoji *Emoji) IsValid() *AppError {
|
||||||
|
if len(emoji.Id) != 26 {
|
||||||
|
return NewLocAppError("Emoji.IsValid", "model.emoji.id.app_error", nil, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
if emoji.CreateAt == 0 {
|
||||||
|
return NewLocAppError("Emoji.IsValid", "model.emoji.create_at.app_error", nil, "id="+emoji.Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
if emoji.UpdateAt == 0 {
|
||||||
|
return NewLocAppError("Emoji.IsValid", "model.emoji.update_at.app_error", nil, "id="+emoji.Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(emoji.CreatorId) != 26 {
|
||||||
|
return NewLocAppError("Emoji.IsValid", "model.emoji.user_id.app_error", nil, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(emoji.Name) == 0 || len(emoji.Name) > 64 {
|
||||||
|
return NewLocAppError("Emoji.IsValid", "model.emoji.name.app_error", nil, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (emoji *Emoji) PreSave() {
|
||||||
|
if emoji.Id == "" {
|
||||||
|
emoji.Id = NewId()
|
||||||
|
}
|
||||||
|
|
||||||
|
emoji.CreateAt = GetMillis()
|
||||||
|
emoji.UpdateAt = emoji.CreateAt
|
||||||
|
}
|
||||||
|
|
||||||
|
func (emoji *Emoji) PreUpdate() {
|
||||||
|
emoji.UpdateAt = GetMillis()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (emoji *Emoji) ToJson() string {
|
||||||
|
b, err := json.Marshal(emoji)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
} else {
|
||||||
|
return string(b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func EmojiFromJson(data io.Reader) *Emoji {
|
||||||
|
decoder := json.NewDecoder(data)
|
||||||
|
var emoji Emoji
|
||||||
|
err := decoder.Decode(&emoji)
|
||||||
|
if err == nil {
|
||||||
|
return &emoji
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func EmojiListToJson(emojiList []*Emoji) string {
|
||||||
|
b, err := json.Marshal(emojiList)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
} else {
|
||||||
|
return string(b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func EmojiListFromJson(data io.Reader) []*Emoji {
|
||||||
|
decoder := json.NewDecoder(data)
|
||||||
|
var emojiList []*Emoji
|
||||||
|
err := decoder.Decode(&emojiList)
|
||||||
|
if err == nil {
|
||||||
|
return emojiList
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
4
vendor/github.com/mattermost/platform/model/file.go
generated
vendored
4
vendor/github.com/mattermost/platform/model/file.go
generated
vendored
@ -8,10 +8,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
MAX_FILE_SIZE = 50000000 // 50 MB
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
IMAGE_EXTENSIONS = [5]string{".jpg", ".jpeg", ".gif", ".bmp", ".png"}
|
IMAGE_EXTENSIONS = [5]string{".jpg", ".jpeg", ".gif", ".bmp", ".png"}
|
||||||
IMAGE_MIME_TYPES = map[string]string{".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".bmp": "image/bmp", ".png": "image/png", ".tiff": "image/tiff"}
|
IMAGE_MIME_TYPES = map[string]string{".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".bmp": "image/bmp", ".png": "image/png", ".tiff": "image/tiff"}
|
||||||
|
3
vendor/github.com/mattermost/platform/model/gitlab/gitlab.go
generated
vendored
3
vendor/github.com/mattermost/platform/model/gitlab/gitlab.go
generated
vendored
@ -47,7 +47,8 @@ func userFromGitLabUser(glu *GitLabUser) *model.User {
|
|||||||
}
|
}
|
||||||
strings.TrimSpace(user.Email)
|
strings.TrimSpace(user.Email)
|
||||||
user.Email = glu.Email
|
user.Email = glu.Email
|
||||||
*user.AuthData = strconv.FormatInt(glu.Id, 10)
|
userId := strconv.FormatInt(glu.Id, 10)
|
||||||
|
user.AuthData = &userId
|
||||||
user.AuthService = model.USER_AUTH_SERVICE_GITLAB
|
user.AuthService = model.USER_AUTH_SERVICE_GITLAB
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
135
vendor/github.com/mattermost/platform/model/incoming_webhook.go
generated
vendored
135
vendor/github.com/mattermost/platform/model/incoming_webhook.go
generated
vendored
@ -4,13 +4,15 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DEFAULT_WEBHOOK_USERNAME = "webhook"
|
DEFAULT_WEBHOOK_USERNAME = "webhook"
|
||||||
DEFAULT_WEBHOOK_ICON = "/static/images/webhook_icon.jpg"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type IncomingWebhook struct {
|
type IncomingWebhook struct {
|
||||||
@ -125,13 +127,136 @@ func (o *IncomingWebhook) PreUpdate() {
|
|||||||
o.UpdateAt = GetMillis()
|
o.UpdateAt = GetMillis()
|
||||||
}
|
}
|
||||||
|
|
||||||
func IncomingWebhookRequestFromJson(data io.Reader) *IncomingWebhookRequest {
|
// escapeControlCharsFromPayload escapes control chars (\n, \t) from a byte slice.
|
||||||
decoder := json.NewDecoder(data)
|
// Context:
|
||||||
|
// JSON strings are not supposed to contain control characters such as \n, \t,
|
||||||
|
// ... but some incoming webhooks might still send invalid JSON and we want to
|
||||||
|
// try to handle that. An example invalid JSON string from an incoming webhook
|
||||||
|
// might look like this (strings for both "text" and "fallback" attributes are
|
||||||
|
// invalid JSON strings because they contain unescaped newlines and tabs):
|
||||||
|
// `{
|
||||||
|
// "text": "this is a test
|
||||||
|
// that contains a newline and tabs",
|
||||||
|
// "attachments": [
|
||||||
|
// {
|
||||||
|
// "fallback": "Required plain-text summary of the attachment
|
||||||
|
// that contains a newline and tabs",
|
||||||
|
// "color": "#36a64f",
|
||||||
|
// ...
|
||||||
|
// "text": "Optional text that appears within the attachment
|
||||||
|
// that contains a newline and tabs",
|
||||||
|
// ...
|
||||||
|
// "thumb_url": "http://example.com/path/to/thumb.png"
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// }`
|
||||||
|
// This function will search for `"key": "value"` pairs, and escape \n, \t
|
||||||
|
// from the value.
|
||||||
|
func escapeControlCharsFromPayload(by []byte) []byte {
|
||||||
|
// we'll search for `"text": "..."` or `"fallback": "..."`, ...
|
||||||
|
keys := "text|fallback|pretext|author_name|title|value"
|
||||||
|
|
||||||
|
// the regexp reads like this:
|
||||||
|
// (?s): this flag let . match \n (default is false)
|
||||||
|
// "(keys)": we search for the keys defined above
|
||||||
|
// \s*:\s*: followed by 0..n spaces/tabs, a colon then 0..n spaces/tabs
|
||||||
|
// ": a double-quote
|
||||||
|
// (\\"|[^"])*: any number of times the `\"` string or any char but a double-quote
|
||||||
|
// ": a double-quote
|
||||||
|
r := `(?s)"(` + keys + `)"\s*:\s*"(\\"|[^"])*"`
|
||||||
|
re := regexp.MustCompile(r)
|
||||||
|
|
||||||
|
// the function that will escape \n and \t on the regexp matches
|
||||||
|
repl := func(b []byte) []byte {
|
||||||
|
if bytes.Contains(b, []byte("\n")) {
|
||||||
|
b = bytes.Replace(b, []byte("\n"), []byte("\\n"), -1)
|
||||||
|
}
|
||||||
|
if bytes.Contains(b, []byte("\t")) {
|
||||||
|
b = bytes.Replace(b, []byte("\t"), []byte("\\t"), -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
return re.ReplaceAllFunc(by, repl)
|
||||||
|
}
|
||||||
|
|
||||||
|
func decodeIncomingWebhookRequest(by []byte) (*IncomingWebhookRequest, error) {
|
||||||
|
decoder := json.NewDecoder(bytes.NewReader(by))
|
||||||
var o IncomingWebhookRequest
|
var o IncomingWebhookRequest
|
||||||
err := decoder.Decode(&o)
|
err := decoder.Decode(&o)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return &o
|
return &o, nil
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To mention @channel via a webhook in Slack, the message should contain
|
||||||
|
// <!channel>, as explained at the bottom of this article:
|
||||||
|
// https://get.slack.help/hc/en-us/articles/202009646-Making-announcements
|
||||||
|
func expandAnnouncement(text string) string {
|
||||||
|
c1 := "<!channel>"
|
||||||
|
c2 := "@channel"
|
||||||
|
if strings.Contains(text, c1) {
|
||||||
|
return strings.Replace(text, c1, c2, -1)
|
||||||
|
}
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expand announcements in incoming webhooks from Slack. Those announcements
|
||||||
|
// can be found in the text attribute, or in the pretext, text, title and value
|
||||||
|
// attributes of the attachment structure. The Slack attachment structure is
|
||||||
|
// documented here: https://api.slack.com/docs/attachments
|
||||||
|
func expandAnnouncements(i *IncomingWebhookRequest) {
|
||||||
|
i.Text = expandAnnouncement(i.Text)
|
||||||
|
|
||||||
|
if i.Attachments != nil {
|
||||||
|
attachments := i.Attachments.([]interface{})
|
||||||
|
for _, attachment := range attachments {
|
||||||
|
a := attachment.(map[string]interface{})
|
||||||
|
|
||||||
|
if a["pretext"] != nil {
|
||||||
|
a["pretext"] = expandAnnouncement(a["pretext"].(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
if a["text"] != nil {
|
||||||
|
a["text"] = expandAnnouncement(a["text"].(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
if a["title"] != nil {
|
||||||
|
a["title"] = expandAnnouncement(a["title"].(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
if a["fields"] != nil {
|
||||||
|
fields := a["fields"].([]interface{})
|
||||||
|
for _, field := range fields {
|
||||||
|
f := field.(map[string]interface{})
|
||||||
|
if f["value"] != nil {
|
||||||
|
f["value"] = expandAnnouncement(f["value"].(string))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func IncomingWebhookRequestFromJson(data io.Reader) *IncomingWebhookRequest {
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
buf.ReadFrom(data)
|
||||||
|
by := buf.Bytes()
|
||||||
|
|
||||||
|
// Try to decode the JSON data. Only if it fails, try to escape control
|
||||||
|
// characters from the strings contained in the JSON data.
|
||||||
|
o, err := decodeIncomingWebhookRequest(by)
|
||||||
|
if err != nil {
|
||||||
|
o, err = decodeIncomingWebhookRequest(escapeControlCharsFromPayload(by))
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
expandAnnouncements(o)
|
||||||
|
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
94
vendor/github.com/mattermost/platform/model/job.go
generated
vendored
Normal file
94
vendor/github.com/mattermost/platform/model/job.go
generated
vendored
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See License.txt for license information.
|
||||||
|
|
||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TaskFunc func()
|
||||||
|
|
||||||
|
type ScheduledTask struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Interval time.Duration `json:"interval"`
|
||||||
|
Recurring bool `json:"recurring"`
|
||||||
|
function TaskFunc `json:",omitempty"`
|
||||||
|
timer *time.Timer `json:",omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var tasks = make(map[string]*ScheduledTask)
|
||||||
|
|
||||||
|
func addTask(task *ScheduledTask) {
|
||||||
|
tasks[task.Name] = task
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeTaskByName(name string) {
|
||||||
|
delete(tasks, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetTaskByName(name string) *ScheduledTask {
|
||||||
|
if task, ok := tasks[name]; ok {
|
||||||
|
return task
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAllTasks() *map[string]*ScheduledTask {
|
||||||
|
return &tasks
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateTask(name string, function TaskFunc, timeToExecution time.Duration) *ScheduledTask {
|
||||||
|
task := &ScheduledTask{
|
||||||
|
Name: name,
|
||||||
|
Interval: timeToExecution,
|
||||||
|
Recurring: false,
|
||||||
|
function: function,
|
||||||
|
}
|
||||||
|
|
||||||
|
taskRunner := func() {
|
||||||
|
go task.function()
|
||||||
|
removeTaskByName(task.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
task.timer = time.AfterFunc(timeToExecution, taskRunner)
|
||||||
|
|
||||||
|
addTask(task)
|
||||||
|
|
||||||
|
return task
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateRecurringTask(name string, function TaskFunc, interval time.Duration) *ScheduledTask {
|
||||||
|
task := &ScheduledTask{
|
||||||
|
Name: name,
|
||||||
|
Interval: interval,
|
||||||
|
Recurring: true,
|
||||||
|
function: function,
|
||||||
|
}
|
||||||
|
|
||||||
|
taskRecurer := func() {
|
||||||
|
go task.function()
|
||||||
|
task.timer.Reset(task.Interval)
|
||||||
|
}
|
||||||
|
|
||||||
|
task.timer = time.AfterFunc(interval, taskRecurer)
|
||||||
|
|
||||||
|
addTask(task)
|
||||||
|
|
||||||
|
return task
|
||||||
|
}
|
||||||
|
|
||||||
|
func (task *ScheduledTask) Cancel() {
|
||||||
|
task.timer.Stop()
|
||||||
|
removeTaskByName(task.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (task *ScheduledTask) String() string {
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"%s\nInterval: %s\nRecurring: %t\n",
|
||||||
|
task.Name,
|
||||||
|
task.Interval.String(),
|
||||||
|
task.Recurring,
|
||||||
|
)
|
||||||
|
}
|
1
vendor/github.com/mattermost/platform/model/ldap.go
generated
vendored
1
vendor/github.com/mattermost/platform/model/ldap.go
generated
vendored
@ -5,4 +5,5 @@ package model
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
USER_AUTH_SERVICE_LDAP = "ldap"
|
USER_AUTH_SERVICE_LDAP = "ldap"
|
||||||
|
LDAP_SYNC_TASK_NAME = "LDAP Syncronization"
|
||||||
)
|
)
|
||||||
|
12
vendor/github.com/mattermost/platform/model/license.go
generated
vendored
12
vendor/github.com/mattermost/platform/model/license.go
generated
vendored
@ -39,6 +39,8 @@ type Features struct {
|
|||||||
Compliance *bool `json:"compliance"`
|
Compliance *bool `json:"compliance"`
|
||||||
CustomBrand *bool `json:"custom_brand"`
|
CustomBrand *bool `json:"custom_brand"`
|
||||||
MHPNS *bool `json:"mhpns"`
|
MHPNS *bool `json:"mhpns"`
|
||||||
|
SAML *bool `json:"saml"`
|
||||||
|
PasswordRequirements *bool `json:"password_requirements"`
|
||||||
FutureFeatures *bool `json:"future_features"`
|
FutureFeatures *bool `json:"future_features"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +84,16 @@ func (f *Features) SetDefaults() {
|
|||||||
f.MHPNS = new(bool)
|
f.MHPNS = new(bool)
|
||||||
*f.MHPNS = *f.FutureFeatures
|
*f.MHPNS = *f.FutureFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if f.SAML == nil {
|
||||||
|
f.SAML = new(bool)
|
||||||
|
*f.SAML = *f.FutureFeatures
|
||||||
|
}
|
||||||
|
|
||||||
|
if f.PasswordRequirements == nil {
|
||||||
|
f.PasswordRequirements = new(bool)
|
||||||
|
*f.PasswordRequirements = *f.FutureFeatures
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *License) IsExpired() bool {
|
func (l *License) IsExpired() bool {
|
||||||
|
1
vendor/github.com/mattermost/platform/model/message.go
generated
vendored
1
vendor/github.com/mattermost/platform/model/message.go
generated
vendored
@ -17,6 +17,7 @@ const (
|
|||||||
ACTION_CHANNEL_VIEWED = "channel_viewed"
|
ACTION_CHANNEL_VIEWED = "channel_viewed"
|
||||||
ACTION_DIRECT_ADDED = "direct_added"
|
ACTION_DIRECT_ADDED = "direct_added"
|
||||||
ACTION_NEW_USER = "new_user"
|
ACTION_NEW_USER = "new_user"
|
||||||
|
ACTION_LEAVE_TEAM = "leave_team"
|
||||||
ACTION_USER_ADDED = "user_added"
|
ACTION_USER_ADDED = "user_added"
|
||||||
ACTION_USER_REMOVED = "user_removed"
|
ACTION_USER_REMOVED = "user_removed"
|
||||||
ACTION_PREFERENCE_CHANGED = "preference_changed"
|
ACTION_PREFERENCE_CHANGED = "preference_changed"
|
||||||
|
47
vendor/github.com/mattermost/platform/model/outgoing_webhook.go
generated
vendored
47
vendor/github.com/mattermost/platform/model/outgoing_webhook.go
generated
vendored
@ -7,6 +7,8 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OutgoingWebhook struct {
|
type OutgoingWebhook struct {
|
||||||
@ -22,6 +24,47 @@ type OutgoingWebhook struct {
|
|||||||
CallbackURLs StringArray `json:"callback_urls"`
|
CallbackURLs StringArray `json:"callback_urls"`
|
||||||
DisplayName string `json:"display_name"`
|
DisplayName string `json:"display_name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
ContentType string `json:"content_type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OutgoingWebhookPayload struct {
|
||||||
|
Token string `json:"token"`
|
||||||
|
TeamId string `json:"team_id"`
|
||||||
|
TeamDomain string `json:"team_domain"`
|
||||||
|
ChannelId string `json:"channel_id"`
|
||||||
|
ChannelName string `json:"channel_name"`
|
||||||
|
Timestamp int64 `json:"timestamp"`
|
||||||
|
UserId string `json:"user_id"`
|
||||||
|
UserName string `json:"user_name"`
|
||||||
|
PostId string `json:"post_id"`
|
||||||
|
Text string `json:"text"`
|
||||||
|
TriggerWord string `json:"trigger_word"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OutgoingWebhookPayload) ToJSON() string {
|
||||||
|
b, err := json.Marshal(o)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
} else {
|
||||||
|
return string(b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OutgoingWebhookPayload) ToFormValues() string {
|
||||||
|
v := url.Values{}
|
||||||
|
v.Set("token", o.Token)
|
||||||
|
v.Set("team_id", o.TeamId)
|
||||||
|
v.Set("team_domain", o.TeamDomain)
|
||||||
|
v.Set("channel_id", o.ChannelId)
|
||||||
|
v.Set("channel_name", o.ChannelName)
|
||||||
|
v.Set("timestamp", strconv.FormatInt(o.Timestamp/1000, 10))
|
||||||
|
v.Set("user_id", o.UserId)
|
||||||
|
v.Set("user_name", o.UserName)
|
||||||
|
v.Set("post_id", o.PostId)
|
||||||
|
v.Set("text", o.Text)
|
||||||
|
v.Set("trigger_word", o.TriggerWord)
|
||||||
|
|
||||||
|
return v.Encode()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OutgoingWebhook) ToJson() string {
|
func (o *OutgoingWebhook) ToJson() string {
|
||||||
@ -124,6 +167,10 @@ func (o *OutgoingWebhook) IsValid() *AppError {
|
|||||||
return NewLocAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.description.app_error", nil, "")
|
return NewLocAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.description.app_error", nil, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(o.ContentType) > 128 {
|
||||||
|
return NewLocAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.content_type.app_error", nil, "")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
vendor/github.com/mattermost/platform/model/preference.go
generated
vendored
3
vendor/github.com/mattermost/platform/model/preference.go
generated
vendored
@ -14,6 +14,9 @@ const (
|
|||||||
PREFERENCE_CATEGORY_TUTORIAL_STEPS = "tutorial_step"
|
PREFERENCE_CATEGORY_TUTORIAL_STEPS = "tutorial_step"
|
||||||
PREFERENCE_CATEGORY_ADVANCED_SETTINGS = "advanced_settings"
|
PREFERENCE_CATEGORY_ADVANCED_SETTINGS = "advanced_settings"
|
||||||
|
|
||||||
|
PREFERENCE_CATEGORY_DISPLAY_SETTINGS = "display_settings"
|
||||||
|
PREFERENCE_NAME_COLLAPSE_SETTING = "collapse_previews"
|
||||||
|
|
||||||
PREFERENCE_CATEGORY_LAST = "last"
|
PREFERENCE_CATEGORY_LAST = "last"
|
||||||
PREFERENCE_NAME_LAST_CHANNEL = "channel"
|
PREFERENCE_NAME_LAST_CHANNEL = "channel"
|
||||||
)
|
)
|
||||||
|
18
vendor/github.com/mattermost/platform/model/saml.go
generated
vendored
Normal file
18
vendor/github.com/mattermost/platform/model/saml.go
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See License.txt for license information.
|
||||||
|
|
||||||
|
package model
|
||||||
|
|
||||||
|
const (
|
||||||
|
USER_AUTH_SERVICE_SAML = "saml"
|
||||||
|
USER_AUTH_SERVICE_SAML_TEXT = "With SAML"
|
||||||
|
SAML_IDP_CERTIFICATE = 1
|
||||||
|
SAML_PRIVATE_KEY = 2
|
||||||
|
SAML_PUBLIC_CERT = 3
|
||||||
|
)
|
||||||
|
|
||||||
|
type SamlAuthRequest struct {
|
||||||
|
Base64AuthRequest string
|
||||||
|
URL string
|
||||||
|
RelayState string
|
||||||
|
}
|
8
vendor/github.com/mattermost/platform/model/search_params.go
generated
vendored
8
vendor/github.com/mattermost/platform/model/search_params.go
generated
vendored
@ -4,9 +4,13 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var searchTermPuncStart = regexp.MustCompile(`^[^\pL\d\s#"]+`)
|
||||||
|
var searchTermPuncEnd = regexp.MustCompile(`[^\pL\d\s*"]+$`)
|
||||||
|
|
||||||
type SearchParams struct {
|
type SearchParams struct {
|
||||||
Terms string
|
Terms string
|
||||||
IsHashtag bool
|
IsHashtag bool
|
||||||
@ -91,8 +95,8 @@ func parseSearchFlags(input []string) ([]string, [][2]string) {
|
|||||||
|
|
||||||
if !isFlag {
|
if !isFlag {
|
||||||
// trim off surrounding punctuation (note that we leave trailing asterisks to allow wildcards)
|
// trim off surrounding punctuation (note that we leave trailing asterisks to allow wildcards)
|
||||||
word = puncStart.ReplaceAllString(word, "")
|
word = searchTermPuncStart.ReplaceAllString(word, "")
|
||||||
word = puncEndWildcard.ReplaceAllString(word, "")
|
word = searchTermPuncEnd.ReplaceAllString(word, "")
|
||||||
|
|
||||||
// and remove extra pound #s
|
// and remove extra pound #s
|
||||||
word = hashtagStart.ReplaceAllString(word, "#")
|
word = hashtagStart.ReplaceAllString(word, "#")
|
||||||
|
1
vendor/github.com/mattermost/platform/model/team_member.go
generated
vendored
1
vendor/github.com/mattermost/platform/model/team_member.go
generated
vendored
@ -17,6 +17,7 @@ type TeamMember struct {
|
|||||||
TeamId string `json:"team_id"`
|
TeamId string `json:"team_id"`
|
||||||
UserId string `json:"user_id"`
|
UserId string `json:"user_id"`
|
||||||
Roles string `json:"roles"`
|
Roles string `json:"roles"`
|
||||||
|
DeleteAt int64 `json:"delete_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *TeamMember) ToJson() string {
|
func (o *TeamMember) ToJson() string {
|
||||||
|
32
vendor/github.com/mattermost/platform/model/user.go
generated
vendored
32
vendor/github.com/mattermost/platform/model/user.go
generated
vendored
@ -27,7 +27,6 @@ const (
|
|||||||
DEFAULT_LOCALE = "en"
|
DEFAULT_LOCALE = "en"
|
||||||
USER_AUTH_SERVICE_EMAIL = "email"
|
USER_AUTH_SERVICE_EMAIL = "email"
|
||||||
USER_AUTH_SERVICE_USERNAME = "username"
|
USER_AUTH_SERVICE_USERNAME = "username"
|
||||||
MIN_PASSWORD_LENGTH = 5
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
@ -95,10 +94,6 @@ func (u *User) IsValid() *AppError {
|
|||||||
return NewLocAppError("User.IsValid", "model.user.is_valid.last_name.app_error", nil, "user_id="+u.Id)
|
return NewLocAppError("User.IsValid", "model.user.is_valid.last_name.app_error", nil, "user_id="+u.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(u.Password) > 128 {
|
|
||||||
return NewLocAppError("User.IsValid", "model.user.is_valid.pwd.app_error", nil, "user_id="+u.Id)
|
|
||||||
}
|
|
||||||
|
|
||||||
if u.AuthData != nil && len(*u.AuthData) > 128 {
|
if u.AuthData != nil && len(*u.AuthData) > 128 {
|
||||||
return NewLocAppError("User.IsValid", "model.user.is_valid.auth_data.app_error", nil, "user_id="+u.Id)
|
return NewLocAppError("User.IsValid", "model.user.is_valid.auth_data.app_error", nil, "user_id="+u.Id)
|
||||||
}
|
}
|
||||||
@ -136,7 +131,6 @@ func (u *User) PreSave() {
|
|||||||
|
|
||||||
u.Username = strings.ToLower(u.Username)
|
u.Username = strings.ToLower(u.Username)
|
||||||
u.Email = strings.ToLower(u.Email)
|
u.Email = strings.ToLower(u.Email)
|
||||||
u.Locale = strings.ToLower(u.Locale)
|
|
||||||
|
|
||||||
u.CreateAt = GetMillis()
|
u.CreateAt = GetMillis()
|
||||||
u.UpdateAt = u.CreateAt
|
u.UpdateAt = u.CreateAt
|
||||||
@ -166,7 +160,6 @@ func (u *User) PreSave() {
|
|||||||
func (u *User) PreUpdate() {
|
func (u *User) PreUpdate() {
|
||||||
u.Username = strings.ToLower(u.Username)
|
u.Username = strings.ToLower(u.Username)
|
||||||
u.Email = strings.ToLower(u.Email)
|
u.Email = strings.ToLower(u.Email)
|
||||||
u.Locale = strings.ToLower(u.Locale)
|
|
||||||
u.UpdateAt = GetMillis()
|
u.UpdateAt = GetMillis()
|
||||||
|
|
||||||
if u.AuthData != nil && *u.AuthData == "" {
|
if u.AuthData != nil && *u.AuthData == "" {
|
||||||
@ -186,15 +179,30 @@ func (u *User) PreUpdate() {
|
|||||||
}
|
}
|
||||||
u.NotifyProps["mention_keys"] = strings.Join(goodKeys, ",")
|
u.NotifyProps["mention_keys"] = strings.Join(goodKeys, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if u.ThemeProps != nil {
|
||||||
|
colorPattern := regexp.MustCompile(`^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$`)
|
||||||
|
|
||||||
|
// blank out any invalid theme values
|
||||||
|
for name, value := range u.ThemeProps {
|
||||||
|
if name == "image" || name == "type" || name == "codeTheme" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if !colorPattern.MatchString(value) {
|
||||||
|
u.ThemeProps[name] = "#ffffff"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) SetDefaultNotifications() {
|
func (u *User) SetDefaultNotifications() {
|
||||||
u.NotifyProps = make(map[string]string)
|
u.NotifyProps = make(map[string]string)
|
||||||
u.NotifyProps["email"] = "true"
|
u.NotifyProps["email"] = "true"
|
||||||
|
u.NotifyProps["push"] = USER_NOTIFY_MENTION
|
||||||
u.NotifyProps["desktop"] = USER_NOTIFY_ALL
|
u.NotifyProps["desktop"] = USER_NOTIFY_ALL
|
||||||
u.NotifyProps["desktop_sound"] = "true"
|
u.NotifyProps["desktop_sound"] = "true"
|
||||||
u.NotifyProps["mention_keys"] = u.Username + ",@" + u.Username
|
u.NotifyProps["mention_keys"] = u.Username + ",@" + u.Username
|
||||||
u.NotifyProps["all"] = "true"
|
|
||||||
u.NotifyProps["channel"] = "true"
|
u.NotifyProps["channel"] = "true"
|
||||||
|
|
||||||
if u.FirstName == "" {
|
if u.FirstName == "" {
|
||||||
@ -230,8 +238,8 @@ func (u *User) ToJson() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate a valid strong etag so the browser can cache the results
|
// Generate a valid strong etag so the browser can cache the results
|
||||||
func (u *User) Etag() string {
|
func (u *User) Etag(showFullName, showEmail bool) string {
|
||||||
return Etag(u.Id, u.UpdateAt)
|
return Etag(u.Id, u.UpdateAt, showFullName, showEmail)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) IsOffline() bool {
|
func (u *User) IsOffline() bool {
|
||||||
@ -349,13 +357,13 @@ func isValidRole(role string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure you acually want to use this function. In context.go there are functions to check permssions
|
// Make sure you acually want to use this function. In context.go there are functions to check permissions
|
||||||
// This function should not be used to check permissions.
|
// This function should not be used to check permissions.
|
||||||
func (u *User) IsInRole(inRole string) bool {
|
func (u *User) IsInRole(inRole string) bool {
|
||||||
return IsInRole(u.Roles, inRole)
|
return IsInRole(u.Roles, inRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure you acually want to use this function. In context.go there are functions to check permssions
|
// Make sure you acually want to use this function. In context.go there are functions to check permissions
|
||||||
// This function should not be used to check permissions.
|
// This function should not be used to check permissions.
|
||||||
func IsInRole(userRoles string, inRole string) bool {
|
func IsInRole(userRoles string, inRole string) bool {
|
||||||
roles := strings.Split(userRoles, " ")
|
roles := strings.Split(userRoles, " ")
|
||||||
|
12
vendor/github.com/mattermost/platform/model/utils.go
generated
vendored
12
vendor/github.com/mattermost/platform/model/utils.go
generated
vendored
@ -20,6 +20,13 @@ import (
|
|||||||
"github.com/pborman/uuid"
|
"github.com/pborman/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
LOWERCASE_LETTERS = "abcdefghijklmnopqrstuvwxyz"
|
||||||
|
UPPERCASE_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
NUMBERS = "0123456789"
|
||||||
|
SYMBOLS = " !\"\\#$%&'()*+,-./:;<=>?@[]^_`|~"
|
||||||
|
)
|
||||||
|
|
||||||
type StringInterface map[string]interface{}
|
type StringInterface map[string]interface{}
|
||||||
type StringMap map[string]string
|
type StringMap map[string]string
|
||||||
type StringArray []string
|
type StringArray []string
|
||||||
@ -315,10 +322,9 @@ func Etag(parts ...interface{}) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var validHashtag = regexp.MustCompile(`^(#[A-Za-zäöüÄÖÜß]+[A-Za-z0-9äöüÄÖÜß_\-]*[A-Za-z0-9äöüÄÖÜß])$`)
|
var validHashtag = regexp.MustCompile(`^(#[A-Za-zäöüÄÖÜß]+[A-Za-z0-9äöüÄÖÜß_\-]*[A-Za-z0-9äöüÄÖÜß])$`)
|
||||||
var puncStart = regexp.MustCompile(`^[.,()&$!\?\[\]{}':;\\<>\-+=%^*|]+`)
|
var puncStart = regexp.MustCompile(`^[^\pL\d\s#]+`)
|
||||||
var hashtagStart = regexp.MustCompile(`^#{2,}`)
|
var hashtagStart = regexp.MustCompile(`^#{2,}`)
|
||||||
var puncEnd = regexp.MustCompile(`[.,()&$#!\?\[\]{}':;\\<>\-+=%^*|]+$`)
|
var puncEnd = regexp.MustCompile(`[^\pL\d\s]+$`)
|
||||||
var puncEndWildcard = regexp.MustCompile(`[.,()&$#!\?\[\]{}':;\\<>\-+=%^|]+$`)
|
|
||||||
|
|
||||||
func ParseHashtags(text string) (string, string) {
|
func ParseHashtags(text string) (string, string) {
|
||||||
words := strings.Fields(text)
|
words := strings.Fields(text)
|
||||||
|
3
vendor/github.com/mattermost/platform/model/version.go
generated
vendored
3
vendor/github.com/mattermost/platform/model/version.go
generated
vendored
@ -13,6 +13,8 @@ import (
|
|||||||
// It should be maitained in chronological order with most current
|
// It should be maitained in chronological order with most current
|
||||||
// release at the front of the list.
|
// release at the front of the list.
|
||||||
var versions = []string{
|
var versions = []string{
|
||||||
|
"3.2.0",
|
||||||
|
"3.1.0",
|
||||||
"3.0.0",
|
"3.0.0",
|
||||||
"2.2.0",
|
"2.2.0",
|
||||||
"2.1.0",
|
"2.1.0",
|
||||||
@ -33,6 +35,7 @@ var CurrentVersion string = versions[0]
|
|||||||
var BuildNumber string
|
var BuildNumber string
|
||||||
var BuildDate string
|
var BuildDate string
|
||||||
var BuildHash string
|
var BuildHash string
|
||||||
|
var BuildHashEnterprise string
|
||||||
var BuildEnterpriseReady string
|
var BuildEnterpriseReady string
|
||||||
var versionsWithoutHotFixes []string
|
var versionsWithoutHotFixes []string
|
||||||
|
|
||||||
|
20
vendor/github.com/thoj/go-ircevent/irc.go
generated
vendored
20
vendor/github.com/thoj/go-ircevent/irc.go
generated
vendored
@ -439,6 +439,25 @@ func (irc *Connection) Connect(server string) error {
|
|||||||
if len(irc.Password) > 0 {
|
if len(irc.Password) > 0 {
|
||||||
irc.pwrite <- fmt.Sprintf("PASS %s\r\n", irc.Password)
|
irc.pwrite <- fmt.Sprintf("PASS %s\r\n", irc.Password)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resChan := make(chan *SASLResult)
|
||||||
|
if irc.UseSASL {
|
||||||
|
irc.setupSASLCallbacks(resChan)
|
||||||
|
irc.pwrite <- fmt.Sprintf("CAP LS\r\n")
|
||||||
|
// request SASL
|
||||||
|
irc.pwrite <- fmt.Sprintf("CAP REQ :sasl\r\n")
|
||||||
|
// if sasl request doesn't complete in 15 seconds, close chan and timeout
|
||||||
|
select {
|
||||||
|
case res := <-resChan:
|
||||||
|
if res.Failed {
|
||||||
|
close(resChan)
|
||||||
|
return res.Err
|
||||||
|
}
|
||||||
|
case <-time.After(time.Second * 15):
|
||||||
|
close(resChan)
|
||||||
|
return errors.New("SASL setup timed out. This shouldn't happen.")
|
||||||
|
}
|
||||||
|
}
|
||||||
irc.pwrite <- fmt.Sprintf("NICK %s\r\n", irc.nick)
|
irc.pwrite <- fmt.Sprintf("NICK %s\r\n", irc.nick)
|
||||||
irc.pwrite <- fmt.Sprintf("USER %s 0.0.0.0 0.0.0.0 :%s\r\n", irc.user, irc.user)
|
irc.pwrite <- fmt.Sprintf("USER %s 0.0.0.0 0.0.0.0 :%s\r\n", irc.user, irc.user)
|
||||||
return nil
|
return nil
|
||||||
@ -466,6 +485,7 @@ func IRC(nick, user string) *Connection {
|
|||||||
KeepAlive: 4 * time.Minute,
|
KeepAlive: 4 * time.Minute,
|
||||||
Timeout: 1 * time.Minute,
|
Timeout: 1 * time.Minute,
|
||||||
PingFreq: 15 * time.Minute,
|
PingFreq: 15 * time.Minute,
|
||||||
|
SASLMech: "PLAIN",
|
||||||
QuitMessage: "",
|
QuitMessage: "",
|
||||||
}
|
}
|
||||||
irc.setupCallbacks()
|
irc.setupCallbacks()
|
||||||
|
4
vendor/github.com/thoj/go-ircevent/irc_struct.go
generated
vendored
4
vendor/github.com/thoj/go-ircevent/irc_struct.go
generated
vendored
@ -18,6 +18,10 @@ type Connection struct {
|
|||||||
Error chan error
|
Error chan error
|
||||||
Password string
|
Password string
|
||||||
UseTLS bool
|
UseTLS bool
|
||||||
|
UseSASL bool
|
||||||
|
SASLLogin string
|
||||||
|
SASLPassword string
|
||||||
|
SASLMech string
|
||||||
TLSConfig *tls.Config
|
TLSConfig *tls.Config
|
||||||
Version string
|
Version string
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
|
54
vendor/github.com/thoj/go-ircevent/sasl.go
generated
vendored
Normal file
54
vendor/github.com/thoj/go-ircevent/sasl.go
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package irc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SASLResult struct {
|
||||||
|
Failed bool
|
||||||
|
Err error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (irc *Connection) setupSASLCallbacks(result chan<- *SASLResult) {
|
||||||
|
irc.AddCallback("CAP", func(e *Event) {
|
||||||
|
if len(e.Arguments) == 3 {
|
||||||
|
if e.Arguments[1] == "LS" {
|
||||||
|
if !strings.Contains(e.Arguments[2], "sasl") {
|
||||||
|
result <- &SASLResult{true, errors.New("no SASL capability " + e.Arguments[2])}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if e.Arguments[1] == "ACK" {
|
||||||
|
if irc.SASLMech != "PLAIN" {
|
||||||
|
result <- &SASLResult{true, errors.New("only PLAIN is supported")}
|
||||||
|
}
|
||||||
|
irc.SendRaw("AUTHENTICATE " + irc.SASLMech)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
irc.AddCallback("AUTHENTICATE", func(e *Event) {
|
||||||
|
str := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s\x00%s\x00%s", irc.SASLLogin, irc.SASLLogin, irc.SASLPassword)))
|
||||||
|
irc.SendRaw("AUTHENTICATE " + str)
|
||||||
|
})
|
||||||
|
irc.AddCallback("901", func(e *Event) {
|
||||||
|
irc.SendRaw("CAP END")
|
||||||
|
irc.SendRaw("QUIT")
|
||||||
|
result <- &SASLResult{true, errors.New(e.Arguments[1])}
|
||||||
|
})
|
||||||
|
irc.AddCallback("902", func(e *Event) {
|
||||||
|
irc.SendRaw("CAP END")
|
||||||
|
irc.SendRaw("QUIT")
|
||||||
|
result <- &SASLResult{true, errors.New(e.Arguments[1])}
|
||||||
|
})
|
||||||
|
irc.AddCallback("903", func(e *Event) {
|
||||||
|
irc.SendRaw("CAP END")
|
||||||
|
result <- &SASLResult{false, nil}
|
||||||
|
})
|
||||||
|
irc.AddCallback("904", func(e *Event) {
|
||||||
|
irc.SendRaw("CAP END")
|
||||||
|
irc.SendRaw("QUIT")
|
||||||
|
result <- &SASLResult{true, errors.New(e.Arguments[1])}
|
||||||
|
})
|
||||||
|
}
|
27
vendor/golang.org/x/net/lex/httplex/LICENSE
generated
vendored
Normal file
27
vendor/golang.org/x/net/lex/httplex/LICENSE
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
312
vendor/golang.org/x/net/lex/httplex/httplex.go
generated
vendored
Normal file
312
vendor/golang.org/x/net/lex/httplex/httplex.go
generated
vendored
Normal file
@ -0,0 +1,312 @@
|
|||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Package httplex contains rules around lexical matters of various
|
||||||
|
// HTTP-related specifications.
|
||||||
|
//
|
||||||
|
// This package is shared by the standard library (which vendors it)
|
||||||
|
// and x/net/http2. It comes with no API stability promise.
|
||||||
|
package httplex
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"unicode/utf8"
|
||||||
|
)
|
||||||
|
|
||||||
|
var isTokenTable = [127]bool{
|
||||||
|
'!': true,
|
||||||
|
'#': true,
|
||||||
|
'$': true,
|
||||||
|
'%': true,
|
||||||
|
'&': true,
|
||||||
|
'\'': true,
|
||||||
|
'*': true,
|
||||||
|
'+': true,
|
||||||
|
'-': true,
|
||||||
|
'.': true,
|
||||||
|
'0': true,
|
||||||
|
'1': true,
|
||||||
|
'2': true,
|
||||||
|
'3': true,
|
||||||
|
'4': true,
|
||||||
|
'5': true,
|
||||||
|
'6': true,
|
||||||
|
'7': true,
|
||||||
|
'8': true,
|
||||||
|
'9': true,
|
||||||
|
'A': true,
|
||||||
|
'B': true,
|
||||||
|
'C': true,
|
||||||
|
'D': true,
|
||||||
|
'E': true,
|
||||||
|
'F': true,
|
||||||
|
'G': true,
|
||||||
|
'H': true,
|
||||||
|
'I': true,
|
||||||
|
'J': true,
|
||||||
|
'K': true,
|
||||||
|
'L': true,
|
||||||
|
'M': true,
|
||||||
|
'N': true,
|
||||||
|
'O': true,
|
||||||
|
'P': true,
|
||||||
|
'Q': true,
|
||||||
|
'R': true,
|
||||||
|
'S': true,
|
||||||
|
'T': true,
|
||||||
|
'U': true,
|
||||||
|
'W': true,
|
||||||
|
'V': true,
|
||||||
|
'X': true,
|
||||||
|
'Y': true,
|
||||||
|
'Z': true,
|
||||||
|
'^': true,
|
||||||
|
'_': true,
|
||||||
|
'`': true,
|
||||||
|
'a': true,
|
||||||
|
'b': true,
|
||||||
|
'c': true,
|
||||||
|
'd': true,
|
||||||
|
'e': true,
|
||||||
|
'f': true,
|
||||||
|
'g': true,
|
||||||
|
'h': true,
|
||||||
|
'i': true,
|
||||||
|
'j': true,
|
||||||
|
'k': true,
|
||||||
|
'l': true,
|
||||||
|
'm': true,
|
||||||
|
'n': true,
|
||||||
|
'o': true,
|
||||||
|
'p': true,
|
||||||
|
'q': true,
|
||||||
|
'r': true,
|
||||||
|
's': true,
|
||||||
|
't': true,
|
||||||
|
'u': true,
|
||||||
|
'v': true,
|
||||||
|
'w': true,
|
||||||
|
'x': true,
|
||||||
|
'y': true,
|
||||||
|
'z': true,
|
||||||
|
'|': true,
|
||||||
|
'~': true,
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsTokenRune(r rune) bool {
|
||||||
|
i := int(r)
|
||||||
|
return i < len(isTokenTable) && isTokenTable[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
func isNotToken(r rune) bool {
|
||||||
|
return !IsTokenRune(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HeaderValuesContainsToken reports whether any string in values
|
||||||
|
// contains the provided token, ASCII case-insensitively.
|
||||||
|
func HeaderValuesContainsToken(values []string, token string) bool {
|
||||||
|
for _, v := range values {
|
||||||
|
if headerValueContainsToken(v, token) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// isOWS reports whether b is an optional whitespace byte, as defined
|
||||||
|
// by RFC 7230 section 3.2.3.
|
||||||
|
func isOWS(b byte) bool { return b == ' ' || b == '\t' }
|
||||||
|
|
||||||
|
// trimOWS returns x with all optional whitespace removes from the
|
||||||
|
// beginning and end.
|
||||||
|
func trimOWS(x string) string {
|
||||||
|
// TODO: consider using strings.Trim(x, " \t") instead,
|
||||||
|
// if and when it's fast enough. See issue 10292.
|
||||||
|
// But this ASCII-only code will probably always beat UTF-8
|
||||||
|
// aware code.
|
||||||
|
for len(x) > 0 && isOWS(x[0]) {
|
||||||
|
x = x[1:]
|
||||||
|
}
|
||||||
|
for len(x) > 0 && isOWS(x[len(x)-1]) {
|
||||||
|
x = x[:len(x)-1]
|
||||||
|
}
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
|
||||||
|
// headerValueContainsToken reports whether v (assumed to be a
|
||||||
|
// 0#element, in the ABNF extension described in RFC 7230 section 7)
|
||||||
|
// contains token amongst its comma-separated tokens, ASCII
|
||||||
|
// case-insensitively.
|
||||||
|
func headerValueContainsToken(v string, token string) bool {
|
||||||
|
v = trimOWS(v)
|
||||||
|
if comma := strings.IndexByte(v, ','); comma != -1 {
|
||||||
|
return tokenEqual(trimOWS(v[:comma]), token) || headerValueContainsToken(v[comma+1:], token)
|
||||||
|
}
|
||||||
|
return tokenEqual(v, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
// lowerASCII returns the ASCII lowercase version of b.
|
||||||
|
func lowerASCII(b byte) byte {
|
||||||
|
if 'A' <= b && b <= 'Z' {
|
||||||
|
return b + ('a' - 'A')
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// tokenEqual reports whether t1 and t2 are equal, ASCII case-insensitively.
|
||||||
|
func tokenEqual(t1, t2 string) bool {
|
||||||
|
if len(t1) != len(t2) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for i, b := range t1 {
|
||||||
|
if b >= utf8.RuneSelf {
|
||||||
|
// No UTF-8 or non-ASCII allowed in tokens.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if lowerASCII(byte(b)) != lowerASCII(t2[i]) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// isLWS reports whether b is linear white space, according
|
||||||
|
// to http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2
|
||||||
|
// LWS = [CRLF] 1*( SP | HT )
|
||||||
|
func isLWS(b byte) bool { return b == ' ' || b == '\t' }
|
||||||
|
|
||||||
|
// isCTL reports whether b is a control byte, according
|
||||||
|
// to http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2
|
||||||
|
// CTL = <any US-ASCII control character
|
||||||
|
// (octets 0 - 31) and DEL (127)>
|
||||||
|
func isCTL(b byte) bool {
|
||||||
|
const del = 0x7f // a CTL
|
||||||
|
return b < ' ' || b == del
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidHeaderFieldName reports whether v is a valid HTTP/1.x header name.
|
||||||
|
// HTTP/2 imposes the additional restriction that uppercase ASCII
|
||||||
|
// letters are not allowed.
|
||||||
|
//
|
||||||
|
// RFC 7230 says:
|
||||||
|
// header-field = field-name ":" OWS field-value OWS
|
||||||
|
// field-name = token
|
||||||
|
// token = 1*tchar
|
||||||
|
// tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." /
|
||||||
|
// "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA
|
||||||
|
func ValidHeaderFieldName(v string) bool {
|
||||||
|
if len(v) == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, r := range v {
|
||||||
|
if !IsTokenRune(r) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidHostHeader reports whether h is a valid host header.
|
||||||
|
func ValidHostHeader(h string) bool {
|
||||||
|
// The latest spec is actually this:
|
||||||
|
//
|
||||||
|
// http://tools.ietf.org/html/rfc7230#section-5.4
|
||||||
|
// Host = uri-host [ ":" port ]
|
||||||
|
//
|
||||||
|
// Where uri-host is:
|
||||||
|
// http://tools.ietf.org/html/rfc3986#section-3.2.2
|
||||||
|
//
|
||||||
|
// But we're going to be much more lenient for now and just
|
||||||
|
// search for any byte that's not a valid byte in any of those
|
||||||
|
// expressions.
|
||||||
|
for i := 0; i < len(h); i++ {
|
||||||
|
if !validHostByte[h[i]] {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// See the validHostHeader comment.
|
||||||
|
var validHostByte = [256]bool{
|
||||||
|
'0': true, '1': true, '2': true, '3': true, '4': true, '5': true, '6': true, '7': true,
|
||||||
|
'8': true, '9': true,
|
||||||
|
|
||||||
|
'a': true, 'b': true, 'c': true, 'd': true, 'e': true, 'f': true, 'g': true, 'h': true,
|
||||||
|
'i': true, 'j': true, 'k': true, 'l': true, 'm': true, 'n': true, 'o': true, 'p': true,
|
||||||
|
'q': true, 'r': true, 's': true, 't': true, 'u': true, 'v': true, 'w': true, 'x': true,
|
||||||
|
'y': true, 'z': true,
|
||||||
|
|
||||||
|
'A': true, 'B': true, 'C': true, 'D': true, 'E': true, 'F': true, 'G': true, 'H': true,
|
||||||
|
'I': true, 'J': true, 'K': true, 'L': true, 'M': true, 'N': true, 'O': true, 'P': true,
|
||||||
|
'Q': true, 'R': true, 'S': true, 'T': true, 'U': true, 'V': true, 'W': true, 'X': true,
|
||||||
|
'Y': true, 'Z': true,
|
||||||
|
|
||||||
|
'!': true, // sub-delims
|
||||||
|
'$': true, // sub-delims
|
||||||
|
'%': true, // pct-encoded (and used in IPv6 zones)
|
||||||
|
'&': true, // sub-delims
|
||||||
|
'(': true, // sub-delims
|
||||||
|
')': true, // sub-delims
|
||||||
|
'*': true, // sub-delims
|
||||||
|
'+': true, // sub-delims
|
||||||
|
',': true, // sub-delims
|
||||||
|
'-': true, // unreserved
|
||||||
|
'.': true, // unreserved
|
||||||
|
':': true, // IPv6address + Host expression's optional port
|
||||||
|
';': true, // sub-delims
|
||||||
|
'=': true, // sub-delims
|
||||||
|
'[': true,
|
||||||
|
'\'': true, // sub-delims
|
||||||
|
']': true,
|
||||||
|
'_': true, // unreserved
|
||||||
|
'~': true, // unreserved
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidHeaderFieldValue reports whether v is a valid "field-value" according to
|
||||||
|
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 :
|
||||||
|
//
|
||||||
|
// message-header = field-name ":" [ field-value ]
|
||||||
|
// field-value = *( field-content | LWS )
|
||||||
|
// field-content = <the OCTETs making up the field-value
|
||||||
|
// and consisting of either *TEXT or combinations
|
||||||
|
// of token, separators, and quoted-string>
|
||||||
|
//
|
||||||
|
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 :
|
||||||
|
//
|
||||||
|
// TEXT = <any OCTET except CTLs,
|
||||||
|
// but including LWS>
|
||||||
|
// LWS = [CRLF] 1*( SP | HT )
|
||||||
|
// CTL = <any US-ASCII control character
|
||||||
|
// (octets 0 - 31) and DEL (127)>
|
||||||
|
//
|
||||||
|
// RFC 7230 says:
|
||||||
|
// field-value = *( field-content / obs-fold )
|
||||||
|
// obj-fold = N/A to http2, and deprecated
|
||||||
|
// field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
||||||
|
// field-vchar = VCHAR / obs-text
|
||||||
|
// obs-text = %x80-FF
|
||||||
|
// VCHAR = "any visible [USASCII] character"
|
||||||
|
//
|
||||||
|
// http2 further says: "Similarly, HTTP/2 allows header field values
|
||||||
|
// that are not valid. While most of the values that can be encoded
|
||||||
|
// will not alter header field parsing, carriage return (CR, ASCII
|
||||||
|
// 0xd), line feed (LF, ASCII 0xa), and the zero character (NUL, ASCII
|
||||||
|
// 0x0) might be exploited by an attacker if they are translated
|
||||||
|
// verbatim. Any request or response that contains a character not
|
||||||
|
// permitted in a header field value MUST be treated as malformed
|
||||||
|
// (Section 8.1.2.6). Valid characters are defined by the
|
||||||
|
// field-content ABNF rule in Section 3.2 of [RFC7230]."
|
||||||
|
//
|
||||||
|
// This function does not (yet?) properly handle the rejection of
|
||||||
|
// strings that begin or end with SP or HTAB.
|
||||||
|
func ValidHeaderFieldValue(v string) bool {
|
||||||
|
for i := 0; i < len(v); i++ {
|
||||||
|
b := v[i]
|
||||||
|
if isCTL(b) && !isLWS(b) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
34
vendor/manifest
vendored
34
vendor/manifest
vendored
@ -5,7 +5,7 @@
|
|||||||
"importpath": "github.com/42wim/matterbridge-plus/bridge",
|
"importpath": "github.com/42wim/matterbridge-plus/bridge",
|
||||||
"repository": "https://github.com/42wim/matterbridge-plus",
|
"repository": "https://github.com/42wim/matterbridge-plus",
|
||||||
"vcs": "git",
|
"vcs": "git",
|
||||||
"revision": "e48ce1d820967506c7ea21539f6c88f7a1377d0f",
|
"revision": "63c7caabf4b92fa47060cf37beb0ed814cefbaea",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"path": "/bridge",
|
"path": "/bridge",
|
||||||
"notests": true
|
"notests": true
|
||||||
@ -14,20 +14,11 @@
|
|||||||
"importpath": "github.com/42wim/matterbridge-plus/matterclient",
|
"importpath": "github.com/42wim/matterbridge-plus/matterclient",
|
||||||
"repository": "https://github.com/42wim/matterbridge-plus",
|
"repository": "https://github.com/42wim/matterbridge-plus",
|
||||||
"vcs": "git",
|
"vcs": "git",
|
||||||
"revision": "e48ce1d820967506c7ea21539f6c88f7a1377d0f",
|
"revision": "63c7caabf4b92fa47060cf37beb0ed814cefbaea",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"path": "/matterclient",
|
"path": "/matterclient",
|
||||||
"notests": true
|
"notests": true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"importpath": "github.com/42wim/matterbridge/matterhook",
|
|
||||||
"repository": "https://github.com/42wim/matterbridge",
|
|
||||||
"vcs": "",
|
|
||||||
"revision": "6b18257185b1830bd2eff83fae30bdd2055f78b0",
|
|
||||||
"branch": "master",
|
|
||||||
"path": "/matterhook",
|
|
||||||
"notests": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"importpath": "github.com/Sirupsen/logrus",
|
"importpath": "github.com/Sirupsen/logrus",
|
||||||
"repository": "https://github.com/Sirupsen/logrus",
|
"repository": "https://github.com/Sirupsen/logrus",
|
||||||
@ -72,8 +63,8 @@
|
|||||||
"importpath": "github.com/mattermost/platform/einterfaces",
|
"importpath": "github.com/mattermost/platform/einterfaces",
|
||||||
"repository": "https://github.com/mattermost/platform",
|
"repository": "https://github.com/mattermost/platform",
|
||||||
"vcs": "git",
|
"vcs": "git",
|
||||||
"revision": "9d94869cc6a0fb9f051879437c104ccd76094380",
|
"revision": "ab52700aaa76a5623de23cd0156f5dbd9a24e264",
|
||||||
"branch": "HEAD",
|
"branch": "release-3.2",
|
||||||
"path": "/einterfaces",
|
"path": "/einterfaces",
|
||||||
"notests": true
|
"notests": true
|
||||||
},
|
},
|
||||||
@ -81,8 +72,8 @@
|
|||||||
"importpath": "github.com/mattermost/platform/model",
|
"importpath": "github.com/mattermost/platform/model",
|
||||||
"repository": "https://github.com/mattermost/platform",
|
"repository": "https://github.com/mattermost/platform",
|
||||||
"vcs": "git",
|
"vcs": "git",
|
||||||
"revision": "9d94869cc6a0fb9f051879437c104ccd76094380",
|
"revision": "ab52700aaa76a5623de23cd0156f5dbd9a24e264",
|
||||||
"branch": "HEAD",
|
"branch": "release-3.2",
|
||||||
"path": "/model",
|
"path": "/model",
|
||||||
"notests": true
|
"notests": true
|
||||||
},
|
},
|
||||||
@ -122,8 +113,8 @@
|
|||||||
{
|
{
|
||||||
"importpath": "github.com/thoj/go-ircevent",
|
"importpath": "github.com/thoj/go-ircevent",
|
||||||
"repository": "https://github.com/thoj/go-ircevent",
|
"repository": "https://github.com/thoj/go-ircevent",
|
||||||
"vcs": "",
|
"vcs": "git",
|
||||||
"revision": "da78ed515c0f0833e7a92c7cc52898176198e2c1",
|
"revision": "98c1902dd2097f38142384167e60206ba26f1585",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"notests": true
|
"notests": true
|
||||||
},
|
},
|
||||||
@ -154,6 +145,15 @@
|
|||||||
"path": "/http2/hpack",
|
"path": "/http2/hpack",
|
||||||
"notests": true
|
"notests": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"importpath": "golang.org/x/net/lex/httplex",
|
||||||
|
"repository": "https://go.googlesource.com/net",
|
||||||
|
"vcs": "git",
|
||||||
|
"revision": "bc3663df0ac92f928d419e31e0d2af22e683a5a2",
|
||||||
|
"branch": "master",
|
||||||
|
"path": "/lex/httplex",
|
||||||
|
"notests": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"importpath": "gopkg.in/gcfg.v1",
|
"importpath": "gopkg.in/gcfg.v1",
|
||||||
"repository": "https://gopkg.in/gcfg.v1",
|
"repository": "https://gopkg.in/gcfg.v1",
|
||||||
|
Reference in New Issue
Block a user