{"id":51641651,"url":"https://github.com/dibakarghosh03/doh-proxy","last_synced_at":"2026-07-13T19:33:06.619Z","repository":{"id":363398083,"uuid":"1263187017","full_name":"dibakarghosh03/doh-proxy","owner":"dibakarghosh03","description":"DNS-over-HTTPS proxy in Go — forwards local UDP DNS queries to Cloudflare DoH over HTTPS with TTL-aware caching","archived":false,"fork":false,"pushed_at":"2026-06-08T17:59:24.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-08T19:25:09.461Z","etag":null,"topics":["dns","golang","http","proxy"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dibakarghosh03.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-08T17:53:49.000Z","updated_at":"2026-06-08T18:00:16.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/dibakarghosh03/doh-proxy","commit_stats":null,"previous_names":["dibakarghosh03/doh-proxy"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/dibakarghosh03/doh-proxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dibakarghosh03%2Fdoh-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dibakarghosh03%2Fdoh-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dibakarghosh03%2Fdoh-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dibakarghosh03%2Fdoh-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dibakarghosh03","download_url":"https://codeload.github.com/dibakarghosh03/doh-proxy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dibakarghosh03%2Fdoh-proxy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35434586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-13T02:00:06.543Z","response_time":119,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","golang","http","proxy"],"created_at":"2026-07-13T19:33:06.005Z","updated_at":"2026-07-13T19:33:06.612Z","avatar_url":"https://github.com/dibakarghosh03.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# doh-proxy\n\nA lightweight DNS-over-HTTPS (DoH) proxy written in Go from scratch.\n\nListens for plain DNS queries over UDP on localhost, forwards them to an upstream DoH resolver (Cloudflare `1.1.1.1`) over HTTPS, caches responses using each answer's TTL, and returns the result to the caller.\n\n---\n\n## How it works\n\n```\nYour OS / App\n     │\n     │  UDP DNS query (port 5353)\n     ▼\ndoh-proxy (localhost)\n     │\n     ├── cache hit?  ──yes──▶  return cached response (0ms)\n     │\n     no\n     │\n     │  HTTPS POST (application/dns-message)\n     ▼\nCloudflare DoH (cloudflare-dns.com)\n     │\n     ▼\ndoh-proxy caches response with TTL\n     │\n     ▼\nYour OS / App gets the answer\n```\n\n---\n\n## Features\n\n- **DNS wire format parser** — parses headers, questions, and answer records including compression pointers\n- **UDP listener** — handles concurrent queries, one goroutine per request\n- **DoH forwarding** — forwards raw DNS wire format over HTTPS to Cloudflare\n- **TTL-aware cache** — caches responses and expires them based on the minimum TTL across all answer records\n- **Background cache cleanup** — periodic sweep evicts stale entries from memory\n- **ID patching** — correctly rewrites response IDs to match each client's query\n\n---\n\n## Project structure\n\n```\ndoh-proxy/\n├── main.go        — entry point\n├── dns.go         — DNS wire format parser and structs\n├── listener.go    — UDP listener and query handler\n├── resolver.go    — DoH forwarding to upstream resolver\n├── cache.go       — TTL-aware in-memory cache\n└── go.mod\n```\n\n---\n\n## Getting started\n\n### Prerequisites\n\n- Go 1.20 or higher\n\n### Run\n\n```bash\ngit clone https://github.com/dibakarghosh03/doh-proxy\ncd doh-proxy\ngo run .\n```\n\nThe proxy listens on `127.0.0.1:5353` by default.\n\n### Test\n\n```bash\ndig @127.0.0.1 -p 5353 google.com\ndig @127.0.0.1 -p 5353 github.com\n```\n\nRun the same query twice — the second should return in `0ms` from cache.\n\n---\n\n## Use as system DNS resolver (Linux)\n\n**1. Build the binary and grant port 53 access:**\n\n```bash\ngo build -o doh-proxy .\nsudo setcap cap_net_bind_service=+ep ./doh-proxy\n```\n\n**2. Change the listen address in `main.go`:**\n\n```go\nlog.Fatal(startUDPListener(\"127.0.0.1:53\"))\n```\n\n**3. Disable systemd-resolved (Ubuntu):**\n\n```bash\nsudo systemctl stop systemd-resolved\nsudo systemctl disable systemd-resolved\n```\n\n**4. Point your system at the proxy:**\n\n```bash\n# /etc/resolv.conf\nnameserver 127.0.0.1\n```\n\nEvery DNS lookup on your machine now goes through doh-proxy.\n\n**To revert:**\n\n```bash\nsudo systemctl enable systemd-resolved\nsudo systemctl start systemd-resolved\n# restore /etc/resolv.conf to: nameserver 127.0.0.53\n```\n\n---\n\n## Configuration\n\nCurrently configured via constants in source. Defaults:\n\n| Setting | Value |\n|---|---|\n| Listen address | `127.0.0.1:5353` |\n| Upstream resolver | `https://cloudflare-dns.com/dns-query` |\n| Cache cleanup interval | `1 minute` |\n\n---\n\n## Possible extensions\n\n- [ ] Metrics — cache hit/miss rate, query counts per domain\n- [ ] Multiple upstream resolvers with fallback\n- [ ] Config file or CLI flags for listen address and upstream URL\n- [ ] NXDOMAIN caching\n- [ ] DNS over TCP support (for responses \u003e 512 bytes)\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdibakarghosh03%2Fdoh-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdibakarghosh03%2Fdoh-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdibakarghosh03%2Fdoh-proxy/lists"}