• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

funilrys / PyFunceble / 3607917966

pending completion
3607917966

push

github-actions

funilrys
fixup! Introduction of the changeip SPECIAL rule.

11094 of 11508 relevant lines covered (96.4%)

11.55 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

44.44
/PyFunceble/checker/availability/extras/dns.py
1
"""
2
The tool to check the availability or syntax of domain, IP or URL.
3

4
::
5

6

7
    ██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
8
    ██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
9
    ██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
10
    ██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
11
    ██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
12
    ╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
13

14
Provides the extra rules handler based on some DNS records.
15

16
Author:
17
    Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
18

19
Special thanks:
20
    https://pyfunceble.github.io/#/special-thanks
21

22
Contributors:
23
    https://pyfunceble.github.io/#/contributors
24

25
Project link:
26
    https://github.com/funilrys/PyFunceble
27

28
Project documentation:
29
    https://pyfunceble.readthedocs.io/en/dev/
30

31
Project homepage:
32
    https://pyfunceble.github.io/
33

34
License:
35
::
36

37

38
    Copyright 2017, 2018, 2019, 2020, 2022 Nissar Chababy
39

40
    Licensed under the Apache License, Version 2.0 (the "License");
41
    you may not use this file except in compliance with the License.
42
    You may obtain a copy of the License at
43

44
        http://www.apache.org/licenses/LICENSE-2.0
45

46
    Unless required by applicable law or agreed to in writing, software
47
    distributed under the License is distributed on an "AS IS" BASIS,
48
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
49
    See the License for the specific language governing permissions and
50
    limitations under the License.
51
"""
52

53
from typing import Optional
12✔
54

55
import PyFunceble.facility
12✔
56
from PyFunceble.checker.availability.extras.base import ExtraRuleHandlerBase
12✔
57
from PyFunceble.checker.availability.status import AvailabilityCheckerStatus
12✔
58
from PyFunceble.helpers.regex import RegexHelper
12✔
59

60

61
class DNSRulesHandler(ExtraRuleHandlerBase):
12✔
62
    """
63
    Provides our very own sets of DNS based rules.
64

65
    :param status:
66
        The previously gathered status.
67
    :type status:
68
        :class:`~PyFunceble.checker.availability.status.AvailabilityCheckerStatus`
69
    """
70

71
    rulesets: dict = {}
12✔
72

73
    def __init__(self, status: Optional[AvailabilityCheckerStatus] = None) -> None:
