aboutsummaryrefslogtreecommitdiff
path: root/connector/xmpp
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-02-26 22:49:27 +0100
committerAlex Auvolat <alex@adnab.me>2020-02-26 22:49:27 +0100
commit8a5ed3f507d37c52e2a68a23ced6942cc752221d (patch)
tree14e85d2f6031d6b38ad34bb7b360df3918c1c9e4 /connector/xmpp
parent775fc7b2172a632587e82cd44b9d7400ca4f4f74 (diff)
downloadeasybridge-8a5ed3f507d37c52e2a68a23ced6942cc752221d.tar.gz
easybridge-8a5ed3f507d37c52e2a68a23ced6942cc752221d.zip
Initial ability to configure accounts from web interface
Diffstat (limited to 'connector/xmpp')
-rw-r--r--connector/xmpp/config.go38
-rw-r--r--connector/xmpp/xmpp.go13
2 files changed, 42 insertions, 9 deletions
diff --git a/connector/xmpp/config.go b/connector/xmpp/config.go
new file mode 100644
index 0000000..6fd5f9b
--- /dev/null
+++ b/connector/xmpp/config.go
@@ -0,0 +1,38 @@
+package xmpp
+
+import (
+ . "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector"
+)
+
+func init() {
+ Register("xmpp", ConfigSchema{
+ &ConfigEntry{
+ Name: "jid",
+ Description: "JID",
+ Required: true,
+ },
+ &ConfigEntry{
+ Name: "password",
+ Description: "Password",
+ Required: true,
+ IsPassword: true,
+ },
+ &ConfigEntry{
+ Name: "nickname",
+ Description: "Nickname in MUCs",
+ Required: true,
+ },
+ &ConfigEntry{
+ Name: "port",
+ Description: "Port",
+ IsNumeric: true,
+ Default: "6667",
+ },
+ &ConfigEntry{
+ Name: "ssl",
+ Description: "Use SSL",
+ IsBoolean: true,
+ Default: "true",
+ },
+ })
+}
diff --git a/connector/xmpp/xmpp.go b/connector/xmpp/xmpp.go
index 698016f..f1a75b2 100644
--- a/connector/xmpp/xmpp.go
+++ b/connector/xmpp/xmpp.go
@@ -55,11 +55,6 @@ func (xm *XMPP) Configure(c Configuration) error {
// Parse and validate configuration
var err error
- xm.server, err = c.GetString("server")
- if err != nil {
- return err
- }
-
xm.port, err = c.GetInt("port", 5222)
if err != nil {
return err
@@ -78,9 +73,7 @@ func (xm *XMPP) Configure(c Configuration) error {
if len(jid_parts) != 2 {
return fmt.Errorf("Invalid JID: %s", xm.jid)
}
- if jid_parts[1] != xm.server {
- return fmt.Errorf("JID %s not on server %s", xm.jid, xm.server)
- }
+ xm.server = jid_parts[1]
xm.jid_localpart = jid_parts[0]
xm.nickname, _ = c.GetString("nickname", xm.jid_localpart)
@@ -353,7 +346,9 @@ func (xm *XMPP) Send(event *Event) error {
}
func (xm *XMPP) Close() {
- xm.conn.Close()
+ if xm.conn != nil {
+ xm.conn.Close()
+ }
xm.conn = nil
xm.connectorLoopNum += 1
}