8use Psr\Log\LoggerInterface;
24 private LoggerInterface $logger;
30 LoggerInterface $logger,
34 $this->options = $options;
35 $this->logger = $logger;
36 $this->textFormatter = $textFormatter;
40 private function getOnWikiExemptionList() {
41 $list = $this->textFormatter->
format(
42 MessageValue::new(
'block-autoblock-exemptionlist' )
44 $lines = explode(
"\n", $list );
46 foreach ( $lines as $line ) {
48 if ( !str_starts_with( $line,
'*' ) ) {
52 $wlEntry = substr( $line, 1 );
53 $wlEntry = trim( $wlEntry );
59 private function getExemptionList() {
62 yield from $this->getOnWikiExemptionList();
72 $this->logger->debug(
"Checking the autoblock exemption list.." );
73 foreach ( $this->getExemptionList() as $wlEntry ) {
74 $this->logger->debug(
"Checking $ip against $wlEntry..." );
77 if ( IPUtils::isInRange( $ip, $wlEntry ) ) {
78 $this->logger->debug(
" IP $ip matches $wlEntry, not autoblocking" );
81 $this->logger->debug(
" No match" );
A class containing constants representing the names of configuration variables.
const AutoblockExemptions
Name constant for the AutoblockExemptions setting, for use with Config::get()
format(MessageSpecifier $message)
Convert a MessageSpecifier to text.