74
        self.rulesets = {
75
            r"\.(25u\.com|2waky\.com|3-a\.net|4dq\.com|4pu\.com|acmetoy\.com|"
76
            r"almostmy\.com|americanunfinished\.com|as19557\.net|"
77
            r"authorizeddns\.net|authorizeddns\.org|authorizeddns\.us|"
78
            r"b0tnet\.com|bigmoney\.biz|changeip\.biz|changeip\.co|"
79
            r"changeip\.net|changeip\.org|changeip\.us|cleansite\.biz|"
80
            r"cleansite\.info|cleansite\.us|ddns\.info|ddns\.mobi|ddns\.ms|"
81
            r"ddns\.us|dhcp\.biz|dns-dns\.com|dns-report\.com|dns-stuff\.com|"
82
            r"dns04\.com|dns05\.com|dns1\.us|dns2\.us|dnset\.com|"
83
            r"dnsfailover\.net|dnsrd\.com|dsmtp\.biz|dsmtp\.com|dubya\.biz|"
84
            r"dubya\.info|dubya\.net|dubya\.us|dumb1\.com|dynamic-dns\.net|"
85
            r"dynamicdns\.biz|dynssl\.com|edns\.biz|esmtp\.biz|ezua\.com|"
86
            r"faqserv\.com|fartit\.com|freeddns\.com|freetcp\.com|freewww\.biz|"
87
            r"freewww\.info|ftp1\.biz|ftpserver\.biz|gettrials\.com|"
88
            r"got-game\.org|gr8domain\.biz|gr8name\.biz|homingbeacon\.net|"
89
            r"https443\.net|https443\.org|ikwb\.com|instanthq\.com|iownyour\.biz|"
90
            r"iownyour\.org|isasecret\.com|itemdb\.com|itsaol\.com|jetos\.com|"
91
            r"jkub\.com|jungleheart\.com|justdied\.com|lflink\.com|lflinkup\.com|"
92
            r"lflinkup\.net|lflinkup\.org|longmusic\.com|mefound\.com|"
93
            r"misecure\.com|moneyhome\.biz|mrbasic\.com|mrbonus\.com|mrface\.com|"
94
            r"mrslove\.com|my03\.com|mydad\.info|myddns\.com|myftp\.info|"
95
            r"mylftv\.com|mymom\.info|mynetav\.com|mynetav\.net|mynetav\.org|"
96
            r"mynumber\.org|mypicture\.info|mypop3\.net|mypop3\.org|"
97
            r"mysecondarydns\.com|mywww\.biz|myz\.info|ninth\.biz|ns01\.biz|"
98
            r"ns01\.info|ns01\.us|ns02\.biz|ns02\.info|ns02\.us|ns1\.name|"
99
            r"ns2\.name|ns3\.name|ocry\.com|onedumb\.com|onmypc\.biz|"
100
            r"onmypc\.info|onmypc\.net|onmypc\.org|onmypc\.us|"
101
            r"organiccrap\.com|otzo\.com|ourhobby\.com|port25\.biz|"
102
            r"proxydns\.com|qhigh\.com|qpoe\.com|rebatesrule\.net|"
103
            r"sendsmtp\.com|serveuser\.com|serveusers\.com|sexidude\.com|"
104
            r"sexxxy\.biz|sixth\.biz|squirly\.info|ssl443\.org|ssmailer\.com|"
105
            r"toh\.info|toshibanetcam\.com|toythieves\.com|trickip\.net|"
106
            r"trickip\.org|vizvaz\.com|wikaba\.com|www1\.biz|"
107
            r"wwwhost\.biz|wwwhost\.us|x24hr\.com|xxuz\.com|xxxy\.biz|"
108
            r"xxxy\.info|ygto\.com|youdontcare\.com|yourtrap\.com|"
109
            r"zyns\.com|zzux\.com)(\.|)$": [
110
                (self._switch_down_if_match, ("SOA", ["abuse.changeip.com."]))
111
            ]
112
        }
113

114
        super().__init__(status)
115

116
    def _switch_down_if_match(
12✔
117
        self, query_type: str, matches: list
118
    ) -> "DNSRulesHandler":
119
        """
120
        Tries to switch the status :code:`INACTIVE` if the query matched.
121
        """
122

123
        result = (
×
124
            self.dns_query_tool.set_query_record_type(query_type)
125
            .set_subject(self.status.netloc)
126
            .query()
127
        )
128

129
        for record in result:
×
130
            for match in matches:
×
131
                if match in record:
×
132
                    self.switch_to_down()
×
133
                    break
×
134

135
    @ExtraRuleHandlerBase.ensure_status_is_given
12✔
136
    @ExtraRuleHandlerBase.setup_status_before
12✔
137
    @ExtraRuleHandlerBase.setup_status_after
12✔
138
    def start(self) -> "SubjectSwitchRulesHandler":
12✔
139
        """
140
        Process the check and handling of the current subject.
141
        """
142

143
        PyFunceble.facility.Logger.info(
144
            "Started to check %r against our subject switcher rules.",
145
            self.status.idna_subject,
146
        )
147

148
        for regex, rulesets in self.rulesets.items():
×
149
            if self.status.status_after_extra_rules:
×
150
                break
×
151

152
            if not RegexHelper(regex).match(self.status.netloc, return_match=False):
×
153
                break
×
154

155
            for ruler, params in rulesets:
×
156
                if self.status.status_after_extra_rules:
×
157
                    break
×
158

159
                ruler(*params)
×
160

161
        PyFunceble.facility.Logger.info(
162
            "Finished to check %r against our subject switcher rules.",
163
            self.status.idna_subject,
164
        )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc