From 3158ce40cd18a9d046deb7cefdeb45eba783d788 Mon Sep 17 00:00:00 2001 From: towards-a-new-leftypol Date: Thu, 14 Mar 2024 17:10:38 -0400 Subject: [PATCH 1/2] Rate limit opening posts for specific ip (basically copy flood-time-any filter and add ip condition) --- inc/instance-config.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/inc/instance-config.php b/inc/instance-config.php index 430fcd48..9f731e6f 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -569,5 +569,25 @@ $config['filters'][] = array( 'message' => 'Url shorteners are not allowed' ); +// Rate limit posting new threads over Tor +$config['filters'][] = array( + 'condition' => array( + /* + * Confusingly `isreply` is defined as: + * $flood_post['isreply'] == $post['op'] + * + * We only want to look at OP posts in the flood table. + */ + 'flood-match' => array('isreply'), + 'OP' => true, + 'flood-time-any' => 60 * 10 // 10 minutes + ), + 'noip' => true, + 'ip' => '127.0.0.1', + 'find_time' => 60 * 60 * 1, + 'action' => 'reject', + 'message' => 'New threads are being created too quickly. Wait [at most] 10 minutes' +); + $config['global_message'] = 'Matrix   IRC Chat   Mumble   Telegram   Discord'; $config['debug'] = false; From 10015def126f598c33c410537af7a78e6d275570 Mon Sep 17 00:00:00 2001 From: towards-a-new-leftypol Date: Thu, 14 Mar 2024 17:30:39 -0400 Subject: [PATCH 2/2] Add ip member variable to filter class --- inc/filters.php | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/filters.php b/inc/filters.php index cbd3e09f..36193e16 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -18,6 +18,7 @@ class Filter { private bool $add_note; private bool $noip; private $find_time; + private string $ip; public function __construct(array $arr) { foreach ($arr as $key => $value) {