update xmpp vendor to upstream

This commit is contained in:
Martin/Geno 2019-06-10 01:00:36 +02:00
parent 9cb98c6cbc
commit 93d872a1c9
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
4 changed files with 19 additions and 44 deletions

4
.gitmodules vendored
View File

@ -1,4 +0,0 @@
[submodule "vendor/gosrc.io/xmpp"]
path = vendor/gosrc.io/xmpp
url = https://github.com/genofire/go-xmpp
branch = all

View File

@ -16,15 +16,26 @@ type Config struct {
comp Component comp Component
} }
func (c *Config) Start() error { func (c *Config) Start() (err error) {
c.xmpp = &xmpp.Component{Host: c.Host, Secret: c.Secret} c.xmpp, err = xmpp.NewComponent(xmpp.ComponentOptions{
err := c.xmpp.Connect(c.Connection) Domain: c.Host,
Secret: c.Secret,
Address: c.Connection,
Name: c.Type,
Category: "gateway",
Type: "service",
})
if err != nil { if err != nil {
return err return
}
cm := xmpp.NewStreamManager(c.xmpp, nil)
err = cm.Start()
if err != nil {
return
} }
out, err := c.comp.Connect() out, err := c.comp.Connect()
if err != nil { if err != nil {
return err return
} }
go c.sender(out) go c.sender(out)

View File

@ -6,12 +6,7 @@ import (
) )
func (c *Config) receiver() { func (c *Config) receiver() {
for { for packet := range c.xmpp.Recv() {
packet, err := c.xmpp.ReadPacket()
if err != nil {
log.WithField("type", c.Type).Panicf("connection closed%s", err)
return
}
p, back := c.receiving(packet) p, back := c.receiving(packet)
if p == nil { if p == nil {
continue 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) logger := log.WithField("type", c.Type)
switch p := packet.(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) { 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: case *xmpp.DiscoItems:
if p.Type == "get" { if p.Type == "get" {
iq := xmpp.NewIQ("result", attrs.To, attrs.From, attrs.Id, "en") 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, "id": p.PacketAttrs.Id,
}).Debug(p.XMPPFormat()) }).Debug(p.XMPPFormat())
} }
return packet, false return p, false
case xmpp.Presence: case xmpp.Presence:
logger.Debug("received presence:", p.Type) logger.Debug("received presence:", p.Type)

1
vendor/gosrc.io/xmpp generated vendored

@ -1 +0,0 @@
Subproject commit f78a014b96d53478e43b9adadd7bd3b5f11b0416