diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/LAN_discovery.h | 2 | ||||
-rw-r--r-- | toxcore/group_chats.c | 29 | ||||
-rw-r--r-- | toxcore/group_chats.h | 3 |
3 files changed, 31 insertions, 3 deletions
diff --git a/toxcore/LAN_discovery.h b/toxcore/LAN_discovery.h index 58bd2bee..fcb094e4 100644 --- a/toxcore/LAN_discovery.h +++ b/toxcore/LAN_discovery.h | |||
@@ -36,7 +36,7 @@ | |||
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | /* Interval in seconds between LAN discovery packet sending. */ | 38 | /* Interval in seconds between LAN discovery packet sending. */ |
39 | #define LAN_DISCOVERY_INTERVAL 60 | 39 | #define LAN_DISCOVERY_INTERVAL 10 |
40 | 40 | ||
41 | /* Send a LAN discovery pcaket to the broadcast address with port port. */ | 41 | /* Send a LAN discovery pcaket to the broadcast address with port port. */ |
42 | int send_LANdiscovery(uint16_t port, DHT *dht); | 42 | int send_LANdiscovery(uint16_t port, DHT *dht); |
diff --git a/toxcore/group_chats.c b/toxcore/group_chats.c index 6dff52ef..17914038 100644 --- a/toxcore/group_chats.c +++ b/toxcore/group_chats.c | |||
@@ -251,6 +251,22 @@ static int addpeer(Group_Chat *chat, uint8_t *client_id) | |||
251 | } | 251 | } |
252 | 252 | ||
253 | /* | 253 | /* |
254 | * Set a peer from the group chat to deleted. | ||
255 | * | ||
256 | * return 0 if success | ||
257 | * return -1 if error. | ||
258 | */ | ||
259 | static int del_peer_set(Group_Chat *chat, int peernum) | ||
260 | { | ||
261 | if ((uint32_t)peernum >= chat->numpeers) | ||
262 | return -1; | ||
263 | |||
264 | chat->group[peernum].deleted = 1; | ||
265 | chat->group[peernum].deleted_time = unix_time(); | ||
266 | return 0; | ||
267 | } | ||
268 | |||
269 | /* | ||
254 | * Delete a peer from the group chat. | 270 | * Delete a peer from the group chat. |
255 | * | 271 | * |
256 | * return 0 if success | 272 | * return 0 if success |
@@ -488,6 +504,9 @@ static int handle_data(Group_Chat *chat, uint8_t *data, uint32_t len) | |||
488 | if (peernum == -1) | 504 | if (peernum == -1) |
489 | return 1; | 505 | return 1; |
490 | 506 | ||
507 | if (chat->group[peernum].deleted) | ||
508 | return 1; | ||
509 | |||
491 | /* Spam prevention (1 message per peer per second limit.) | 510 | /* Spam prevention (1 message per peer per second limit.) |
492 | 511 | ||
493 | if (chat->group[peernum].last_recv == temp_time) | 512 | if (chat->group[peernum].last_recv == temp_time) |
@@ -531,7 +550,7 @@ static int handle_data(Group_Chat *chat, uint8_t *data, uint32_t len) | |||
531 | if (contents_len != 0) | 550 | if (contents_len != 0) |
532 | return 1; | 551 | return 1; |
533 | 552 | ||
534 | delpeer(chat, peernum); | 553 | del_peer_set(chat, peernum); |
535 | break; | 554 | break; |
536 | 555 | ||
537 | case GROUP_CHAT_PEER_NICK: | 556 | case GROUP_CHAT_PEER_NICK: |
@@ -758,6 +777,7 @@ static void ping_group(Group_Chat *chat) | |||
758 | } | 777 | } |
759 | } | 778 | } |
760 | 779 | ||
780 | #define DEL_PEER_DELAY 3 | ||
761 | static void del_dead_peers(Group_Chat *chat) | 781 | static void del_dead_peers(Group_Chat *chat) |
762 | { | 782 | { |
763 | uint32_t i; | 783 | uint32_t i; |
@@ -766,6 +786,11 @@ static void del_dead_peers(Group_Chat *chat) | |||
766 | if (is_timeout(chat->group[i].last_recv_msgping, GROUP_PING_INTERVAL * 4)) { | 786 | if (is_timeout(chat->group[i].last_recv_msgping, GROUP_PING_INTERVAL * 4)) { |
767 | delpeer(chat, i); | 787 | delpeer(chat, i); |
768 | } | 788 | } |
789 | |||
790 | if (chat->group[i].deleted) { | ||
791 | if (is_timeout(chat->group[i].deleted_time, DEL_PEER_DELAY)) | ||
792 | delpeer(chat, i); | ||
793 | } | ||
769 | } | 794 | } |
770 | } | 795 | } |
771 | 796 | ||
@@ -773,7 +798,7 @@ static void del_dead_peers(Group_Chat *chat) | |||
773 | static void send_names_new_peer(Group_Chat *chat) | 798 | static void send_names_new_peer(Group_Chat *chat) |
774 | { | 799 | { |
775 | group_send_nick(chat, chat->nick, chat->nick_len); | 800 | group_send_nick(chat, chat->nick, chat->nick_len); |
776 | chat->last_sent_nick = (unix_time() - NICK_SEND_INTERVAL) + 10; | 801 | chat->last_sent_nick = (unix_time() - NICK_SEND_INTERVAL) + 15; |
777 | } | 802 | } |
778 | static void send_names(Group_Chat *chat) | 803 | static void send_names(Group_Chat *chat) |
779 | { | 804 | { |
diff --git a/toxcore/group_chats.h b/toxcore/group_chats.h index 8d5f5e50..e31aa229 100644 --- a/toxcore/group_chats.h +++ b/toxcore/group_chats.h | |||
@@ -41,6 +41,9 @@ typedef struct { | |||
41 | 41 | ||
42 | uint8_t nick[MAX_NICK_BYTES]; | 42 | uint8_t nick[MAX_NICK_BYTES]; |
43 | uint16_t nick_len; | 43 | uint16_t nick_len; |
44 | |||
45 | uint8_t deleted; | ||
46 | uint64_t deleted_time; | ||
44 | } Group_Peer; | 47 | } Group_Peer; |
45 | 48 | ||
46 | typedef struct { | 49 | typedef struct { |