@@ -370,6 +370,7 @@ void webserver::unregister_resource(const string& resource) {
370
370
}
371
371
372
372
void webserver::ban_ip (const string& ip) {
373
+ std::unique_lock bans_and_allowances_lock (bans_and_allowances_mutex);
373
374
ip_representation t_ip (ip);
374
375
set<ip_representation>::iterator it = bans.find (t_ip);
375
376
if (it != bans.end () && (t_ip.weight () < (*it).weight ())) {
@@ -381,6 +382,7 @@ void webserver::ban_ip(const string& ip) {
381
382
}
382
383
383
384
void webserver::allow_ip (const string& ip) {
385
+ std::unique_lock bans_and_allowances_lock (bans_and_allowances_mutex);
384
386
ip_representation t_ip (ip);
385
387
set<ip_representation>::iterator it = allowances.find (t_ip);
386
388
if (it != allowances.end () && (t_ip.weight () < (*it).weight ())) {
@@ -392,10 +394,12 @@ void webserver::allow_ip(const string& ip) {
392
394
}
393
395
394
396
void webserver::unban_ip (const string& ip) {
397
+ std::unique_lock bans_and_allowances_lock (bans_and_allowances_mutex);
395
398
bans.erase (ip_representation (ip));
396
399
}
397
400
398
401
void webserver::disallow_ip (const string& ip) {
402
+ std::unique_lock bans_and_allowances_lock (bans_and_allowances_mutex);
399
403
allowances.erase (ip_representation (ip));
400
404
}
401
405
@@ -405,6 +409,7 @@ MHD_Result policy_callback(void *cls, const struct sockaddr* addr, socklen_t add
405
409
406
410
if (!(static_cast <webserver*>(cls))->ban_system_enabled ) return MHD_YES;
407
411
412
+ std::shared_lock bans_and_allowances_lock ((static_cast <webserver*>(cls))->bans_and_allowances_mutex );
408
413
if ((((static_cast <webserver*>(cls))->default_policy == http_utils::ACCEPT) &&
409
414
((static_cast <webserver*>(cls))->bans .count (ip_representation (addr))) &&
410
415
(!(static_cast <webserver*>(cls))->allowances .count (ip_representation (addr)))) ||
0 commit comments