Giter Club home page Giter Club logo

async-doh's Issues

AssertionError while querying TXT record

Hello, First of all, amazing work on the doh library!
I was trying to get the TXT record for example.com which errored out the ParseError.

Code:

import asyncio
from async_doh.client import DoHClient


async def async_query(domain):
    async with DoHClient() as client:
        return await client.query("https://1.1.1.1/dns-query", domain, "TXT")

result = asyncio.run(async_query("example.com"))
print(result)

Error Traceback:

Traceback (most recent call last):
  File "gen.py", line 10, in <module>
    result = asyncio.run(async_query("example.com"))
  File "/Users/scorpionk/.pyenv/versions/3.8.6/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Users/scorpionk/.pyenv/versions/3.8.6/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "gen.py", line 7, in async_query
    return await client.query("https://1.1.1.1/dns-query", domain, "TXT")
  File "/Users/scorpionk/.pyenv/versions/3.8.6/lib/python3.8/site-packages/async_doh/client.py", line 49, in query
    return await self.request_message(url, req, method)
  File "/Users/scorpionk/.pyenv/versions/3.8.6/lib/python3.8/site-packages/async_doh/client.py", line 41, in request_message
    result = DNSMessage.parse(data)
  File "/Users/scorpionk/.pyenv/versions/3.8.6/lib/python3.8/site-packages/async_dns/core/record.py", line 313, in parse
    l, ans.an = ans.parse_entry(RESPONSE, data, l, an)
  File "/Users/scorpionk/.pyenv/versions/3.8.6/lib/python3.8/site-packages/async_dns/core/record.py", line 294, in parse_entry
    l = r.parse(data, l)
  File "/Users/scorpionk/.pyenv/versions/3.8.6/lib/python3.8/site-packages/async_dns/core/record.py", line 196, in parse
    _, self.data = utils.load_message(data, l)
  File "/Users/scorpionk/.pyenv/versions/3.8.6/lib/python3.8/site-packages/async_dns/core/utils.py", line 39, in load_message
    assert cursor is not None, ParseError(data, offset)
AssertionError

If I do the curl of example.com TXT record using Cloudflare DNS then I get the following result.
Command:
curl -H 'accept: application/dns-json' 'https://cloudflare-dns.com/dns-query?name=example.com&type=TXT' | python -m json.tool

Output:

 {
    "Status": 0,
    "TC": false,
    "RD": true,
    "RA": true,
    "AD": true,
    "CD": false,
    "Question": [
        {
            "name": "example.com",
            "type": 16
        }
    ],
    "Answer": [
        {
            "name": "example.com",
            "type": 16,
            "TTL": 86400,
            "data": "\"v=spf1 -all\""
        },
        {
            "name": "example.com",
            "type": 16,
            "TTL": 86400,
            "data": "\"8j5nfqld20zpcyr8xjw0ydcfq9rk8hgm\""
        }
    ]
}

It would be great if this can be fixed.
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.