Commit c40b32e4 authored by Patrick Schmalstig's avatar Patrick Schmalstig
Browse files

Implemented MANTIS-6254 (Performance: Split rate limiter by IP)

parent 6e06149a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ test_a
/themes/*/templates_cached/*/*.tcp
/themes/*/templates_cached/*/*.gz
/themes/*/templates_cached/*/*.br
/data_custom/rate_limiter.php
/data_custom/rate_limiting/*.json
/data_custom/*log.php
/exports/*/*.tar
/exports/*/*.gz
+0 −1
Original line number Diff line number Diff line
@@ -147,7 +147,6 @@ class basic_code_formatting_test_set extends cms_test_case
                continue;
            }
            $exceptions = array_merge(list_untouchable_third_party_files(), [
                'data_custom/rate_limiter.php',
                'text/unbannable_ips.txt',
                'themes/default/templates/BREADCRUMB_SEPARATOR.tpl',
            ]);
+0 −1
Original line number Diff line number Diff line
@@ -74,7 +74,6 @@ class path_references_test_set extends cms_test_case
                // Files that do not exist by default in a Composr install
                'data_custom/execute_temp.php',
                'data_custom/latest_activity.txt',
                'data_custom/rate_limiter.php',
                'sources_custom/critical_errors.php',
                'Could not find data_custom/upgrader.cms.tmp',
                'lang_custom/langs.ini',
+2 −3
Original line number Diff line number Diff line
@@ -27,8 +27,7 @@ class rate_limiting_test_set extends cms_test_case
        file_put_contents($config_file_path, $config_file . "\n\n\$SITE_INFO['rate_limiting'] = '1';\n\$SITE_INFO['rate_limit_time_window'] = '60';\n\$SITE_INFO['rate_limit_hits_per_window'] = '3';");
        fix_permissions($config_file_path);

        $rate_limiter_path = get_custom_file_base() . '/data_custom/rate_limiter.php';
        file_put_contents($rate_limiter_path, '');
        $rate_limiter_path = get_custom_file_base() . '/data_custom/rate_limiting/' . str_replace(['.', ':'], ['_', '-'], get_ip_address()) . '.json';

        $url = build_url(['page' => ''], '');
        for ($i = 0; $i < 4; $i++) {
@@ -53,6 +52,6 @@ class rate_limiting_test_set extends cms_test_case
        }

        file_put_contents($config_file_path, $config_file);
        unlink($rate_limiter_path);
        //unlink($rate_limiter_path);
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -236,7 +236,7 @@ function do_access(string $given_password)
        'failover_message_place_after' => '<em>Failover:</em> failover_message will be placed after this HTML marker.',
        'failover_message_place_before' => '<em>Failover:</em> failover_message will be placed before this HTML marker. May be specified in addition to failover_message_place_after, so that two messages show.',

        'rate_limiting' => '<em>Rate limiting:</em> Whether to enable rate limiting for IPs (recommended if you get heavy bot activity). The data_custom/rate_limiter.php file must exist and be writeable (on a suExec-style server the file will auto-create, otherwise just make it as an empty file). IP addresses passed to PHP must be accurate (some front-end proxying systems break this).',
        'rate_limiting' => '<em>Rate limiting:</em> Whether to enable rate limiting for IPs (recommended if you get heavy bot activity). The data_custom/rate_limiting directory must exist and be writeable. IP addresses passed to PHP must be accurate (some front-end proxying systems break this).',
        'rate_limit_time_window' => '<em>Rate limiting:</em> The number of seconds hits are counted across. Defaults to <kbd>10</kbd>.',
        'rate_limit_hits_per_window' => '<em>Rate limiting:</em> The number of hits per IP going back as far as the time window. Note that this is any URL hitting the software as a whole, not just pages (i.e. AJAX and banner frames would both count). Defaults to <kbd>5</kbd>.',

Loading