{"id":42870126,"url":"https://github.com/swift-dns/swift-dns","last_synced_at":"2026-01-30T12:58:09.801Z","repository":{"id":297986408,"uuid":"998389183","full_name":"swift-dns/swift-dns","owner":"swift-dns","description":"A high-performance Swift DNS library built on top of SwiftNIO; aiming to provide DNS client, resolver and server implementations.","archived":false,"fork":false,"pushed_at":"2025-12-25T10:54:24.000Z","size":6240,"stargazers_count":20,"open_issues_count":4,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-12-26T23:21:29.061Z","etag":null,"topics":["client","dns","server","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swift-dns.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2025-06-08T14:06:48.000Z","updated_at":"2025-12-25T12:34:18.000Z","dependencies_parsed_at":"2025-06-29T22:22:00.905Z","dependency_job_id":"a67d2599-48a4-4b99-860c-1bafce20a52d","html_url":"https://github.com/swift-dns/swift-dns","commit_stats":null,"previous_names":["mahdibm/swift-dns","swift-dns/swift-dns"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/swift-dns/swift-dns","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-dns%2Fswift-dns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-dns%2Fswift-dns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-dns%2Fswift-dns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-dns%2Fswift-dns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swift-dns","download_url":"https://codeload.github.com/swift-dns/swift-dns/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-dns%2Fswift-dns/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28913164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T12:13:43.263Z","status":"ssl_error","status_checked_at":"2026-01-30T12:13:22.389Z","response_time":66,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["client","dns","server","swift"],"created_at":"2026-01-30T12:58:09.080Z","updated_at":"2026-01-30T12:58:09.792Z","avatar_url":"https://github.com/swift-dns.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp\u003e\n    \u003ca href=\"https://github.com/MahdiBM/swift-dns/actions/workflows/unit-tests.yml\"\u003e\n        \u003cimg\n            src=\"https://img.shields.io/github/actions/workflow/status/MahdiBM/swift-dns/unit-tests.yml?event=push\u0026style=plastic\u0026logo=github\u0026label=unit-tests\u0026logoColor=%23ccc\"\n            alt=\"Unit Tests CI\"\n        \u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/MahdiBM/swift-dns/actions/workflows/integration-tests.yml\"\u003e\n        \u003cimg\n            src=\"https://img.shields.io/github/actions/workflow/status/MahdiBM/swift-dns/integration-tests.yml?event=push\u0026style=plastic\u0026logo=github\u0026label=integration-tests\u0026logoColor=%23ccc\"\n            alt=\"Integration Tests CI\"\n        \u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/MahdiBM/swift-dns/actions/workflows/benchmarks.yml\"\u003e\n        \u003cimg\n            src=\"https://img.shields.io/github/actions/workflow/status/MahdiBM/swift-dns/benchmarks.yml?event=push\u0026style=plastic\u0026logo=github\u0026label=benchmarks\u0026logoColor=%23ccc\"\n            alt=\"Benchamrks CI\"\n        \u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://swift.org\"\u003e\n        \u003cimg\n            src=\"https://design.vapor.codes/images/swift623up.svg\"\n            alt=\"Swift 6.2.3+\"\n        \u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n# swift-dns\n\nA high-performance Swift DNS library built on top of SwiftNIO; aiming to provide DNS client, resolver and server implementations.\n\n## Usage\n\nInitialize a `ForwardingDNSResolver`, then use the `query` methods:\n\n```swift\nimport DNSClient\nimport DNSModels\n\n/// Create a `ForwardingDNSResolver`\nlet resolver = try ForwardingDNSResolver(\n    transport: .default(\n        serverAddress: .domain(\n            /// Connect to Cloudflare's DNS primary server @ 1.1.1.1\n            domainName: DomainName(ipv4: IPv4Address(1, 1, 1, 1)),\n            port: 53\n        )\n    )\n)\n\ntry await withThrowingTaskGroup(of: Void.self) { taskGroup in\n    /// Use `addImmediateTask` instead of `addTask` on macOS 26 or Linux.\n    taskGroup.addTask {\n        try await resolver.run()/// !important\n    }\n\n    /// You can use the resolver while the `resolver.run()` method is not cancelled.\n\n    /// Send the query\n    /// `response` will be of type `Message`\n    let response = try await resolver.queryA(\n        message: .forQuery(domainName: \"mahdibm.com\")\n    )\n\n    /// Read the answers\n    for answer in response.answers {\n        /// `a` will be of type `A`\n        let a = answer.rdata\n        /// `ipv4` will be of type `IPv4Address`\n        let ipv4 = a.value\n        print(\n            \"Got ipv4 \\(ipv4) for domain \\(response.queries.first?.domainName.description ?? \"n/a\")\"\n        )\n    }\n\n    /// To shutdown the resolver, cancel its run method, by cancelling the taskGroup.\n    taskGroup.cancelAll()\n}\n```\n\nYou can use different transports if you so desire.\nThe `default` transport is `preferUDPOrUseTCP` similar to other DNS resolvers and resolvers.\nCurrently a TCP-only transport is also supported:\n\n```swift\n/// Create a `ForwardingDNSResolver` with the TCP transport\nlet resolver = try ForwardingDNSResolver(\n    transport: .tcp(\n        serverAddress: .domain(\n            domainName: DomainName(ipv4: IPv4Address(1, 1, 1, 1)),\n            port: 53\n        )\n    )\n)\n```\n\n## Operators\n\nI'm experimenting with using operators that do checks in debug builds, but are unchecked in optimized builds.\n\nThese operators always have 2 of the last character of the normal operator, and they should in theory always result in the same value as their stdlib version.\n\nSome examples of these operators are:\n\n- `\u0026+` -\u003e `\u0026++`\n- `\u0026+=` -\u003e `\u0026+==`\n- `\u0026\u003e\u003e` -\u003e `\u0026\u003e\u003e\u003e`\n\n## Checklist\n\n- [x] DNS Parsing\n  - [x] IDNA support for non-ASCII domain names.\n- [x] DNS client\n  - [x] DNS over UDP\n  - [x] DNS over TCP\n  - [ ] DoT (DNS Over TLS)\n  - [ ] DoH (DNS Over HTTPS)\n  - [ ] DoQ (DNS Over Quic)\n  - [ ] MDNS\n- [x] DNS resolver\n  - [x] ForwardingDNSResolver: A DNS client but with caching.\n  - [ ] \\_RecursiveDNSResolver: Implementation is in progress\n- [ ] DNS server\n- [ ] DNSSEC\n\n## Credits\n\n- https://github.com/apple/swift-nio\n  - The networking library used to implement this library.\n- https://github.com/hickory-dns/hickory-dns\n  - Some data type / parsing implementations were heavily inspired by hickory-dns.\n- https://github.com/valkey-io/valkey-swift\n  - Helped a lot in putting together an initial version of the connection handling.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswift-dns%2Fswift-dns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswift-dns%2Fswift-dns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswift-dns%2Fswift-dns/lists"}