Skip to content

Commit

Permalink
Add option to disable rcguard for a list of IPs.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsoares committed Mar 5, 2018
1 parent ba50e1e commit 8034f90
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions config.inc.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ $rcmail_config['recaptcha_log_unknown'] = 'Error: Unknown log type.';
// Block IPv6 clients based on prefix length
// Use an integer between 16 and 128, 0 to disable
$rcmail_config['rcguard_ipv6_prefix'] = 0;

// Do not show recaptcha for this IPs
$rcmail_config['rcguard_ignore_ips'] = array();
13 changes: 9 additions & 4 deletions rcguard.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ class rcguard extends rcube_plugin
public function init()
{
$this->load_config();
$this->add_hook('template_object_loginform', array($this, 'loginform'));
$this->add_hook('authenticate', array($this, 'authenticate'));
$this->add_hook('login_after', array($this, 'login_after'));
$this->add_hook('login_failed', array($this, 'login_failed'));
$ignore_ips = rcmail::get_instance()->config->get('rcguard_ignore_ips', array());
$client_ip = $this->get_client_ip();

if (!in_array($client_ip, $ignore_ips)) {
$this->add_hook('template_object_loginform', array($this, 'loginform'));
$this->add_hook('authenticate', array($this, 'authenticate'));
$this->add_hook('login_after', array($this, 'login_after'));
$this->add_hook('login_failed', array($this, 'login_failed'));
}
}

public function loginform($loginform)
Expand Down

0 comments on commit 8034f90

Please sign in to comment.