mirror of
https://github.com/transmission/transmission
synced 2025-03-03 18:25:35 +00:00
Include dht-0.19.
This fixes a bug with parsing of announce messages, noticed by cjdelisle.
This commit is contained in:
parent
0cff181c09
commit
09c67f749a
2 changed files with 10 additions and 7 deletions
5
third-party/dht/CHANGES
vendored
5
third-party/dht/CHANGES
vendored
|
@ -1,3 +1,8 @@
|
||||||
|
30 April 2011: dht-0.19
|
||||||
|
|
||||||
|
* Fix incorrect parsing of announces. Thanks to cjdelisle.
|
||||||
|
* Relax rate limiting slightly.
|
||||||
|
|
||||||
20 January 2011: dht-0.18
|
20 January 2011: dht-0.18
|
||||||
|
|
||||||
* Fix a bug that could cause parse_message to enter an infinite loop
|
* Fix a bug that could cause parse_message to enter an infinite loop
|
||||||
|
|
12
third-party/dht/dht.c
vendored
12
third-party/dht/dht.c
vendored
|
@ -310,7 +310,7 @@ static struct timeval now;
|
||||||
static time_t mybucket_grow_time, mybucket6_grow_time;
|
static time_t mybucket_grow_time, mybucket6_grow_time;
|
||||||
static time_t expire_stuff_time;
|
static time_t expire_stuff_time;
|
||||||
|
|
||||||
#define MAX_TOKEN_BUCKET_TOKENS 40
|
#define MAX_TOKEN_BUCKET_TOKENS 400
|
||||||
static time_t token_bucket_time;
|
static time_t token_bucket_time;
|
||||||
static int token_bucket_tokens;
|
static int token_bucket_tokens;
|
||||||
|
|
||||||
|
@ -1221,23 +1221,21 @@ find_storage(const unsigned char *id)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
storage_store(const unsigned char *id, const struct sockaddr *sa)
|
storage_store(const unsigned char *id,
|
||||||
|
const struct sockaddr *sa, unsigned short port)
|
||||||
{
|
{
|
||||||
int i, len;
|
int i, len;
|
||||||
struct storage *st;
|
struct storage *st;
|
||||||
unsigned char *ip;
|
unsigned char *ip;
|
||||||
unsigned short port;
|
|
||||||
|
|
||||||
if(sa->sa_family == AF_INET) {
|
if(sa->sa_family == AF_INET) {
|
||||||
struct sockaddr_in *sin = (struct sockaddr_in*)sa;
|
struct sockaddr_in *sin = (struct sockaddr_in*)sa;
|
||||||
ip = (unsigned char*)&sin->sin_addr;
|
ip = (unsigned char*)&sin->sin_addr;
|
||||||
len = 4;
|
len = 4;
|
||||||
port = ntohs(sin->sin_port);
|
|
||||||
} else if(sa->sa_family == AF_INET6) {
|
} else if(sa->sa_family == AF_INET6) {
|
||||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)sa;
|
struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)sa;
|
||||||
ip = (unsigned char*)&sin6->sin6_addr;
|
ip = (unsigned char*)&sin6->sin6_addr;
|
||||||
len = 16;
|
len = 16;
|
||||||
port = ntohs(sin6->sin6_port);
|
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1714,7 +1712,7 @@ token_bucket(void)
|
||||||
{
|
{
|
||||||
if(token_bucket_tokens == 0) {
|
if(token_bucket_tokens == 0) {
|
||||||
token_bucket_tokens = MIN(MAX_TOKEN_BUCKET_TOKENS,
|
token_bucket_tokens = MIN(MAX_TOKEN_BUCKET_TOKENS,
|
||||||
4 * (now.tv_sec - token_bucket_time));
|
100 * (now.tv_sec - token_bucket_time));
|
||||||
token_bucket_time = now.tv_sec;
|
token_bucket_time = now.tv_sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2089,7 +2087,7 @@ dht_periodic(const void *buf, size_t buflen,
|
||||||
203, "Announce_peer with forbidden port number");
|
203, "Announce_peer with forbidden port number");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
storage_store(info_hash, from);
|
storage_store(info_hash, from, port);
|
||||||
/* Note that if storage_store failed, we lie to the requestor.
|
/* Note that if storage_store failed, we lie to the requestor.
|
||||||
This is to prevent them from backtracking, and hence
|
This is to prevent them from backtracking, and hence
|
||||||
polluting the DHT. */
|
polluting the DHT. */
|
||||||
|
|
Loading…
Reference in a new issue