Add ReadExtendedHandshake callback
This commit is contained in:
parent
9d0ea15044
commit
dd906f8fa7
|
@ -7,6 +7,7 @@ import (
|
|||
// These are called synchronously, and do not pass ownership. The Client and other locks may still
|
||||
// be held. nil functions are not called.
|
||||
type Callbacks struct {
|
||||
CompletedHandshake func(_ *PeerConn, infoHash InfoHash)
|
||||
ReadMessage func(*PeerConn, *pp.Message)
|
||||
CompletedHandshake func(_ *PeerConn, infoHash InfoHash)
|
||||
ReadMessage func(*PeerConn, *pp.Message)
|
||||
ReadExtendedHandshake func(*PeerConn, *pp.ExtendedHandshakeMessage)
|
||||
}
|
||||
|
|
|
@ -1195,6 +1195,9 @@ func (c *PeerConn) onReadExtendedMsg(id pp.ExtensionNumber, payload []byte) (err
|
|||
c.logger.Printf("error parsing extended handshake message %q: %s", payload, err)
|
||||
return errors.Wrap(err, "unmarshalling extended handshake payload")
|
||||
}
|
||||
if cb := cl.config.Callbacks.ReadExtendedHandshake; cb != nil {
|
||||
cb(c, &d)
|
||||
}
|
||||
//c.logger.WithDefaultLevel(log.Debug).Printf("received extended handshake message:\n%s", spew.Sdump(d))
|
||||
if d.Reqq != 0 {
|
||||
c.PeerMaxRequests = d.Reqq
|
||||
|
|
Loading…
Reference in New Issue