Make XMPP connexion use SRV lookup.

This commit is contained in:
Chteufleur 2016-12-30 09:10:21 +01:00
parent 7113e69a91
commit 84d7c000ae
3 changed files with 9 additions and 5 deletions

View File

@ -17,3 +17,4 @@ SessionCookieLifeTime = 3600
JID = test@kingpenguin.tk
PWD = test
PORT = 5222
XMPP_DEBUG = false

View File

@ -62,7 +62,7 @@ func main() {
time.Sleep(1 * time.Second)
models.ChanRuns <- watchlog.EndRun
time.Sleep(1 * time.Second)
// models.ChanRuns <- xmpp_manager.EndRun
models.ChanRuns <- xmpp_manager.EndRun
beego.Run()
}

View File

@ -41,7 +41,7 @@ var (
stream = new(xmpp.Stream)
client = new(xmpp.XMPP)
Debug = true
Debug = beego.AppConfig.String("XMPP_DEBUG") == "true"
)
func init() {
@ -59,10 +59,13 @@ func Run() {
// Create stream and configure it as a component connection.
log.Info("XMPP Run()")
jid = must(xmpp.ParseJID(JidStr)).(xmpp.JID)
stream = must(xmpp.NewStream(jid.Domain+":"+serverPort, &xmpp.StreamConfig{LogStanzas: Debug})).(*xmpp.Stream)
addrs, err := xmpp.HomeServerAddrs(jid)
if err == nil && len(addrs) > 0 {
stream = must(xmpp.NewStream(addrs[0], &xmpp.StreamConfig{LogStanzas: Debug})).(*xmpp.Stream)
client = must(xmpp.NewClientXMPP(stream, jid, passwdStr, &xmpp.ClientConfig{InsecureSkipVerify: true})).(*xmpp.XMPP)
mainXMPP()
}
log.Debug("xmpp.Run Ended")
models.ChanRuns <- EndRun
}