Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 5 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
||
LoadExitNodes | n/a |
0 / 0 |
n/a |
0 / 0 |
5 | n/a |
0 / 0 |
|||
__construct | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
execute | n/a |
0 / 0 |
n/a |
0 / 0 |
4 |
1 | <?php |
2 | |
3 | /** |
4 | * Updates the tor exit node list |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. |
10 | * |
11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU General Public License along |
17 | * with this program; if not, write to the Free Software Foundation, Inc., |
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
19 | * http://www.gnu.org/copyleft/gpl.html |
20 | * |
21 | * @file |
22 | * @ingroup Extensions |
23 | */ |
24 | |
25 | namespace MediaWiki\Extension\TorBlock; |
26 | |
27 | use MediaWiki\Maintenance\Maintenance; |
28 | |
29 | require_once getenv( 'MW_INSTALL_PATH' ) !== false |
30 | ? getenv( 'MW_INSTALL_PATH' ) . "/maintenance/Maintenance.php" |
31 | : __DIR__ . '/../../../maintenance/Maintenance.php'; |
32 | |
33 | /** |
34 | * Maintenance script to load/reload the list of Tor exit nodes. |
35 | * |
36 | * @ingroup Maintenance |
37 | * @ingroup Extensions |
38 | * |
39 | * @codeCoverageIgnore |
40 | */ |
41 | class LoadExitNodes extends Maintenance { |
42 | public function __construct() { |
43 | parent::__construct(); |
44 | $this->addDescription( "Load the list of Tor exit nodes." ); |
45 | $this->addOption( 'force', 'Force loading of exit nodes from the server rather than cache.' ); |
46 | $this->addOption( 'show', 'Print the list of exist nodes' ); |
47 | $this->requireExtension( "TorBlock" ); |
48 | } |
49 | |
50 | public function execute() { |
51 | if ( $this->hasOption( 'force' ) ) { |
52 | $nodes = TorExitNodes::loadExitNodes(); |
53 | } else { |
54 | $nodes = TorExitNodes::getExitNodes(); |
55 | } |
56 | if ( !$nodes ) { |
57 | $this->fatalError( "Could not load exit nodes." ); |
58 | } |
59 | |
60 | $this->output( 'Successfully loaded ' . count( $nodes ) . " exit nodes.\n" ); |
61 | |
62 | if ( $this->hasOption( 'show' ) ) { |
63 | $this->output( implode( "\n", $nodes ) . "\n" ); |
64 | } |
65 | } |
66 | } |
67 | |
68 | $maintClass = LoadExitNodes::class; |
69 | require_once RUN_MAINTENANCE_IF_MAIN; |