Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ns_turn_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#ifndef __IOADEFS__
#define __IOADEFS__

#define TURN_SERVER_VERSION "wireapp/4.6.2h"
#define TURN_SERVER_VERSION "wireapp/4.6.2j"
#define TURN_SERVER_VERSION_NAME "Gorst"
#ifndef TURN_SERVER_BUILD_INFO
#define TURN_SERVER_BUILD_INFO ""
Expand Down
8 changes: 8 additions & 0 deletions src/server/ns_turn_ratelimit.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
TURN_MUTEX_UNLOCK(&rate_limit_main_mutex);
}

int ratelimit_is_address_limited(ioa_addr *address, int max_requests, int window_seconds) {

Check warning on line 66 in src/server/ns_turn_ratelimit.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this parameter a pointer-to-const. The current type of "address" is "ioa_addr *".

See more on https://sonarcloud.io/project/issues?id=wireapp_coturn&issues=AZzcL1n7HSwZ4ERQOWxL&open=AZzcL1n7HSwZ4ERQOWxL&pullRequest=29
/* Housekeeping, prune the map when ADDR_MAP_SIZE is hit and delete expired items */
turn_time_t current_time = turn_time();

Expand All @@ -86,7 +86,12 @@
*address_new = *address;
addr_set_port(address_new, 0);

/* Set global lock for `ur_addr_map_get` */
TURN_MUTEX_LOCK(&rate_limit_main_mutex);
if (ur_addr_map_get(rate_limit_map, address_new, &ratelimit_ptr)) {
/* Unlock global lock from `ur_addr_map_get` */
TURN_MUTEX_UNLOCK(&rate_limit_main_mutex);

free(address_new);
ratelimit_entry *rateLimitEntry = (ratelimit_entry *)(void *)(ur_map_value_type)ratelimit_ptr;
TURN_MUTEX_LOCK(&(rateLimitEntry->mutex));
Expand All @@ -105,6 +110,9 @@
TURN_MUTEX_UNLOCK(&(rateLimitEntry->mutex));
return 0;
} else {
/* Unlock global lock from `ur_addr_map_get` */
TURN_MUTEX_UNLOCK(&rate_limit_main_mutex);

/* Request is outside of defined window and count, request is ratelimited */
if (rateLimitEntry->request_count < UINT32_MAX)
rateLimitEntry->request_count++;
Expand Down