dns-client


Namedns-client JSON
Version 0.2.4 PyPI version JSON
download
home_page
Summary
upload_time2024-03-04 09:07:31
maintainer
docs_urlNone
authorSergey M
requires_python>=3.11.7
licenseFUCK LICENSE
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python DNS Client Library

[ ![PyPI - Python Version](https://img.shields.io/pypi/v/dns-client) ]()
[ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/dns-client) ]()
[ ![PyPI - Downloads](https://img.shields.io/pypi/dm/dns-client) ]()

Python client library for sending DNS queries.

Featurtes:

* supports DNS over TLS (DOT)
* contains adapter for requests
* threadsafe
* null-dependency

Install:

```bash
# from pypi.org
pip install dns-client

# latest commit
pip install git+https://github.com/s3rgeym/python-dns-client.git
```

Examples:

```python
In [1]: from dns_client import DNSClient, RecordType

In [2]: c = DNSClient('1.1.1.1', over_tls=True)

In [3]: c.query('ya.ru', RecordType.AAAA)
Out[3]: [Record(name='ya.ru', qtype=<RecordType.AAAA: 28>, qclass=<RecordClass.IN: 1>, ttl=76, value='2a02:6b8::2:242')]

In [4]: c.query('ya.ru', RecordType.MX)
Out[4]: [Record(name='ya.ru', qtype=<RecordType.MX: 15>, qclass=<RecordClass.IN: 1>, ttl=2242, value=(10, 'mx.yandex.ru'))]

In [5]: c.get_query_response('ya.ru')
Out[5]: Packet(header=Header(id=47527, response=True, opcode=<OpCode.QUERY: 0>, authoritative=False, truncated=False, recursion_desired=True, recursion_available=True, reserved=False, authentic_data=False, check_disabled=False, rcode=<ResponseCode.NOERROR: 0>, num_questions=1, num_records=2, num_authorities=0, num_additionals=0), questions=[Question(name='ya.ru', qtype=<RecordType.A: 1>, qclass=<RecordClass.IN: 1>)], records=[Record(name='ya.ru', qtype=<RecordType.A: 1>, qclass=<RecordClass.IN: 1>, ttl=266, value='77.88.55.242'), Record(name='ya.ru', qtype=<RecordType.A: 1>, qclass=<RecordClass.IN: 1>, ttl=266, value='5.255.255.242')])

In [6]: c.get_all_records('ya.ru')
Out[6]:
[('A', '5.255.255.242'),
 ('A', '77.88.55.242'),
 ('AAAA', '2a02:6b8::2:242'),
 ('MX', (10, 'mx.yandex.ru')),
 ('NS', 'ns1.yandex.ru'),
 ('NS', 'ns2.yandex.ru'),
 ('TXT',
  '_globalsign-domain-verification=eLi0_-xATuNmRfuTIX8VQIvgfyi7Od7Hph4V0yNisF'),
 ('TXT',
  '_globalsign-domain-verification=xUUDG4u7Zo56EmmFewz7Y4UK3MfAU7QSjAgBsy0w6q'),
 ('TXT',
  'google-site-verification=SVTEeUiCU4KV-5qGw4o4JPok7mfsP8NtQTIdN6tt6Nw'),
 ('TXT', 'v=spf1 redirect=_spf.yandex.ru'),
 ('TXT',
  '_globalsign-domain-verification=dHoe580bPQ-lfi_vh-BEIwB4NAtUwURIzrzsivByVL'),
 ('TXT', 'e1c8e4dd3d13fad0dd9e8ed54a1813ececd3d5412fb16c4ed2c0612332950fe')]
```

You can use `dns-client` with `requests`:

```python
from dns_client.adapters.requests import DNSClientSession

s = DNSClientSession('8.8.8.8')
r = s.get('https://google.com')
print(r.headers)
```

CLI Usage:

```bash
$ python -m dns_client ya.ru -t ns -H 8.8.8.8 --tls -pr
Response Flags = 0x8180

1... .... .... .... = Response (True)
.000 0... .... .... = Opcode (<OpCode.QUERY: 0>)
.... .0.. .... .... = Authoritative (False)
.... ..0. .... .... = Truncated (False)
.... ...1 .... .... = Recursion Desired (True)
.... .... 1... .... = Recursion Available (True)
.... .... .0.. .... = Reserved (False)
.... .... ..0. .... = Authentic Data (False)
.... .... ...0 .... = Check Disabled (False)
.... .... .... 0000 = Rcode (<ResponseCode.NOERROR: 0>)

Number of Records       : 2
Number of Questions     : 1
Number of Authorities   : 0
Number of Additionals   : 0

ns1.yandex.ru
ns2.yandex.ru
```

| Arg | Desc |
| --- | --- |
| `-t` | record type |
| `-H` | dns address |
| `--tls` | dns over tls aka d.o.t. |
| `-pr` | print response |

See all arguments:

```bash
python -m dns_client -h
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "dns-client",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Sergey M",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/86/83/476dcd70abb32c96a822bcdf5b1d05e3ab3bbcbfad06f4eb736b244d01d9/dns-client-0.2.4.tar.gz",
    "platform": null,
    "description": "# Python DNS Client Library\n\n[ ![PyPI - Python Version](https://img.shields.io/pypi/v/dns-client) ]()\n[ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/dns-client) ]()\n[ ![PyPI - Downloads](https://img.shields.io/pypi/dm/dns-client) ]()\n\nPython client library for sending DNS queries.\n\nFeaturtes:\n\n* supports DNS over TLS (DOT)\n* contains adapter for requests\n* threadsafe\n* null-dependency\n\nInstall:\n\n```bash\n# from pypi.org\npip install dns-client\n\n# latest commit\npip install git+https://github.com/s3rgeym/python-dns-client.git\n```\n\nExamples:\n\n```python\nIn [1]: from dns_client import DNSClient, RecordType\n\nIn [2]: c = DNSClient('1.1.1.1', over_tls=True)\n\nIn [3]: c.query('ya.ru', RecordType.AAAA)\nOut[3]: [Record(name='ya.ru', qtype=<RecordType.AAAA: 28>, qclass=<RecordClass.IN: 1>, ttl=76, value='2a02:6b8::2:242')]\n\nIn [4]: c.query('ya.ru', RecordType.MX)\nOut[4]: [Record(name='ya.ru', qtype=<RecordType.MX: 15>, qclass=<RecordClass.IN: 1>, ttl=2242, value=(10, 'mx.yandex.ru'))]\n\nIn [5]: c.get_query_response('ya.ru')\nOut[5]: Packet(header=Header(id=47527, response=True, opcode=<OpCode.QUERY: 0>, authoritative=False, truncated=False, recursion_desired=True, recursion_available=True, reserved=False, authentic_data=False, check_disabled=False, rcode=<ResponseCode.NOERROR: 0>, num_questions=1, num_records=2, num_authorities=0, num_additionals=0), questions=[Question(name='ya.ru', qtype=<RecordType.A: 1>, qclass=<RecordClass.IN: 1>)], records=[Record(name='ya.ru', qtype=<RecordType.A: 1>, qclass=<RecordClass.IN: 1>, ttl=266, value='77.88.55.242'), Record(name='ya.ru', qtype=<RecordType.A: 1>, qclass=<RecordClass.IN: 1>, ttl=266, value='5.255.255.242')])\n\nIn [6]: c.get_all_records('ya.ru')\nOut[6]:\n[('A', '5.255.255.242'),\n ('A', '77.88.55.242'),\n ('AAAA', '2a02:6b8::2:242'),\n ('MX', (10, 'mx.yandex.ru')),\n ('NS', 'ns1.yandex.ru'),\n ('NS', 'ns2.yandex.ru'),\n ('TXT',\n  '_globalsign-domain-verification=eLi0_-xATuNmRfuTIX8VQIvgfyi7Od7Hph4V0yNisF'),\n ('TXT',\n  '_globalsign-domain-verification=xUUDG4u7Zo56EmmFewz7Y4UK3MfAU7QSjAgBsy0w6q'),\n ('TXT',\n  'google-site-verification=SVTEeUiCU4KV-5qGw4o4JPok7mfsP8NtQTIdN6tt6Nw'),\n ('TXT', 'v=spf1 redirect=_spf.yandex.ru'),\n ('TXT',\n  '_globalsign-domain-verification=dHoe580bPQ-lfi_vh-BEIwB4NAtUwURIzrzsivByVL'),\n ('TXT', 'e1c8e4dd3d13fad0dd9e8ed54a1813ececd3d5412fb16c4ed2c0612332950fe')]\n```\n\nYou can use `dns-client` with `requests`:\n\n```python\nfrom dns_client.adapters.requests import DNSClientSession\n\ns = DNSClientSession('8.8.8.8')\nr = s.get('https://google.com')\nprint(r.headers)\n```\n\nCLI Usage:\n\n```bash\n$ python -m dns_client ya.ru -t ns -H 8.8.8.8 --tls -pr\nResponse Flags = 0x8180\n\n1... .... .... .... = Response (True)\n.000 0... .... .... = Opcode (<OpCode.QUERY: 0>)\n.... .0.. .... .... = Authoritative (False)\n.... ..0. .... .... = Truncated (False)\n.... ...1 .... .... = Recursion Desired (True)\n.... .... 1... .... = Recursion Available (True)\n.... .... .0.. .... = Reserved (False)\n.... .... ..0. .... = Authentic Data (False)\n.... .... ...0 .... = Check Disabled (False)\n.... .... .... 0000 = Rcode (<ResponseCode.NOERROR: 0>)\n\nNumber of Records       : 2\nNumber of Questions     : 1\nNumber of Authorities   : 0\nNumber of Additionals   : 0\n\nns1.yandex.ru\nns2.yandex.ru\n```\n\n| Arg | Desc |\n| --- | --- |\n| `-t` | record type |\n| `-H` | dns address |\n| `--tls` | dns over tls aka d.o.t. |\n| `-pr` | print response |\n\nSee all arguments:\n\n```bash\npython -m dns_client -h\n```\n",
    "bugtrack_url": null,
    "license": "FUCK LICENSE ",
    "summary": "",
    "version": "0.2.4",
    "project_urls": {
        "Repository": "https://github.com/s3rgeym/python-dns-client.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f9f6d5dac34be3896bb5664bb0d87a76a499caa299fefb3e73f11e3d1c4b1830",
                "md5": "084843eaa51bd435677823dfea7a2381",
                "sha256": "bfdde85dfb83b58ab4a8ab21992d854330cb5a8e715c2484de474662fda3fcd0"
            },
            "downloads": -1,
            "filename": "dns_client-0.2.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "084843eaa51bd435677823dfea7a2381",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11.7",
            "size": 14765,
            "upload_time": "2024-03-04T09:07:25",
            "upload_time_iso_8601": "2024-03-04T09:07:25.143165Z",
            "url": "https://files.pythonhosted.org/packages/f9/f6/d5dac34be3896bb5664bb0d87a76a499caa299fefb3e73f11e3d1c4b1830/dns_client-0.2.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8683476dcd70abb32c96a822bcdf5b1d05e3ab3bbcbfad06f4eb736b244d01d9",
                "md5": "402553f85e3008f87e3c19b068b4bd7d",
                "sha256": "8986b95d7c3a0f383fb51e401e34bf7706fb31d60ee24f3964e2bbfd1a736dd3"
            },
            "downloads": -1,
            "filename": "dns-client-0.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "402553f85e3008f87e3c19b068b4bd7d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11.7",
            "size": 14219,
            "upload_time": "2024-03-04T09:07:31",
            "upload_time_iso_8601": "2024-03-04T09:07:31.316818Z",
            "url": "https://files.pythonhosted.org/packages/86/83/476dcd70abb32c96a822bcdf5b1d05e3ab3bbcbfad06f4eb736b244d01d9/dns-client-0.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-04 09:07:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "s3rgeym",
    "github_project": "python-dns-client",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "dns-client"
}
        
Elapsed time: 0.40964s