29 lines
933 B
Go
29 lines
933 B
Go
package torrent
|
|
|
|
import (
|
|
"github.com/anacrolix/torrent/mse"
|
|
pp "github.com/anacrolix/torrent/peer_protocol"
|
|
)
|
|
|
|
// These are called synchronously, and do not pass ownership of arguments (do not expect to retain
|
|
// data after returning from the callback). The Client and other locks may still be held. nil
|
|
// functions are not called.
|
|
type Callbacks struct {
|
|
// Called after a peer connection completes the BitTorrent handshake. The Client lock is not
|
|
// held.
|
|
CompletedHandshake func(*PeerConn, InfoHash)
|
|
ReadMessage func(*PeerConn, *pp.Message)
|
|
ReadExtendedHandshake func(*PeerConn, *pp.ExtendedHandshakeMessage)
|
|
PeerConnClosed func(*PeerConn)
|
|
|
|
// Provides secret keys to be tried against incoming encrypted connections.
|
|
ReceiveEncryptedHandshakeSkeys mse.SecretKeyIter
|
|
|
|
ReceivedUsefulData []func(ReceivedUsefulDataEvent)
|
|
}
|
|
|
|
type ReceivedUsefulDataEvent struct {
|
|
Peer *Peer
|
|
Message *pp.Message
|
|
}
|