summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2017-09-11 18:59:58 +0200
committerGitHub <noreply@github.com>2017-09-11 18:59:58 +0200
commitce38f8be741a8b618dfac9d2f6f166a6e3954e45 (patch)
tree67c2d67bc1c180bb2be80e12b6d07bf9ef42446f /scripts
parentd3cf76c62299d9ff9e3589a3c159571711d8d186 (diff)
downloadbugzilla-ce38f8be741a8b618dfac9d2f6f166a6e3954e45.tar.gz
bugzilla-ce38f8be741a8b618dfac9d2f6f166a6e3954e45.tar.xz
Bug 1393888 - Write httpd access handler to block by ip address stored in memcached
Diffstat (limited to 'scripts')
-rw-r--r--scripts/block-ip.pl55
1 files changed, 55 insertions, 0 deletions
diff --git a/scripts/block-ip.pl b/scripts/block-ip.pl
new file mode 100644
index 000000000..b767a1fd5
--- /dev/null
+++ b/scripts/block-ip.pl
@@ -0,0 +1,55 @@
+#!/usr/bin/perl
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+use strict;
+use warnings;
+use lib qw(. lib local/lib/perl5);
+
+use Bugzilla;
+use Bugzilla::Constants;
+use Bugzilla::ModPerl::BlockIP;
+use Getopt::Long;
+
+Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
+
+my $unblock;
+GetOptions('unblock' => \$unblock);
+
+pod2usage("No IPs given") unless @ARGV;
+
+if ($unblock) {
+ Bugzilla::ModPerl::BlockIP->unblock_ip($_) for @ARGV;
+} else {
+ Bugzilla::ModPerl::BlockIP->block_ip($_) for @ARGV;
+}
+
+=head1 NAME
+
+block-ip.pl -- block or unlock ip addresses from Bugzilla's IP block list
+
+=head1 SYNOPSIS
+
+block-ip.pl [--unblock] ip1 [ip2 ...]
+
+ Options:
+ --unblock instead of blocking, unblock the listed IPs
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<--unblock>
+
+If passed, the IPs will be unblocked instead of blocked. Use this to remove IPs from the blocklist.
+
+=back
+
+=head1 DESCRIPTION
+
+This is just a simple CLI inteface to L<Bugzilla::ModPerl::BlockIP>.