File: dns.py

package info (click to toggle)
python-pyfunceble 4.2.29.dev-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,108 kB
  • sloc: python: 27,413; sh: 142; makefile: 27
file content (146 lines) | stat: -rw-r--r-- 6,830 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
"""
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://docs.pyfunceble.com

Project homepage:
    https://pyfunceble.github.io/

License:
::


    Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 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

        https://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


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_dns_match, ("SOA", ["abuse.changeip.com."]))
            ]
        }

        super().__init__(status)

    @ExtraRuleHandlerBase.ensure_status_is_given
    @ExtraRuleHandlerBase.setup_status_before
    @ExtraRuleHandlerBase.setup_status_after
    def start(self) -> "DNSRulesHandler":
        """
        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 self.regex_helper.set_regex(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,
        )