8000 DNS Queries over HTTPS (DoH) support · Issue #122 · MiniDNS/minidns · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
DNS Queries over HTTPS (DoH) support #122
Open
@rekire

Description

@rekire

I played today a bit more with your library and build a DoH client (in Kotlin) on top.

class DohResult(query: DnsMessage, data: ByteArray?) :
    DnsQueryResult(QueryMethod.tcp, query, DnsMessage(data))

class DohResolver : DnsClient() {
    override fun query(queryBuilder: DnsMessage.Builder): DnsQueryResult {
        val q = queryBuilder.setId(0).build()
        val output = ByteArrayOutputStream()
        q.writeTo(output, false)

        val client = OkHttpClient()
        val query = Base64.encodeToString(output.toByteArray()).trimEnd('=')
        val request = Request.Builder()
            .url("https://dns.google/dns-query?dns=$query")
            .header("Content-Type", "application/dns-message")
            .build()

        val result = client.newCall(request).execute()
        return DohResult(q, result.body?.bytes())
    }
}

@Test
fun doh() {
    println(DohResolver().query(Question("github.com", Record.TYPE.MX)))
}

Are you interested in a PR? I would improve the code before. Just wondering if this could be interested for you at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0