{"id":15068987,"url":"https://github.com/thewaterfall/doh4j","last_synced_at":"2026-02-11T11:31:42.744Z","repository":{"id":248706695,"uuid":"829043280","full_name":"thewaterfall/doh4j","owner":"thewaterfall","description":"The Doh4j library is a powerful yet simple DNS Over HTTPS (DoH) client implementation for Java 11+, packaged neatly into a streamlined and powerful API. The Doh4j client uses Google, Cloudflare, and Quad9 DoH resolvers by default, but it also supports custom RFC 8484-compliant resolvers.","archived":false,"fork":false,"pushed_at":"2024-07-16T14:18:20.000Z","size":76,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-17T16:40:11.131Z","etag":null,"topics":["dns-lookup","dns-over-https","doh","java","java-11","java-dns","java-doh"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thewaterfall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-15T16:32:03.000Z","updated_at":"2024-07-18T21:18:01.000Z","dependencies_parsed_at":"2024-07-16T17:07:12.840Z","dependency_job_id":null,"html_url":"https://github.com/thewaterfall/doh4j","commit_stats":null,"previous_names":["thewaterfall/doh4j"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewaterfall%2Fdoh4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewaterfall%2Fdoh4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewaterfall%2Fdoh4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewaterfall%2Fdoh4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thewaterfall","download_url":"https://codeload.github.com/thewaterfall/doh4j/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243203888,"owners_count":20253367,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dns-lookup","dns-over-https","doh","java","java-11","java-dns","java-doh"],"created_at":"2024-09-25T01:39:57.487Z","updated_at":"2026-02-11T11:31:37.707Z","avatar_url":"https://github.com/thewaterfall.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Doh4j: DNS over HTTPS (DoH) for Java\n\n[![](https://jitpack.io/v/thewaterfall/doh4j.svg)](https://jitpack.io/#thewaterfall/doh4j)\n\nThe Doh4j library is a powerful yet simple DNS Over HTTPS (DoH) client implementation for **Java 11+**, packaged neatly into a streamlined and powerful API. The Doh4j client uses Google, Cloudflare, and Quad9 DoH resolvers by default, but it also supports custom RFC 8484-compliant resolvers.\n\n## Features\n\n- Perform DNS lookup over HTTPS: The Doh4jClient class provides a client for performing DNS over HTTPS (DoH) lookups using a list of resolvers.\n- Configurable Resolvers: By default, Google, Cloudflare, and Quad9 are used as resolvers. However, custom resolvers can be supplied.\n- Fallback Mechanism: If a DNS lookup fails with the first resolver, the client tries the next one until a resolver responds or no resolvers are left.\n- Synchronous and Asynchronous Operations: Supports both blocking synchronous and non-blocking asynchronous operations.\n- Utilizes Native Java HttpClient: Leverages the native HttpClient available from **Java 11** and onwards. This makes the library efficient and reliable, as it uses the well-maintained and high-performing HTTP API provided by Java itself\n\n## Installation\nThe Doh4j library can be easily installed using JitPack, see Gradle and Maven examples below.\n\n### Gradle\nAdd the following to your build.gradle file:\n\n```\nrepositories {\n    mavenCentral()\n    maven { url \"https://jitpack.io\" }\n}\n\ndependencies {\n    implementation 'com.github.thewaterfall:doh4j:1.0.0'\n}\n```\n\n### Maven\nAdd the following to your pom.xml file:\n\n```\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ejitpack.io\u003c/id\u003e\n        \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.github.thewaterfall\u003c/groupId\u003e\n        \u003cartifactId\u003edoh4j\u003c/artifactId\u003e\n        \u003cversion\u003e1.0.0\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n## Usage\n\nThe Doh4j client provides a simple and straightforward interface, making the process of DNS lookups easy. Below are examples of how you can carry out DNS lookups using predefined and custom resolvers.\n\n### Synchronous lookup with predefined resolvers\n\n```\nDoh4j.newClient()\n    .lookup(\"example.com\", Type.A);\n```\n\n### Synchronous lookup with custom resolvers\n\n```\nDoh4j.builder()\n    .resolver(\"https://resolve.com/resolve\")\n    .build()\n    .lookup(\"example.com\", Type.A);\n```\n\n\n### Synchronous lookup with custom HTTP client\n\nYou can also use a custom java.net HTTP client while performing DNS lookups. This feature can be useful in situations where there is a need for custom configuration for HTTP requests like timeouts, handlers, proxies, and more. Here's how you can perform a DNS lookup with a custom resolver and a custom HTTP client:\n\n```\nHttpClient client = HttpClient.newHttpClient();\n\nDoh4j.builder()\n    .client(client)\n    .resolver(\"https://resolve.com/resolve\")\n    .build()\n    .lookup(\"example.com\", Type.A);\n```\n\n### Asynchronous lookup\n\n```\nDo4J.newClient()\n    .lookupAsync(\"example.com\", Type.A)\n    .thenAccept(result -\u003e System.out.println(result.getStatus())); // Callback, called if no exception is thrown\n    \nDo4J.builder()\n    .resolver(\"https://resolver1.com/resolve\")\n    .resolver(\"https://resolver2.com/resolve\")\n    .build()\n    .lookupAsync(\"example.com\", Type.A)\n    .thenAccept(result -\u003e System.out.println(result.getStatus())); // Callback, called if no exception is thrown\n    \n// Exception handling    \nDo4J.newClient()\n    .lookupAsync(\"example.com\", Type.A)\n    .whenComplete((result, e) -\u003e {\n        if (e != null) {\n         // Handle exception\n        }\n    });\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthewaterfall%2Fdoh4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthewaterfall%2Fdoh4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthewaterfall%2Fdoh4j/lists"}