You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
271 lines
6.8 KiB
271 lines
6.8 KiB
Index: lib/as_netinfo.c |
|
--- lib/as_netinfo.c.orig 2006-02-25 23:46:44 +0100 |
|
+++ lib/as_netinfo.c 2006-10-23 20:47:30 +0200 |
|
@@ -134,6 +134,7 @@ |
|
ASPacket *packet) |
|
{ |
|
in_addr_t ip; |
|
+ as_uint16 sn_build; |
|
|
|
if ((ip = as_packet_get_ip (packet)) == 0) |
|
return FALSE; |
|
@@ -148,6 +149,15 @@ |
|
|
|
info->outside_ip = ip; |
|
|
|
+ /* further data in packet: */ |
|
+ as_packet_get_8 (packet); /* 0x00 */ |
|
+ as_packet_get_le16 (packet); /* NatPort (our port as seen by supernode?) */ |
|
+ as_packet_get_le16 (packet); /* ResultId (used for UDP searching?) */ |
|
+ sn_build = as_packet_get_le16 (packet); /* Supernode build number */ |
|
+ |
|
+ AS_HEAVY_DBG_2 ("Supernode %s has build number %u", |
|
+ net_ip_str (session->host), sn_build); |
|
+ |
|
return TRUE; |
|
} |
|
|
|
Index: lib/as_sha1.c |
|
--- lib/as_sha1.c.orig 2004-09-02 21:39:52 +0200 |
|
+++ lib/as_sha1.c 2006-10-23 20:47:30 +0200 |
|
@@ -34,19 +34,28 @@ |
|
|
|
/*****************************************************************************/ |
|
|
|
-#if 1 |
|
-#define GET_BE32(p,ind) \ |
|
- ((p)[ind] << 24 | (p)[(ind)+1] << 16 | (p)[(ind)+2] << 8 | (p)[(ind)+3]) |
|
+#ifndef WIN32 |
|
+ |
|
+/* sigh */ |
|
+#ifdef WORDS_BIGENDIAN |
|
+# if SIZEOF_LONG == 4 |
|
+# define SHA_BYTE_ORDER 4321 |
|
+# elif SIZEOF_LONG == 8 |
|
+# define SHA_BYTE_ORDER 87654321 |
|
+# endif |
|
#else |
|
-#define GET_BE32(p32,ind) \ |
|
- ntohl((p32)[(ind)/4]) |
|
+# if SIZEOF_LONG == 4 |
|
+# define SHA_BYTE_ORDER 1234 |
|
+# elif SIZEOF_LONG == 8 |
|
+# define SHA_BYTE_ORDER 12345678 |
|
+# endif |
|
#endif |
|
|
|
-#define COPY_BE32x16(W,wind,p,ind) \ |
|
- (W)[(wind)] = GET_BE32((p),(ind)); \ |
|
- (W)[(wind)+1] = GET_BE32((p),(ind)+4); \ |
|
- (W)[(wind)+2] = GET_BE32((p),(ind)+8); \ |
|
- (W)[(wind)+3] = GET_BE32((p),(ind)+12); |
|
+#else /* WIN32 */ |
|
+ |
|
+#define SHA_BYTE_ORDER 1234 |
|
+ |
|
+#endif /* !WIN32 */ |
|
|
|
/* SHA f()-functions */ |
|
|
|
@@ -108,10 +117,59 @@ |
|
|
|
dp = sha_info->data; |
|
|
|
- COPY_BE32x16(W, 0,dp,0); |
|
- COPY_BE32x16(W, 4,dp,16); |
|
- COPY_BE32x16(W, 8,dp,32); |
|
- COPY_BE32x16(W,12,dp,48); |
|
+/* |
|
+the following makes sure that at least one code block below is |
|
+traversed or an error is reported, without the necessity for nested |
|
+preprocessor if/else/endif blocks, which are a great pain in the |
|
+nether regions of the anatomy... |
|
+*/ |
|
+#undef SWAP_DONE |
|
+ |
|
+#if (SHA_BYTE_ORDER == 1234) |
|
+#define SWAP_DONE |
|
+ for (i = 0; i < 16; ++i) { |
|
+ T = *((unsigned long *) dp); |
|
+ dp += 4; |
|
+ W[i] = ((T << 24) & 0xff000000) | ((T << 8) & 0x00ff0000) | |
|
+ ((T >> 8) & 0x0000ff00) | ((T >> 24) & 0x000000ff); |
|
+ } |
|
+#endif /* SHA_BYTE_ORDER == 1234 */ |
|
+ |
|
+#if (SHA_BYTE_ORDER == 4321) |
|
+#define SWAP_DONE |
|
+ for (i = 0; i < 16; ++i) { |
|
+ T = *((unsigned long *) dp); |
|
+ dp += 4; |
|
+ W[i] = T32(T); |
|
+ } |
|
+#endif /* SHA_BYTE_ORDER == 4321 */ |
|
+ |
|
+#if (SHA_BYTE_ORDER == 12345678) |
|
+#define SWAP_DONE |
|
+ for (i = 0; i < 16; i += 2) { |
|
+ T = *((unsigned long *) dp); |
|
+ dp += 8; |
|
+ W[i] = ((T << 24) & 0xff000000) | ((T << 8) & 0x00ff0000) | |
|
+ ((T >> 8) & 0x0000ff00) | ((T >> 24) & 0x000000ff); |
|
+ T >>= 32; |
|
+ W[i+1] = ((T << 24) & 0xff000000) | ((T << 8) & 0x00ff0000) | |
|
+ ((T >> 8) & 0x0000ff00) | ((T >> 24) & 0x000000ff); |
|
+ } |
|
+#endif /* SHA_BYTE_ORDER == 12345678 */ |
|
+ |
|
+#if (SHA_BYTE_ORDER == 87654321) |
|
+#define SWAP_DONE |
|
+ for (i = 0; i < 16; i += 2) { |
|
+ T = *((unsigned long *) dp); |
|
+ dp += 8; |
|
+ W[i] = T32(T >> 32); |
|
+ W[i+1] = T32(T); |
|
+ } |
|
+#endif /* SHA_BYTE_ORDER == 87654321 */ |
|
+ |
|
+#ifndef SWAP_DONE |
|
+#error Unknown byte order -- you need to add code here |
|
+#endif /* SWAP_DONE */ |
|
|
|
for (i = 16; i < 80; ++i) { |
|
W[i] = W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16]; |
|
Index: lib/as_share.c |
|
--- lib/as_share.c.orig 2005-01-09 00:07:56 +0100 |
|
+++ lib/as_share.c 2006-10-23 20:47:30 +0200 |
|
@@ -260,6 +260,13 @@ |
|
} |
|
} |
|
|
|
+ if (as_packet_size (tokens) > 400) |
|
+ { |
|
+ AS_WARN_1 ("Share token size exceeds 400 bytes (%d). " |
|
+ "Supernodes will ignore this share!", |
|
+ as_packet_size (tokens)); |
|
+ } |
|
+ |
|
as_packet_put_le16 (p, (as_uint16) tokens->used); |
|
as_packet_append (p, tokens); |
|
as_packet_free (tokens); |
|
@@ -278,6 +285,13 @@ |
|
/* Add random position block. See as_meta.c. */ |
|
add_meta_tags2 (p, share); |
|
|
|
+ if (as_packet_size (p) > 1024) |
|
+ { |
|
+ AS_WARN_1 ("Share packet size exceeds 1024 bytes (%d). " |
|
+ "Supernodes will ignore this share!", |
|
+ as_packet_size (tokens)); |
|
+ } |
|
+ |
|
return p; |
|
} |
|
|
|
Index: lib/as_share_man.c |
|
--- lib/as_share_man.c.orig 2006-02-19 16:34:25 +0100 |
|
+++ lib/as_share_man.c 2006-10-23 20:47:30 +0200 |
|
@@ -157,6 +157,13 @@ |
|
|
|
static as_bool conglobulator_assimilate (Conglobulator *glob, ASPacket *p) |
|
{ |
|
+ if (as_packet_size (p) > 700) |
|
+ { |
|
+ AS_WARN_1 ("Share packet is larger than 700 bytes (%d). " |
|
+ "Supernodes will this and subsequent packets in compressed envelope!", |
|
+ as_packet_size (p)); |
|
+ } |
|
+ |
|
if (!glob->data) |
|
glob->data = p; |
|
else |
|
Index: lib/as_upload.c |
|
--- lib/as_upload.c.orig 2006-02-20 00:07:22 +0100 |
|
+++ lib/as_upload.c 2006-10-23 20:47:30 +0200 |
|
@@ -356,7 +356,7 @@ |
|
net_ip_str (up->host)); |
|
|
|
up->start = 0; |
|
- up->stop = up->share->size; |
|
+ up->stop = 0; |
|
} |
|
|
|
/* Get hash from request header. */ |
|
@@ -411,6 +411,10 @@ |
|
return FALSE; |
|
} |
|
|
|
+ /* send entire file if no range was specified */ |
|
+ if (up->stop == 0) |
|
+ up->stop = up->share->size; |
|
+ |
|
/* sanity check requested range */ |
|
if (up->stop <= up->start || |
|
up->start >= up->share->size || up->stop > up->share->size) |
|
Index: lib/as_upload_man.c |
|
--- lib/as_upload_man.c.orig 2005-11-26 02:04:10 +0100 |
|
+++ lib/as_upload_man.c 2006-10-23 20:47:30 +0200 |
|
@@ -16,7 +16,7 @@ |
|
|
|
/*****************************************************************************/ |
|
|
|
-struct queue |
|
+struct xqueue |
|
{ |
|
in_addr_t host; |
|
time_t time; |
|
@@ -376,14 +376,14 @@ |
|
* specified to ignore beyond, so that we can avoid timing out entries |
|
* if later entries haven't pinged us yet. |
|
*/ |
|
-static void tidy_queue (ASUpMan *man, struct queue *last) |
|
+static void tidy_queue (ASUpMan *man, struct xqueue *last) |
|
{ |
|
List *l, *next; |
|
time_t t = time (NULL); |
|
|
|
for (l = man->queue; l; l = next) |
|
{ |
|
- struct queue *q = l->data; |
|
+ struct xqueue *q = l->data; |
|
|
|
next = l->next; /* to avoid referencing freed data |
|
* should we choose to remove this |
|
@@ -407,7 +407,7 @@ |
|
{ |
|
ASUpload *up; |
|
List *l; |
|
- struct queue *q = NULL; |
|
+ struct xqueue *q = NULL; |
|
int i; |
|
|
|
#ifdef VERIFY_ACTIVE_COUNT |
|
@@ -467,7 +467,7 @@ |
|
if (!l) |
|
{ |
|
/* not queued; insert at end */ |
|
- q = malloc (sizeof(struct queue)); |
|
+ q = malloc (sizeof(struct xqueue)); |
|
|
|
if (!q) |
|
return -1; |
|
Index: lib/as_util.c |
|
--- lib/as_util.c.orig 2005-09-15 23:26:40 +0200 |
|
+++ lib/as_util.c 2006-10-23 20:47:30 +0200 |
|
@@ -40,9 +40,15 @@ |
|
/* Insert link after prev. Returns prev. */ |
|
List *list_insert_link (List *prev, List *link) |
|
{ |
|
- if (!prev || !link) |
|
+ if (!link) |
|
return prev; |
|
|
|
+ link->prev = NULL; |
|
+ link->next = NULL; |
|
+ |
|
+ if (!prev) |
|
+ return link; |
|
+ |
|
link->prev = prev; |
|
link->next = prev->next; |
|
prev->next = link;
|
|
|