]> Sergey Matveev's repositories - btrtrc.git/blob - callbacks.go
Drop support for go 1.20
[btrtrc.git] / callbacks.go
1 package torrent
2
3 import (
4         "github.com/anacrolix/torrent/mse"
5         pp "github.com/anacrolix/torrent/peer_protocol"
6 )
7
8 // These are called synchronously, and do not pass ownership of arguments (do not expect to retain
9 // data after returning from the callback). The Client and other locks may still be held. nil
10 // functions are not called.
11 type Callbacks struct {
12         // Called after a peer connection completes the BitTorrent handshake. The Client lock is not
13         // held.
14         CompletedHandshake    func(*PeerConn, InfoHash)
15         ReadMessage           func(*PeerConn, *pp.Message)
16         ReadExtendedHandshake func(*PeerConn, *pp.ExtendedHandshakeMessage)
17         PeerConnClosed        func(*PeerConn)
18
19         // Provides secret keys to be tried against incoming encrypted connections.
20         ReceiveEncryptedHandshakeSkeys mse.SecretKeyIter
21
22         ReceivedUsefulData []func(ReceivedUsefulDataEvent)
23         ReceivedRequested  []func(PeerMessageEvent)
24         DeletedRequest     []func(PeerRequestEvent)
25         SentRequest        []func(PeerRequestEvent)
26         PeerClosed         []func(*Peer)
27         NewPeer            []func(*Peer)
28 }
29
30 type ReceivedUsefulDataEvent = PeerMessageEvent
31
32 type PeerMessageEvent struct {
33         Peer    *Peer
34         Message *pp.Message
35 }
36
37 type PeerRequestEvent struct {
38         Peer *Peer
39         Request
40 }