forked from External/grumble
grumble: add Debugf print method to Client and Server.
This commit is contained in:
parent
e6d4e0c453
commit
c4e05027f8
2 changed files with 13 additions and 0 deletions
|
|
@ -91,6 +91,11 @@ type Client struct {
|
|||
PluginIdentity string
|
||||
}
|
||||
|
||||
// Debugf implements debug-level printing for Clients.
|
||||
func (client *Client) Debugf(format string, v ...interface{}) {
|
||||
client.Printf(format, v...)
|
||||
}
|
||||
|
||||
// Is the client a registered user?
|
||||
func (client *Client) IsRegistered() bool {
|
||||
return client.user != nil
|
||||
|
|
@ -627,6 +632,7 @@ func (client *Client) sendChannelTree(channel *Channel) {
|
|||
|
||||
// Try to do a crypto resync
|
||||
func (client *Client) cryptResync() {
|
||||
client.Debugf("requesting crypt resync")
|
||||
goodElapsed := time.Now().Unix() - client.crypt.LastGoodTime
|
||||
if goodElapsed > 5 {
|
||||
requestElapsed := time.Now().Unix() - client.lastResync
|
||||
|
|
|
|||
|
|
@ -153,6 +153,11 @@ func NewServer(id int64) (s *Server, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// Debugf implements debug-level printing for Servers.
|
||||
func (server *Server) Debugf(format string, v ...interface{}) {
|
||||
server.Printf(format, v...)
|
||||
}
|
||||
|
||||
// Get a pointer to the root channel
|
||||
func (server *Server) RootChannel() *Channel {
|
||||
root, exists := server.Channels[0]
|
||||
|
|
@ -996,6 +1001,7 @@ func (server *Server) handleUdpPacket(udpaddr *net.UDPAddr, buf []byte) {
|
|||
if ok {
|
||||
err := client.crypt.Decrypt(plain, buf)
|
||||
if err != nil {
|
||||
client.Debugf("unable to decrypt incoming packet, requesting resync: %v", err)
|
||||
client.cryptResync()
|
||||
return
|
||||
}
|
||||
|
|
@ -1006,6 +1012,7 @@ func (server *Server) handleUdpPacket(udpaddr *net.UDPAddr, buf []byte) {
|
|||
for _, client := range hostclients {
|
||||
err := client.crypt.Decrypt(plain[0:], buf)
|
||||
if err != nil {
|
||||
client.Debugf("unable to decrypt incoming packet, requesting resync: %v", err)
|
||||
client.cryptResync()
|
||||
return
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue