update xmpp vendor to upstream
This commit is contained in:
parent
9cb98c6cbc
commit
93d872a1c9
|
@ -1,4 +0,0 @@
|
|||
[submodule "vendor/gosrc.io/xmpp"]
|
||||
path = vendor/gosrc.io/xmpp
|
||||
url = https://github.com/genofire/go-xmpp
|
||||
branch = all
|
|
@ -16,15 +16,26 @@ type Config struct {
|
|||
comp Component
|
||||
}
|
||||
|
||||
func (c *Config) Start() error {
|
||||
c.xmpp = &xmpp.Component{Host: c.Host, Secret: c.Secret}
|
||||
err := c.xmpp.Connect(c.Connection)
|
||||
func (c *Config) Start() (err error) {
|
||||
c.xmpp, err = xmpp.NewComponent(xmpp.ComponentOptions{
|
||||
Domain: c.Host,
|
||||
Secret: c.Secret,
|
||||
Address: c.Connection,
|
||||
Name: c.Type,
|
||||
Category: "gateway",
|
||||
Type: "service",
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
return
|
||||
}
|
||||
cm := xmpp.NewStreamManager(c.xmpp, nil)
|
||||
err = cm.Start()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
out, err := c.comp.Connect()
|
||||
if err != nil {
|
||||
return err
|
||||
return
|
||||
}
|
||||
|
||||
go c.sender(out)
|
||||
|
|
|
@ -6,12 +6,7 @@ import (
|
|||
)
|
||||
|
||||
func (c *Config) receiver() {
|
||||
for {
|
||||
packet, err := c.xmpp.ReadPacket()
|
||||
if err != nil {
|
||||
log.WithField("type", c.Type).Panicf("connection closed%s", err)
|
||||
return
|
||||
}
|
||||
for packet := range c.xmpp.Recv() {
|
||||
p, back := c.receiving(packet)
|
||||
if p == nil {
|
||||
continue
|
||||
|
@ -24,7 +19,7 @@ func (c *Config) receiver() {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *Config) receiving(packet xmpp.Packet) (xmpp.Packet, bool) {
|
||||
func (c *Config) receiving(packet interface{}) (xmpp.Packet, bool) {
|
||||
logger := log.WithField("type", c.Type)
|
||||
|
||||
switch p := packet.(type) {
|
||||
|
@ -36,32 +31,6 @@ func (c *Config) receiving(packet xmpp.Packet) (xmpp.Packet, bool) {
|
|||
})
|
||||
|
||||
switch inner := p.Payload[0].(type) {
|
||||
case *xmpp.DiscoInfo:
|
||||
if p.Type == "get" {
|
||||
iq := xmpp.NewIQ("result", attrs.To, attrs.From, attrs.Id, "en")
|
||||
var identity xmpp.Identity
|
||||
if inner.Node == "" {
|
||||
identity = xmpp.Identity{
|
||||
Name: c.Type,
|
||||
Category: "gateway",
|
||||
Type: "service",
|
||||
}
|
||||
}
|
||||
|
||||
payload := xmpp.DiscoInfo{
|
||||
Identity: identity,
|
||||
Features: []xmpp.Feature{
|
||||
{Var: xmpp.NSDiscoInfo},
|
||||
{Var: xmpp.NSDiscoItems},
|
||||
{Var: xmpp.NSMsgReceipts},
|
||||
{Var: xmpp.NSMsgChatMarkers},
|
||||
{Var: xmpp.NSMsgChatStateNotifications},
|
||||
},
|
||||
}
|
||||
iq.AddPayload(&payload)
|
||||
loggerIQ.Debug("disco info")
|
||||
return iq, true
|
||||
}
|
||||
case *xmpp.DiscoItems:
|
||||
if p.Type == "get" {
|
||||
iq := xmpp.NewIQ("result", attrs.To, attrs.From, attrs.Id, "en")
|
||||
|
@ -98,7 +67,7 @@ func (c *Config) receiving(packet xmpp.Packet) (xmpp.Packet, bool) {
|
|||
"id": p.PacketAttrs.Id,
|
||||
}).Debug(p.XMPPFormat())
|
||||
}
|
||||
return packet, false
|
||||
return p, false
|
||||
|
||||
case xmpp.Presence:
|
||||
logger.Debug("received presence:", p.Type)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit f78a014b96d53478e43b9adadd7bd3b5f11b0416
|
Reference in New Issue