max number of shared relays

This commit is contained in:
notsecure 2014-05-19 19:03:52 -04:00
parent 987a8d9850
commit 1b0a810a65
2 changed files with 9 additions and 5 deletions

View File

@ -716,11 +716,11 @@ static int send_ping(Messenger *m, int32_t friendnumber)
static int send_relays(Messenger *m, int32_t friendnumber) static int send_relays(Messenger *m, int32_t friendnumber)
{ {
Node_format nodes[MAX_TCP_CONNECTIONS]; Node_format nodes[MAX_SHARED_RELAYS];
uint8_t data[1024]; uint8_t data[1024];
int n, length; int n, length;
n = copy_connected_tcp_relays(m->net_crypto, nodes, MAX_TCP_CONNECTIONS); n = copy_connected_tcp_relays(m->net_crypto, nodes, MAX_SHARED_RELAYS);
length = pack_nodes(data, sizeof(data), nodes, n); length = pack_nodes(data, sizeof(data), nodes, n);
int ret = write_cryptpacket_id(m, friendnumber, PACKET_ID_SHARE_RELAYS, data, length); int ret = write_cryptpacket_id(m, friendnumber, PACKET_ID_SHARE_RELAYS, data, length);
@ -2180,14 +2180,15 @@ static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len)
} }
case PACKET_ID_SHARE_RELAYS: { case PACKET_ID_SHARE_RELAYS: {
Node_format nodes[MAX_TCP_CONNECTIONS]; Node_format nodes[MAX_SHARED_RELAYS];
int n; int n;
if ((n = unpack_nodes(nodes, MAX_TCP_CONNECTIONS, NULL, data, data_length, 1) == -1)) if ((n = unpack_nodes(nodes, MAX_SHARED_RELAYS, NULL, data, data_length, 1) == -1))
break; break;
int i; int i;
for(i = 0; i < n; i++) {
for (i = 0; i < n; i++) {
add_tcp_relay(m->net_crypto, nodes[i].ip_port, nodes[i].client_id); add_tcp_relay(m->net_crypto, nodes[i].ip_port, nodes[i].client_id);
} }
} }

View File

@ -60,6 +60,9 @@
/* Max number of groups we can invite someone at the same time to. */ /* Max number of groups we can invite someone at the same time to. */
#define MAX_INVITED_GROUPS 64 #define MAX_INVITED_GROUPS 64
/* Max number of tcp relays sent to friends */
#define MAX_SHARED_RELAYS 16
/* Status definitions. */ /* Status definitions. */
enum { enum {
NOFRIEND, NOFRIEND,