feat(shares): reply to distributed searches with our matching files

Wire the incoming server FileSearch (code 26): the handler now forwards
ServerMessage::FileSearchRequest -> ClientOperation::IncomingSearch instead of
just logging. The client matches the query against its shares and, if anything
matches, sends a FileSearchResponse to the searcher — connecting to them first
(GetPeerAddress -> outbound P) and flushing the response on PeerConnected when
not already connected. GetPeerAddressResponse now also caches peer addresses
for the serve path. Adds build_search_response + a unit test.
This commit is contained in:
michel
2026-07-19 18:39:05 +02:00
parent bcfe56e74f
commit 9b6e533bed
3 changed files with 231 additions and 8 deletions
+22
View File
@@ -149,6 +149,13 @@ pub enum ServerMessage {
token: u32,
query: String,
},
/// A search the server distributed to us from another user; if it matches
/// our shares we reply with a FileSearchResponse.
FileSearchRequest {
username: String,
token: u32,
query: String,
},
#[allow(dead_code)]
ConnectToPeer(Peer),
PierceFirewall(u32),
@@ -508,6 +515,21 @@ impl ServerActor {
ServerMessage::FileSearch { token, query } => {
self.file_search(token, &query);
}
ServerMessage::FileSearchRequest {
username,
token,
query,
} => {
if let Err(e) =
self.client_channel.send(ClientOperation::IncomingSearch {
username,
token,
query,
})
{
error!("[server] forward IncomingSearch: {}", e);
}
}
}
}