diff options
author | irungentoo <irungentoo@gmail.com> | 2013-11-27 14:18:39 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-11-27 14:18:39 -0500 |
commit | 74b13a9fcfdce5d9513b3d58a9f647a68981b3ed (patch) | |
tree | 562630675850be2a3a1030ba482d3a27482883e3 /toxcore/Messenger.c | |
parent | 3fe7e087913d07c5805a9e27c267476527de0e84 (diff) |
Friend requests from friends are now discarded.
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r-- | toxcore/Messenger.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 1a7fc230..5e9758dd 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -1454,6 +1454,17 @@ int m_msi_packet(Messenger *m, int friendnumber, uint8_t *data, uint16_t length) | |||
1454 | return write_cryptpacket_id(m, friendnumber, PACKET_ID_MSI, data, length); | 1454 | return write_cryptpacket_id(m, friendnumber, PACKET_ID_MSI, data, length); |
1455 | } | 1455 | } |
1456 | 1456 | ||
1457 | /* Function to filter out some friend requests*/ | ||
1458 | static int friend_already_added(uint8_t * client_id, void * data) | ||
1459 | { | ||
1460 | Messenger *m = data; | ||
1461 | |||
1462 | if (getfriend_id(m, client_id) == -1) | ||
1463 | return 0; | ||
1464 | |||
1465 | return -1; | ||
1466 | } | ||
1467 | |||
1457 | /* Send a LAN discovery packet every LAN_DISCOVERY_INTERVAL seconds. */ | 1468 | /* Send a LAN discovery packet every LAN_DISCOVERY_INTERVAL seconds. */ |
1458 | static void LANdiscovery(Messenger *m) | 1469 | static void LANdiscovery(Messenger *m) |
1459 | { | 1470 | { |
@@ -1503,6 +1514,8 @@ Messenger *new_messenger(uint8_t ipv6enabled) | |||
1503 | friendreq_init(&(m->fr), m->net_crypto); | 1514 | friendreq_init(&(m->fr), m->net_crypto); |
1504 | LANdiscovery_init(m->dht); | 1515 | LANdiscovery_init(m->dht); |
1505 | set_nospam(&(m->fr), random_int()); | 1516 | set_nospam(&(m->fr), random_int()); |
1517 | set_filter_function(&(m->fr), &friend_already_added, m); | ||
1518 | |||
1506 | networking_registerhandler(m->net, NET_PACKET_GROUP_CHATS, &handle_group, m); | 1519 | networking_registerhandler(m->net, NET_PACKET_GROUP_CHATS, &handle_group, m); |
1507 | 1520 | ||
1508 | return m; | 1521 | return m; |