summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Quantum/Plugin/BlockIP.pm
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-07-23 17:24:13 +0200
committerDylan William Hardison <dylan@hardison.net>2018-07-31 18:57:17 +0200
commit8ca2304eea840e37bcf182f21e2c14bd21ad9cd7 (patch)
treef00549d638af4420be0634e0bf46725d50f96a95 /Bugzilla/Quantum/Plugin/BlockIP.pm
parent0840339ee8a77fac943338f7ca354261c3d1066c (diff)
downloadbugzilla-8ca2304eea840e37bcf182f21e2c14bd21ad9cd7.tar.gz
bugzilla-8ca2304eea840e37bcf182f21e2c14bd21ad9cd7.tar.xz
more tidy
Diffstat (limited to 'Bugzilla/Quantum/Plugin/BlockIP.pm')
-rw-r--r--Bugzilla/Quantum/Plugin/BlockIP.pm20
1 files changed, 10 insertions, 10 deletions
diff --git a/Bugzilla/Quantum/Plugin/BlockIP.pm b/Bugzilla/Quantum/Plugin/BlockIP.pm
index fbfffad66..ebeb2a4aa 100644
--- a/Bugzilla/Quantum/Plugin/BlockIP.pm
+++ b/Bugzilla/Quantum/Plugin/BlockIP.pm
@@ -4,34 +4,34 @@ use Mojo::Base 'Mojolicious::Plugin';
use Bugzilla::Memcached;
-use constant BLOCK_TIMEOUT => 60*60;
+use constant BLOCK_TIMEOUT => 60 * 60;
-my $MEMCACHED = Bugzilla::Memcached->_new()->{memcached};
+my $MEMCACHED = Bugzilla::Memcached->new()->{memcached};
sub register {
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) = @_;
+ my ( $class, $ip ) = @_;
$MEMCACHED->delete("block_ip:$ip") if $MEMCACHED;
}
sub _before_routes {
- my ( $c ) = @_;
+ my ($c) = @_;
return if $c->stash->{'mojo.static'};
my $ip = $c->tx->remote_address;
- if ($MEMCACHED && $MEMCACHED->get("block_ip:$ip")) {
+ if ( $MEMCACHED && $MEMCACHED->get("block_ip:$ip") ) {
$c->block_ip($ip);
$c->res->code(429);
$c->res->message("Too Many Requests");