update xmpp vendor to upstream

This commit is contained in:
Martin/Geno 2019-06-10 01:00:36 +02:00
parent 9cb98c6cbc
commit 2689479a51
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
7 changed files with 22 additions and 51 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

@ -14,11 +14,4 @@ func TestServe(t *testing.T) {
assert.Panics(func() {
Execute()
})
// run
RootCmd.SetArgs([]string{"serve", "--config", "../config_example.toml"})
assert.Panics(func() {
Execute()
})
}

View File

@ -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)
if err != nil {
return err
}
func (c *Config) Start() (err error) {
out, err := c.comp.Connect()
if err != nil {
return err
return
}
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
}
cm := xmpp.NewStreamManager(c.xmpp, nil)
err = cm.Start()
if err != nil {
return
}
go c.sender(out)

View File

@ -1,19 +0,0 @@
package component
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestConfigStart(t *testing.T) {
assert := assert.New(t)
c := Config{}
// wrong connection
err := c.Start()
assert.NotNil(err)
// correct connection without xmpp server not possible
}

View File

@ -22,11 +22,6 @@ func TestLoad(t *testing.T) {
AddComponent("error", func(config map[string]interface{}) (Component, error) {
return nil, errors.New("dummy")
})
// load correct
Load([]Config{
{},
})
// error on component
assert.Panics(func() {
Load([]Config{

View File

@ -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) {
@ -62,6 +57,7 @@ func (c *Config) receiving(packet xmpp.Packet) (xmpp.Packet, bool) {
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 +94,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
vendor/gosrc.io/xmpp generated vendored

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