mirror of
https://github.com/aria2/aria2.git
synced 2024-12-11 15:55:37 +00:00
2009-09-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Limit the size of values list when sending get_peers reply. * src/DHTGetPeersReplyMessage.cc
This commit is contained in:
parent
1cd092f6a1
commit
2e8b0d785e
@ -1,3 +1,8 @@
|
||||
2009-09-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Limit the size of values list when sending get_peers reply.
|
||||
* src/DHTGetPeersReplyMessage.cc
|
||||
|
||||
2009-09-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Updated banner
|
||||
|
@ -92,9 +92,21 @@ BDE DHTGetPeersReplyMessage::getResponse()
|
||||
}
|
||||
rDict[NODES] = BDE(buffer, offset);
|
||||
} else {
|
||||
// Limit the size of values list. The maxmum payload size of UDP
|
||||
// packet is limited to 65507bytes. aria2 uses 20bytes token and
|
||||
// 2byte transaction ID. The size of get_peers reply message
|
||||
// without values list is 87bytes:
|
||||
//
|
||||
// d1:rd2:id20:aaaaaaaaaaaaaaaaaaaa5:token20:aaaaaaaaaaaaaaaaaaaa
|
||||
// 6:valueslee1:t2:bb1:y1:re
|
||||
//
|
||||
// With this configuration, We can send (65507-87)/8 = 8177
|
||||
// values. Since the size of token and transaction ID may vary in
|
||||
// implementations, we use 8100.
|
||||
static const size_t MAX_VALUES_SIZE = 8100;
|
||||
BDE valuesList = BDE::list();
|
||||
for(std::deque<SharedHandle<Peer> >::const_iterator i = _values.begin();
|
||||
i != _values.end(); ++i) {
|
||||
i != _values.end() && valuesList.size() < MAX_VALUES_SIZE; ++i) {
|
||||
const SharedHandle<Peer>& peer = *i;
|
||||
unsigned char buffer[6];
|
||||
if(PeerMessageUtil::createcompact(buffer, peer->ipaddr, peer->port)) {
|
||||
|
Loading…
Reference in New Issue
Block a user