summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Quantum/Plugin/BlockIP.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/Quantum/Plugin/BlockIP.pm')
-rw-r--r--Bugzilla/Quantum/Plugin/BlockIP.pm38
1 files changed, 19 insertions, 19 deletions
diff --git a/Bugzilla/Quantum/Plugin/BlockIP.pm b/Bugzilla/Quantum/Plugin/BlockIP.pm
index 058ecbf64..974eebff9 100644
--- a/Bugzilla/Quantum/Plugin/BlockIP.pm
+++ b/Bugzilla/Quantum/Plugin/BlockIP.pm
@@ -9,35 +9,35 @@ use constant BLOCK_TIMEOUT => 60 * 60;
my $MEMCACHED = Bugzilla::Memcached->new()->{memcached};
sub register {
- my ( $self, $app, $conf ) = @_;
+ my ($self, $app, $conf) = @_;
- $app->hook( before_routes => \&_before_routes );
- $app->helper( block_ip => \&_block_ip );
- $app->helper( unblock_ip => \&_unblock_ip );
+ $app->hook(before_routes => \&_before_routes);
+ $app->helper(block_ip => \&_block_ip);
+ $app->helper(unblock_ip => \&_unblock_ip);
}
sub _block_ip {
- my ( $class, $ip ) = @_;
- $MEMCACHED->set( "block_ip:$ip" => 1, BLOCK_TIMEOUT ) if $MEMCACHED;
+ my ($class, $ip) = @_;
+ $MEMCACHED->set("block_ip:$ip" => 1, BLOCK_TIMEOUT) if $MEMCACHED;
}
sub _unblock_ip {
- my ( $class, $ip ) = @_;
- $MEMCACHED->delete("block_ip:$ip") if $MEMCACHED;
+ my ($class, $ip) = @_;
+ $MEMCACHED->delete("block_ip:$ip") if $MEMCACHED;
}
sub _before_routes {
- my ($c) = @_;
- return if $c->stash->{'mojo.static'};
-
- my $ip = $c->tx->remote_address;
- if ( $MEMCACHED && $MEMCACHED->get("block_ip:$ip") ) {
- $c->block_ip($ip);
- $c->res->code(429);
- $c->res->message('Too Many Requests');
- $c->res->body('Too Many Requests');
- $c->finish;
- }
+ my ($c) = @_;
+ return if $c->stash->{'mojo.static'};
+
+ my $ip = $c->tx->remote_address;
+ if ($MEMCACHED && $MEMCACHED->get("block_ip:$ip")) {
+ $c->block_ip($ip);
+ $c->res->code(429);
+ $c->res->message('Too Many Requests');
+ $c->res->body('Too Many Requests');
+ $c->finish;
+ }
}
1;