mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-08 22:08:00 +00:00
ignore far-future message in getposts
This commit is contained in:
parent
a7e9b67e37
commit
4d43c08a5b
@ -123,7 +123,7 @@ void dht_get_observer::reply(msg const& m)
|
||||
}
|
||||
|
||||
int64 p_time = p->dict_find_int_value("time");
|
||||
if(!p_time || p_time > GetAdjustedTime() + 2*60*60 ) {
|
||||
if(!p_time || p_time > GetAdjustedTime() + MAX_TIME_IN_FUTURE ) {
|
||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||
TORRENT_LOG(traversal) << "dht_get_observer::reply invalid time";
|
||||
#endif
|
||||
|
@ -1430,7 +1430,7 @@ void node_impl::incoming_request(msg const& m, entry& e)
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg_keys[mk_time]->int_value() > GetAdjustedTime() + 2*60*60) {
|
||||
if (msg_keys[mk_time]->int_value() > GetAdjustedTime() + MAX_TIME_IN_FUTURE) {
|
||||
incoming_error(e, "time > GetAdjustedTime");
|
||||
return;
|
||||
}
|
||||
|
@ -1926,6 +1926,10 @@ Value getposts(const Array& params, bool fHelp)
|
||||
if (lazy_bdecode(piece.data(), piece.data()+piece.size(), v, ec, &pos) == 0) {
|
||||
lazy_entry const* post = v.dict_find_dict("userpost");
|
||||
int64 time = post->dict_find_int_value("time",-1);
|
||||
|
||||
if(time == -1 || time > GetAdjustedTime() + MAX_TIME_IN_FUTURE ) {
|
||||
printf("getposts: ignoring far-future message by '%s'\n", strUsername.c_str());
|
||||
}
|
||||
|
||||
entry vEntry;
|
||||
vEntry = v;
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#define BLOCK_AGE_TO_EXPIRE_DHT_ENTRY (2016) // about 2 weeks
|
||||
#define BLOCK_AGE_TO_EXPIRE_DHT_POSTS (4320*2) // about 2 months
|
||||
#define MAX_TIME_IN_FUTURE (2*60*60) // same constant as in Bitcoin's main.cpp:CheckBlock()
|
||||
|
||||
namespace libtorrent {
|
||||
class entry;
|
||||
|
Loading…
Reference in New Issue
Block a user