[WIP] Fix ban by software version, some other under-hood changes
- Use updated version of upstream go-xmpp + fixes on client-side - Introduce golangci-lint v2 + fixes - Move especially noisy debugging stuff to separate config handles to be able to switch them off - Add a bit debug to ban by software path
This commit is contained in:
57
vendor/github.com/xmppo/go-xmpp/xmpp_ping.go
generated
vendored
Normal file
57
vendor/github.com/xmppo/go-xmpp/xmpp_ping.go
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
package xmpp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (c *Client) PingC2S(jid, server string) error {
|
||||
if jid == "" {
|
||||
jid = c.jid
|
||||
}
|
||||
if server == "" {
|
||||
server = c.domain
|
||||
}
|
||||
_, err := fmt.Fprintf(c.stanzaWriter, "<iq from='%s' to='%s' id='%s' type='get'>"+
|
||||
"<ping xmlns='urn:xmpp:ping'/>"+
|
||||
"</iq>\n",
|
||||
xmlEscape(jid), xmlEscape(server), getUUID())
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) PingS2S(fromServer, toServer string) error {
|
||||
_, err := fmt.Fprintf(c.stanzaWriter, "<iq from='%s' to='%s' id='%s' type='get'>"+
|
||||
"<ping xmlns='urn:xmpp:ping'/>"+
|
||||
"</iq>\n",
|
||||
xmlEscape(fromServer), xmlEscape(toServer), getUUID())
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) SendResultPing(id, toServer string) error {
|
||||
_, err := fmt.Fprintf(c.stanzaWriter, "<iq type='result' to='%s' id='%s'/>\n",
|
||||
xmlEscape(toServer), xmlEscape(id))
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) sendPeriodicPings() {
|
||||
for range c.periodicPingTicker.C {
|
||||
// Reset ticker for periodic pings if configured.
|
||||
if c.periodicPings {
|
||||
c.periodicPingTicker.Reset(c.periodicPingPeriod)
|
||||
}
|
||||
c.periodicPingID = getUUID()
|
||||
c.periodicPingReply = false
|
||||
_, err := fmt.Fprintf(c.stanzaWriter, "<iq from='%s' to='%s' id='%s' type='get'>"+
|
||||
"<ping xmlns='urn:xmpp:ping'/></iq>\n",
|
||||
xmlEscape(c.jid), xmlEscape(c.domain), c.periodicPingID)
|
||||
if err != nil {
|
||||
c.Close()
|
||||
}
|
||||
time.Sleep(c.periodicPingTimeout)
|
||||
if !c.periodicPingReply {
|
||||
c.shutdown = true
|
||||
fmt.Fprintf(c.stanzaWriter, "</stream:stream>\n")
|
||||
c.conn.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user