Make XMPP connexion use SRV lookup.
This commit is contained in:
parent
7113e69a91
commit
84d7c000ae
|
|
@ -17,3 +17,4 @@ SessionCookieLifeTime = 3600
|
||||||
JID = test@kingpenguin.tk
|
JID = test@kingpenguin.tk
|
||||||
PWD = test
|
PWD = test
|
||||||
PORT = 5222
|
PORT = 5222
|
||||||
|
XMPP_DEBUG = false
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -62,7 +62,7 @@ func main() {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
models.ChanRuns <- watchlog.EndRun
|
models.ChanRuns <- watchlog.EndRun
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
// models.ChanRuns <- xmpp_manager.EndRun
|
models.ChanRuns <- xmpp_manager.EndRun
|
||||||
|
|
||||||
beego.Run()
|
beego.Run()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
11
xmpp/xmpp.go
11
xmpp/xmpp.go
|
|
@ -41,7 +41,7 @@ var (
|
||||||
stream = new(xmpp.Stream)
|
stream = new(xmpp.Stream)
|
||||||
client = new(xmpp.XMPP)
|
client = new(xmpp.XMPP)
|
||||||
|
|
||||||
Debug = true
|
Debug = beego.AppConfig.String("XMPP_DEBUG") == "true"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -59,10 +59,13 @@ func Run() {
|
||||||
// Create stream and configure it as a component connection.
|
// Create stream and configure it as a component connection.
|
||||||
log.Info("XMPP Run()")
|
log.Info("XMPP Run()")
|
||||||
jid = must(xmpp.ParseJID(JidStr)).(xmpp.JID)
|
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)
|
||||||
client = must(xmpp.NewClientXMPP(stream, jid, passwdStr, &xmpp.ClientConfig{InsecureSkipVerify: true})).(*xmpp.XMPP)
|
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()
|
mainXMPP()
|
||||||
|
}
|
||||||
log.Debug("xmpp.Run Ended")
|
log.Debug("xmpp.Run Ended")
|
||||||
models.ChanRuns <- EndRun
|
models.ChanRuns <- EndRun
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue