From 1f365c716eae44b64dc5bdace5cb70441d7eb4c2 Mon Sep 17 00:00:00 2001 From: tytan652 <17492366+tytan652@users.noreply.github.com> Date: Sat, 31 Jul 2021 17:26:36 +0200 Subject: [PATCH] Add support for anonymous connection (xmpp) (#1548) --- bridge/xmpp/xmpp.go | 16 +++++++++++++--- matterbridge.toml.sample | 8 ++++++-- 2 files changed, 19 insertions(+), 5 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 } diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index 9e32b49b..b6221757 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -223,12 +223,16 @@ UseRelayMsg=false #REQUIRED Server="jabber.example.com:5222" +#Use anonymous MUC login +#OPTIONAL (default false) +Anonymous=false + #Jid -#REQUIRED +#REQUIRED if Anonymous=false Jid="user@example.com" #Password -#REQUIRED +#REQUIRED if Anonymous=false Password="yourpass" #MUC