File tree Expand file tree Collapse file tree 4 files changed +24
-1
lines changed
dns_server/src/crawler_p2p/crawler_manager Expand file tree Collapse file tree 4 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -219,6 +219,13 @@ where
219
219
ConnectivityEvent :: ConnectionClosed { peer_id } => {
220
220
self . send_crawler_event ( CrawlerEvent :: Disconnected { peer_id } ) ;
221
221
}
222
+ ConnectivityEvent :: Misbehaved {
223
+ peer_id : _,
224
+ error : _,
225
+ } => {
226
+ // Ignore all misbehave reports
227
+ // TODO: Should we ban peers when they send unexpected messages?
228
+ }
222
229
}
223
230
}
224
231
Original file line number Diff line number Diff line change @@ -274,7 +274,11 @@ where
274
274
// TODO: Use a bounded channel to send messages to the peer manager
275
275
match msg. categorize ( ) {
276
276
CategorizedMessage :: Handshake ( _) => {
277
- log:: error!( "peer {peer} sent handshaking message" ) ;
277
+ // TODO: this must be reported to the peer manager, so that it can adjust
278
+ // the peer's ban score. (We may add a separate PeerEvent for this and Backend
279
+ // can then use the now unused ConnectivityEvent::Misbehaved to forward the error
280
+ // to the peer manager.)
281
+ log:: error!( "Peer {peer} sent unexpected handshake message" ) ;
278
282
}
279
283
CategorizedMessage :: PeerManagerMessage ( msg) => {
280
284
peer_event_tx. send ( ( peer, PeerEvent :: MessageReceived { message : msg } ) ) ?
Original file line number Diff line number Diff line change @@ -157,6 +157,15 @@ pub enum ConnectivityEvent {
157
157
peer_id : PeerId ,
158
158
} ,
159
159
160
+ /// Protocol violation
161
+ Misbehaved {
162
+ /// Unique ID of the peer
163
+ peer_id : PeerId ,
164
+
165
+ /// Error code of the violation
166
+ error : P2pError ,
167
+ } ,
168
+
160
169
/// Handshake failed
161
170
HandshakeFailed {
162
171
/// Peer's address
Original file line number Diff line number Diff line change @@ -1282,6 +1282,9 @@ where
1282
1282
ConnectivityEvent :: ConnectionError { address, error } => {
1283
1283
self . handle_outbound_error ( address, error) ;
1284
1284
}
1285
+ ConnectivityEvent :: Misbehaved { peer_id, error } => {
1286
+ self . adjust_peer_score ( peer_id, error. ban_score ( ) ) ;
1287
+ }
1285
1288
ConnectivityEvent :: HandshakeFailed { address, error } => {
1286
1289
self . adjust_peer_score_on_failed_handshake ( address, error. ban_score ( ) ) ;
1287
1290
}
You can’t perform that action at this time.
0 commit comments