diff options
Diffstat (limited to 'connector/xmpp')
-rw-r--r-- | connector/xmpp/config.go | 38 | ||||
-rw-r--r-- | connector/xmpp/xmpp.go | 13 |
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 } |