Skip to content

# Ipv4 reputation

The tool to check the availability or syntax of domain, IP or URL.

::

    ██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
    ██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
    ██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
    ██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
    ██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
    ╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝

Provides an interface which let us interact with the IPv4 reputation database.

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, 2025 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.

## `IPV4ReputationDataset`

Bases: `DatasetBase`

Provides the interface for the lookup of the IPv4 reputation.

Source code in `PyFunceble/dataset/ipv4_reputation.py`

     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

    class IPV4ReputationDataset(DatasetBase):
        """
        Provides the interface for the lookup of the IPv4 reputation.
        """

        STORAGE_INDEX: Optional[str] = None
        downloader: Optional[IPV4ReputationDownloader] = None

        def __init__(self) -> None:
            self.downloader = IPV4ReputationDownloader()
            self.source_file = self.downloader.destination

        def __contains__(self, value: Any) -> bool:
            with self.get_content() as file_stream:
                for line in file_stream:
                    line = line.strip()

                    if line.startswith(f"{value}#"):
                        return True

            return False

        @DatasetBase.ensure_source_file_exists
        def get_content(self) -> open:
            """
            Provides a file handler which does let you read the content line by
            line.

            :raise FileNotFoundError:
                When the declared file does not exists.
            """

            file_helper = FileHelper(self.source_file)

            if not file_helper.exists() and bool(self.downloader):  # pragma: no cover
                ## pragma reason: Safety.
                self.downloader.start()

                if not file_helper.exists():
                    raise FileNotFoundError(file_helper.path)

            return file_helper.open("r", encoding="utf-8")

### `get_content()`

Provides a file handler which does let you read the content line by line.

Raises:

Type | Description
--- | ---
`FileNotFoundError` | When the declared file does not exists.

Source code in `PyFunceble/dataset/ipv4_reputation.py`

     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101

    @DatasetBase.ensure_source_file_exists
    def get_content(self) -> open:
        """
        Provides a file handler which does let you read the content line by
        line.

        :raise FileNotFoundError:
            When the declared file does not exists.
        """

        file_helper = FileHelper(self.source_file)

        if not file_helper.exists() and bool(self.downloader):  # pragma: no cover
            ## pragma reason: Safety.
            self.downloader.start()

            if not file_helper.exists():
                raise FileNotFoundError(file_helper.path)

        return file_helper.open("r", encoding="utf-8")