diff --git a/libtorrent/src/kademlia/dht_get.cpp b/libtorrent/src/kademlia/dht_get.cpp index 26f4bc09..6e6fbf6d 100644 --- a/libtorrent/src/kademlia/dht_get.cpp +++ b/libtorrent/src/kademlia/dht_get.cpp @@ -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 diff --git a/libtorrent/src/kademlia/node.cpp b/libtorrent/src/kademlia/node.cpp index f5736335..10ebd390 100644 --- a/libtorrent/src/kademlia/node.cpp +++ b/libtorrent/src/kademlia/node.cpp @@ -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; } diff --git a/src/twister.cpp b/src/twister.cpp index d59556d7..bb9ab3fd 100644 --- a/src/twister.cpp +++ b/src/twister.cpp @@ -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; diff --git a/src/twister.h b/src/twister.h index 74456961..eafd2bf7 100644 --- a/src/twister.h +++ b/src/twister.h @@ -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;