mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-21 10:12:00 -08:00
Fix vendored xmpp (#1661)
This commit is contained in:
parent
ae2ad824a9
commit
6cb359cb80
2
go.mod
2
go.mod
@ -24,7 +24,7 @@ require (
|
||||
github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16
|
||||
github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20211016222428-79310a412696
|
||||
github.com/matterbridge/discordgo v0.21.2-0.20210201201054-fb39a175b4f7
|
||||
github.com/matterbridge/go-xmpp v0.0.0-20210731150933-5702291c239f
|
||||
github.com/matterbridge/go-xmpp v0.0.0-20211030125215-791a06c5f1be
|
||||
github.com/matterbridge/gozulipbot v0.0.0-20211023205727-a19d6c1f3b75
|
||||
github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba
|
||||
github.com/matterbridge/matterclient v0.0.0-20211107234719-faca3cd42315
|
||||
|
4
go.sum
4
go.sum
@ -812,8 +812,8 @@ github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20211016222428-79310a412696 h1
|
||||
github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20211016222428-79310a412696/go.mod h1:c6MxwqHD+0HvtAJjsHMIdPCiAwGiQwPRPTp69ACMg8A=
|
||||
github.com/matterbridge/discordgo v0.21.2-0.20210201201054-fb39a175b4f7 h1:4J2YZuY8dIYrxbLMsWGqPZb/B59ygCwSBkyZHez5PSY=
|
||||
github.com/matterbridge/discordgo v0.21.2-0.20210201201054-fb39a175b4f7/go.mod h1:411nZYv0UMMrtppR5glXop1foboJiFAowy+42U+Ahvw=
|
||||
github.com/matterbridge/go-xmpp v0.0.0-20210731150933-5702291c239f h1:1hfavl4YOoRjgTBWezeX8WXCGnhrxnfEgQtb38wQnyg=
|
||||
github.com/matterbridge/go-xmpp v0.0.0-20210731150933-5702291c239f/go.mod h1:ECDRehsR9TYTKCAsRS8/wLeOk6UUqDydw47ln7wG41Q=
|
||||
github.com/matterbridge/go-xmpp v0.0.0-20211030125215-791a06c5f1be h1:zlirT+LngOJ60G6FVzI87DljGZLUnfNzmXja61EjtYM=
|
||||
github.com/matterbridge/go-xmpp v0.0.0-20211030125215-791a06c5f1be/go.mod h1:ECDRehsR9TYTKCAsRS8/wLeOk6UUqDydw47ln7wG41Q=
|
||||
github.com/matterbridge/gozulipbot v0.0.0-20211023205727-a19d6c1f3b75 h1:GslZKF7lW7oSisycGLpxPO+TnKJuA4VZuTWIfYZrClc=
|
||||
github.com/matterbridge/gozulipbot v0.0.0-20211023205727-a19d6c1f3b75/go.mod h1:yAjnZ34DuDyPHMPHHjOsTk/FefW4JJjoMMCGt/8uuQA=
|
||||
github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba h1:XleOY4IjAEIcxAh+IFwT5JT5Ze3RHiYz6m+4ZfZ0rc0=
|
||||
|
44
vendor/github.com/matterbridge/go-xmpp/xmpp.go
generated
vendored
44
vendor/github.com/matterbridge/go-xmpp/xmpp.go
generated
vendored
@ -43,7 +43,7 @@ const (
|
||||
)
|
||||
|
||||
// Default TLS configuration options
|
||||
var DefaultConfig tls.Config
|
||||
var DefaultConfig = &tls.Config{}
|
||||
|
||||
// DebugWriter is the writer used to write debugging output to.
|
||||
var DebugWriter io.Writer = os.Stderr
|
||||
@ -76,7 +76,7 @@ func containsIgnoreCase(s, substr string) bool {
|
||||
return strings.Contains(s, substr)
|
||||
}
|
||||
|
||||
func connect(host, user, passwd string) (net.Conn, error) {
|
||||
func connect(host, user, passwd string, timeout time.Duration) (net.Conn, error) {
|
||||
addr := host
|
||||
|
||||
if strings.TrimSpace(host) == "" {
|
||||
@ -117,7 +117,7 @@ func connect(host, user, passwd string) (net.Conn, error) {
|
||||
}
|
||||
}
|
||||
|
||||
c, err := net.Dial("tcp", addr)
|
||||
c, err := net.DialTimeout("tcp", addr, timeout)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -153,6 +153,10 @@ type Options struct {
|
||||
// Password supplies the password to use for authentication with the remote server.
|
||||
Password string
|
||||
|
||||
// DialTimeout is the time limit for establishing a connection. A
|
||||
// DialTimeout of zero means no timeout.
|
||||
DialTimeout time.Duration
|
||||
|
||||
// Resource specifies an XMPP client resource, like "bot", instead of accepting one
|
||||
// from the server. Use "" to let the server generate one for your client.
|
||||
Resource string
|
||||
@ -221,7 +225,7 @@ func (o Options) NewClient() (*Client, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
c, err := connect(host, o.User, o.Password)
|
||||
c, err := connect(host, o.User, o.Password, o.DialTimeout)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -237,11 +241,11 @@ func (o Options) NewClient() (*Client, error) {
|
||||
var tlsconn *tls.Conn
|
||||
if o.TLSConfig != nil {
|
||||
tlsconn = tls.Client(c, o.TLSConfig)
|
||||
host = o.TLSConfig.ServerName
|
||||
} else {
|
||||
DefaultConfig.ServerName = host
|
||||
newconfig := DefaultConfig
|
||||
newconfig := DefaultConfig.Clone()
|
||||
newconfig.ServerName = host
|
||||
tlsconn = tls.Client(c, &newconfig)
|
||||
tlsconn = tls.Client(c, newconfig)
|
||||
}
|
||||
if err = tlsconn.Handshake(); err != nil {
|
||||
return nil, err
|
||||
@ -331,7 +335,6 @@ func cnonce() string {
|
||||
}
|
||||
|
||||
func (c *Client) init(o *Options) error {
|
||||
|
||||
var domain string
|
||||
var user string
|
||||
a := strings.SplitN(o.User, "@", 2)
|
||||
@ -497,7 +500,7 @@ func (c *Client) init(o *Options) error {
|
||||
c.domain = domain
|
||||
|
||||
if o.Session {
|
||||
//if server support session, open it
|
||||
// if server support session, open it
|
||||
fmt.Fprintf(c.conn, "<iq to='%s' type='set' id='%x'><session xmlns='%s'/></iq>", xmlEscape(domain), cookie, nsSession)
|
||||
}
|
||||
|
||||
@ -532,9 +535,8 @@ func (c *Client) startTLSIfRequired(f *streamFeatures, o *Options, domain string
|
||||
|
||||
tc := o.TLSConfig
|
||||
if tc == nil {
|
||||
tc = new(tls.Config)
|
||||
*tc = DefaultConfig
|
||||
//TODO(scott): we should consider using the server's address or reverse lookup
|
||||
tc = DefaultConfig.Clone()
|
||||
// TODO(scott): we should consider using the server's address or reverse lookup
|
||||
tc.ServerName = domain
|
||||
}
|
||||
t := tls.Client(c.conn, tc)
|
||||
@ -652,6 +654,10 @@ func (c *Client) Recv() (stanza interface{}, err error) {
|
||||
// Handle Pubsub notifications
|
||||
switch v.Event.Items.Node {
|
||||
case XMPPNS_AVATAR_PEP_METADATA:
|
||||
if len(v.Event.Items.Items) == 0 {
|
||||
return AvatarMetadata{}, errors.New("No avatar metadata items available")
|
||||
}
|
||||
|
||||
return handleAvatarMetadata(v.Event.Items.Items[0].Body,
|
||||
v.From)
|
||||
// I am not sure whether this can even happen.
|
||||
@ -797,10 +803,18 @@ func (c *Client) Recv() (stanza interface{}, err error) {
|
||||
|
||||
switch p.Node {
|
||||
case XMPPNS_AVATAR_PEP_DATA:
|
||||
if len(p.Items) == 0 {
|
||||
return AvatarData{}, errors.New("No avatar data items available")
|
||||
}
|
||||
|
||||
return handleAvatarData(p.Items[0].Body,
|
||||
v.From,
|
||||
p.Items[0].ID)
|
||||
case XMPPNS_AVATAR_PEP_METADATA:
|
||||
if len(p.Items) == 0 {
|
||||
return AvatarMetadata{}, errors.New("No avatar metadata items available")
|
||||
}
|
||||
|
||||
return handleAvatarMetadata(p.Items[0].Body,
|
||||
v.From)
|
||||
default:
|
||||
@ -842,8 +856,10 @@ func (c *Client) Recv() (stanza interface{}, err error) {
|
||||
return Chat{}, err
|
||||
}
|
||||
|
||||
return IQ{ID: v.ID, From: v.From, To: v.To, Type: v.Type,
|
||||
Query: res}, nil
|
||||
return IQ{
|
||||
ID: v.ID, From: v.From, To: v.To, Type: v.Type,
|
||||
Query: res,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
vendor/github.com/matterbridge/go-xmpp/xmpp_information_query.go
generated
vendored
2
vendor/github.com/matterbridge/go-xmpp/xmpp_information_query.go
generated
vendored
@ -39,7 +39,7 @@ func (c *Client) RawInformationQuery(from, to, id, iqType, requestNamespace, bod
|
||||
return id, err
|
||||
}
|
||||
|
||||
// rawInformation send a IQ request with the the payload body to the server
|
||||
// rawInformation send a IQ request with the payload body to the server
|
||||
func (c *Client) RawInformation(from, to, id, iqType, body string) (string, error) {
|
||||
const xmlIQ = "<iq from='%s' to='%s' id='%s' type='%s'>%s</iq>"
|
||||
_, err := fmt.Fprintf(c.conn, xmlIQ, xmlEscape(from), xmlEscape(to), id, iqType, body)
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -180,7 +180,7 @@ github.com/matterbridge/Rocket.Chat.Go.SDK/rest
|
||||
# github.com/matterbridge/discordgo v0.21.2-0.20210201201054-fb39a175b4f7
|
||||
## explicit; go 1.10
|
||||
github.com/matterbridge/discordgo
|
||||
# github.com/matterbridge/go-xmpp v0.0.0-20210731150933-5702291c239f
|
||||
# github.com/matterbridge/go-xmpp v0.0.0-20211030125215-791a06c5f1be
|
||||
## explicit
|
||||
github.com/matterbridge/go-xmpp
|
||||
# github.com/matterbridge/gozulipbot v0.0.0-20211023205727-a19d6c1f3b75
|
||||
|
Loading…
Reference in New Issue
Block a user