mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 06:06:10 -04:00
search spy
This commit is contained in:
parent
54ee6509d1
commit
41251fdd9e
6 changed files with 26 additions and 5 deletions
|
@ -907,6 +907,7 @@ void p3turtle::handleSearchRequest(RsTurtleSearchRequestItem *item)
|
|||
req.origin = item->PeerId() ;
|
||||
req.time_stamp = time(NULL) ;
|
||||
req.depth = item->depth ;
|
||||
req.keywords = item->GetKeywords() ;
|
||||
|
||||
// If it's not for us, perform a local search. If something found, forward the search result back.
|
||||
|
||||
|
@ -2079,6 +2080,7 @@ void p3turtle::getInfo( std::vector<std::vector<std::string> >& hashes_info,
|
|||
info.source_peer_id = it->second.origin ;
|
||||
info.age = now - it->second.time_stamp ;
|
||||
info.depth = it->second.depth ;
|
||||
info.keywords = it->second.keywords ;
|
||||
|
||||
search_reqs_info.push_back(info) ;
|
||||
}
|
||||
|
|
|
@ -172,6 +172,7 @@ class TurtleRequestInfo
|
|||
uint32_t time_stamp ; // last time the tunnel was actually used. Used for cleaning old tunnels.
|
||||
int depth ; // depth of the request. Used to optimize tunnel length.
|
||||
std::set<uint32_t> responses; // responses to this request. Useful to avoid spamming tunnel responses.
|
||||
std::string keywords;
|
||||
};
|
||||
|
||||
class TurtleTunnel
|
||||
|
|
|
@ -71,7 +71,9 @@ class RsTurtleSearchRequestItem: public RsTurtleItem
|
|||
virtual RsTurtleSearchRequestItem *clone() const = 0 ; // used for cloning in routing methods
|
||||
|
||||
virtual void performLocalSearch(std::list<TurtleFileInfo>&) const = 0 ; // abstracts the search method
|
||||
|
||||
|
||||
virtual std::string GetKeywords() = 0;
|
||||
|
||||
uint32_t request_id ; // randomly generated request id.
|
||||
uint16_t depth ; // Used for limiting search depth.
|
||||
};
|
||||
|
@ -82,7 +84,9 @@ class RsTurtleStringSearchRequestItem: public RsTurtleSearchRequestItem
|
|||
RsTurtleStringSearchRequestItem() : RsTurtleSearchRequestItem(RS_TURTLE_SUBTYPE_STRING_SEARCH_REQUEST) {}
|
||||
|
||||
std::string match_string ; // string to match
|
||||
|
||||
|
||||
std::string GetKeywords() { return match_string; }
|
||||
|
||||
virtual RsTurtleSearchRequestItem *clone() const { return new RsTurtleStringSearchRequestItem(*this) ; }
|
||||
virtual void performLocalSearch(std::list<TurtleFileInfo>&) const ;
|
||||
|
||||
|
@ -99,6 +103,8 @@ class RsTurtleRegExpSearchRequestItem: public RsTurtleSearchRequestItem
|
|||
|
||||
RsRegularExpression::LinearizedExpression expr ; // Reg Exp in linearised mode
|
||||
|
||||
std::string GetKeywords() { return expr.GetStrings(); }
|
||||
|
||||
virtual RsTurtleSearchRequestItem *clone() const { return new RsTurtleRegExpSearchRequestItem(*this) ; }
|
||||
virtual void performLocalSearch(std::list<TurtleFileInfo>&) const ;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue