diff options
author | tytan652 <17492366+tytan652@users.noreply.github.com> | 2021-07-31 17:26:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-31 17:26:36 +0200 |
commit | 1f365c716eae44b64dc5bdace5cb70441d7eb4c2 (patch) | |
tree | 642665c345ba8be6bd8870271da0ac61656b0fba /bridge | |
parent | 9efcc41ab23aaabb935ad18cbb4122579a27a728 (diff) | |
download | matterbridge-msglm-1f365c716eae44b64dc5bdace5cb70441d7eb4c2.tar.gz matterbridge-msglm-1f365c716eae44b64dc5bdace5cb70441d7eb4c2.tar.bz2 matterbridge-msglm-1f365c716eae44b64dc5bdace5cb70441d7eb4c2.zip |
Add support for anonymous connection (xmpp) (#1548)
Diffstat (limited to 'bridge')
-rw-r--r-- | bridge/xmpp/xmpp.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/bridge/xmpp/xmpp.go b/bridge/xmpp/xmpp.go index 07ae8a28..6a0564ea 100644 --- a/bridge/xmpp/xmpp.go +++ b/bridge/xmpp/xmpp.go @@ -169,11 +169,21 @@ func (b *Bxmpp) postSlackCompatibleWebhook(msg config.Message) error { } func (b *Bxmpp) createXMPP() error { - if !strings.Contains(b.GetString("Jid"), "@") { - return fmt.Errorf("the Jid %s doesn't contain an @", b.GetString("Jid")) + var serverName string + switch { + case !b.GetBool("Anonymous"): + if !strings.Contains(b.GetString("Jid"), "@") { + return fmt.Errorf("the Jid %s doesn't contain an @", b.GetString("Jid")) + } + serverName = strings.Split(b.GetString("Jid"), "@")[1] + case !strings.Contains(b.GetString("Server"), ":"): + serverName = strings.Split(b.GetString("Server"), ":")[0] + default: + serverName = b.GetString("Server") } + tc := &tls.Config{ - ServerName: strings.Split(b.GetString("Jid"), "@")[1], + ServerName: serverName, InsecureSkipVerify: b.GetBool("SkipTLSVerify"), // nolint: gosec } |