-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit fea6ad7 Author: funilrys <contact@funilrys.com> Date: Sat Dec 3 10:21:10 2022 +0100 fixup! Introduction of the changeip SPECIAL rule. commit 6a96637 Author: funilrys <contact@funilrys.com> Date: Thu Dec 1 21:34:25 2022 +0100 Introduction of the changeip SPECIAL rule. This patch fixes #311. Also: * Introduction of checker/availability/extras/dns.py From now on any changeip platform domains that were disabled for abuse will be switch to the `INACTIVE` status. To do that, this patch looks at the SOA record of the domain and look for `abuse.changeip.com` in the response. Contributors: * @smed79
- Loading branch information
Showing
4 changed files
with
379 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
""" | ||
The tool to check the availability or syntax of domain, IP or URL. | ||
:: | ||
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗ | ||
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝ | ||
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗ | ||
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝ | ||
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗ | ||
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝ | ||
Provides the extra rules handler based on some DNS records. | ||
Author: | ||
Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom | ||
Special thanks: | ||
https://pyfunceble.github.io/#/special-thanks | ||
Contributors: | ||
https://pyfunceble.github.io/#/contributors | ||
Project link: | ||
https://github.com/funilrys/PyFunceble | ||
Project documentation: | ||
https://pyfunceble.readthedocs.io/en/dev/ | ||
Project homepage: | ||
https://pyfunceble.github.io/ | ||
License: | ||
:: | ||
Copyright 2017, 2018, 2019, 2020, 2022 Nissar Chababy | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
""" | ||
|
||
from typing import Optional | ||
|
||
import PyFunceble.facility | ||
from PyFunceble.checker.availability.extras.base import ExtraRuleHandlerBase | ||
from PyFunceble.checker.availability.status import AvailabilityCheckerStatus | ||
from PyFunceble.helpers.regex import RegexHelper | ||
|
||
|
||
class DNSRulesHandler(ExtraRuleHandlerBase): | ||
""" | ||
Provides our very own sets of DNS based rules. | ||
:param status: | ||
The previously gathered status. | ||
:type status: | ||
:class:`~PyFunceble.checker.availability.status.AvailabilityCheckerStatus` | ||
""" | ||
|
||
rulesets: dict = {} | ||
|
||
def __init__(self, status: Optional[AvailabilityCheckerStatus] = None) -> None: | ||
self.rulesets = { | ||
r"\.(25u\.com|2waky\.com|3-a\.net|4dq\.com|4pu\.com|acmetoy\.com|" | ||
r"almostmy\.com|americanunfinished\.com|as19557\.net|" | ||
r"authorizeddns\.net|authorizeddns\.org|authorizeddns\.us|" | ||
r"b0tnet\.com|bigmoney\.biz|changeip\.biz|changeip\.co|" | ||
r"changeip\.net|changeip\.org|changeip\.us|cleansite\.biz|" | ||
r"cleansite\.info|cleansite\.us|ddns\.info|ddns\.mobi|ddns\.ms|" | ||
r"ddns\.us|dhcp\.biz|dns-dns\.com|dns-report\.com|dns-stuff\.com|" | ||
r"dns04\.com|dns05\.com|dns1\.us|dns2\.us|dnset\.com|" | ||
r"dnsfailover\.net|dnsrd\.com|dsmtp\.biz|dsmtp\.com|dubya\.biz|" | ||
r"dubya\.info|dubya\.net|dubya\.us|dumb1\.com|dynamic-dns\.net|" | ||
r"dynamicdns\.biz|dynssl\.com|edns\.biz|esmtp\.biz|ezua\.com|" | ||
r"faqserv\.com|fartit\.com|freeddns\.com|freetcp\.com|freewww\.biz|" | ||
r"freewww\.info|ftp1\.biz|ftpserver\.biz|gettrials\.com|" | ||
r"got-game\.org|gr8domain\.biz|gr8name\.biz|homingbeacon\.net|" | ||
r"https443\.net|https443\.org|ikwb\.com|instanthq\.com|iownyour\.biz|" | ||
r"iownyour\.org|isasecret\.com|itemdb\.com|itsaol\.com|jetos\.com|" | ||
r"jkub\.com|jungleheart\.com|justdied\.com|lflink\.com|lflinkup\.com|" | ||
r"lflinkup\.net|lflinkup\.org|longmusic\.com|mefound\.com|" | ||
r"misecure\.com|moneyhome\.biz|mrbasic\.com|mrbonus\.com|mrface\.com|" | ||
r"mrslove\.com|my03\.com|mydad\.info|myddns\.com|myftp\.info|" | ||
r"mylftv\.com|mymom\.info|mynetav\.com|mynetav\.net|mynetav\.org|" | ||
r"mynumber\.org|mypicture\.info|mypop3\.net|mypop3\.org|" | ||
r"mysecondarydns\.com|mywww\.biz|myz\.info|ninth\.biz|ns01\.biz|" | ||
r"ns01\.info|ns01\.us|ns02\.biz|ns02\.info|ns02\.us|ns1\.name|" | ||
r"ns2\.name|ns3\.name|ocry\.com|onedumb\.com|onmypc\.biz|" | ||
r"onmypc\.info|onmypc\.net|onmypc\.org|onmypc\.us|" | ||
r"organiccrap\.com|otzo\.com|ourhobby\.com|port25\.biz|" | ||
r"proxydns\.com|qhigh\.com|qpoe\.com|rebatesrule\.net|" | ||
r"sendsmtp\.com|serveuser\.com|serveusers\.com|sexidude\.com|" | ||
r"sexxxy\.biz|sixth\.biz|squirly\.info|ssl443\.org|ssmailer\.com|" | ||
r"toh\.info|toshibanetcam\.com|toythieves\.com|trickip\.net|" | ||
r"trickip\.org|vizvaz\.com|wikaba\.com|www1\.biz|" | ||
r"wwwhost\.biz|wwwhost\.us|x24hr\.com|xxuz\.com|xxxy\.biz|" | ||
r"xxxy\.info|ygto\.com|youdontcare\.com|yourtrap\.com|" | ||
r"zyns\.com|zzux\.com)(\.|)$": [ | ||
(self._switch_down_if_match, ("SOA", ["abuse.changeip.com."])) | ||
] | ||
} | ||
|
||
super().__init__(status) | ||
|
||
def _switch_down_if_match( | ||
self, query_type: str, matches: list | ||
) -> "DNSRulesHandler": | ||
""" | ||
Tries to switch the status :code:`INACTIVE` if the query matched. | ||
""" | ||
|
||
result = ( | ||
self.dns_query_tool.set_query_record_type(query_type) | ||
.set_subject(self.status.netloc) | ||
.query() | ||
) | ||
|
||
for record in result: | ||
for match in matches: | ||
if match in record: | ||
self.switch_to_down() | ||
break | ||
|
||
@ExtraRuleHandlerBase.ensure_status_is_given | ||
@ExtraRuleHandlerBase.setup_status_before | ||
@ExtraRuleHandlerBase.setup_status_after | ||
def start(self) -> "SubjectSwitchRulesHandler": | ||
""" | ||
Process the check and handling of the current subject. | ||
""" | ||
|
||
PyFunceble.facility.Logger.info( | ||
"Started to check %r against our subject switcher rules.", | ||
self.status.idna_subject, | ||
) | ||
|
||
for regex, rulesets in self.rulesets.items(): | ||
if self.status.status_after_extra_rules: | ||
break | ||
|
||
if not RegexHelper(regex).match(self.status.netloc, return_match=False): | ||
break | ||
|
||
for ruler, params in rulesets: | ||
if self.status.status_after_extra_rules: | ||
break | ||
|
||
ruler(*params) | ||
|
||
PyFunceble.facility.Logger.info( | ||
"Finished to check %r against our subject switcher rules.", | ||
self.status.idna_subject, | ||
) |
Oops, something went wrong.