{"id":13725946,"url":"https://github.com/dantecatalfamo/zig-dns","last_synced_at":"2025-08-02T16:05:03.936Z","repository":{"id":62858218,"uuid":"559748602","full_name":"dantecatalfamo/zig-dns","owner":"dantecatalfamo","description":"Experimental DNS library implemented in zig","archived":false,"fork":false,"pushed_at":"2024-03-15T23:00:01.000Z","size":88,"stargazers_count":65,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-25T01:00:19.096Z","etag":null,"topics":["dns","dns-library","zig","zig-library"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/dantecatalfamo.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":"2022-10-31T02:21:03.000Z","updated_at":"2025-07-11T09:39:00.000Z","dependencies_parsed_at":"2023-01-22T08:03:01.072Z","dependency_job_id":"14fa6d99-4c9d-45d5-aff3-ab68c5c64202","html_url":"https://github.com/dantecatalfamo/zig-dns","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dantecatalfamo/zig-dns","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantecatalfamo%2Fzig-dns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantecatalfamo%2Fzig-dns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantecatalfamo%2Fzig-dns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantecatalfamo%2Fzig-dns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dantecatalfamo","download_url":"https://codeload.github.com/dantecatalfamo/zig-dns/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantecatalfamo%2Fzig-dns/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268415882,"owners_count":24246812,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"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","dns-library","zig","zig-library"],"created_at":"2024-08-03T01:02:42.404Z","updated_at":"2025-08-02T16:05:03.869Z","avatar_url":"https://github.com/dantecatalfamo.png","language":"Zig","funding_links":[],"categories":["Zig","Libraries"],"sub_categories":[],"readme":"# zig-dns\n\nExperimental DNS library implemented in zig.\n\nSo far implements [RFC 1035](https://www.rfc-editor.org/rfc/rfc1035.html) plus some updates.\n\nThe library itself has no dependencies, the CLI example uses [`zig-network`](https://github.com/MasterQ32/zig-network) to send and receive packets over the network.\n\n* Library: `src/dns.zig`\n* CLI test: `src/main.zig`\n\n### Features\n  * Streaming interface\n  * Parse DNS packets\n  * Generate DNS packets\n  * Print packet contents\n  * Label compression\n\n### Currently supported record types\n\n* A - A host address\n* NS - An authoritative name server\n* MD - A mail destination (Obsolete)\n* MF - A mail forwarder (Obsolete)\n* CNAME - The canonical name for an alias\n* SOA - Marks the start of a zone of authority\n* MB - A mailbox domain name (Experimental)\n* MG - A mail group member (Experimental)\n* MR - A mail rename domain name (Experimental)\n* NULL - A byte array (Experimental)\n* WKS - A well known service description\n* PTR - A domain name pointer\n* HINFO - Host information\n* MINFO - Mailbox or mail list information\n* MX - Mail exchange\n* TXT - Text strings\n* RP - Responsible Person [RFC 1183](https://www.rfc-editor.org/rfc/rfc1183)\n* AAAA - An IPv6 host address [RFC 3596](https://www.rfc-editor.org/rfc/rfc3596)\n* LOC - Location information [RFC 1876](https://datatracker.ietf.org/doc/html/rfc1876)\n* SRV - Service locator [RFC 2782](https://www.rfc-editor.org/rfc/rfc2782)\n* SSHFP - SSH Fingerprint [RFC 4255](https://www.rfc-editor.org/rfc/rfc4255), [RFC 6594](https://www.rfc-editor.org/rfc/rfc6594)\n* URI - Uniform Resource Identifier [RFC 7553](https://www.rfc-editor.org/rfc/rfc7553.html)\n  \n### Interactive\n\nFor testing and development purposes you can call the library interactively from the command line.\n\n```\nUsage: zig-dns \u003cdns-server\u003e \u003cdomain\u003e \u003cquery-type\u003e\n```\n\n### Interactive Example\n\n```\n$ zig-dns 1.1.1.1 www.lambda.cx A\nSending bytes: { 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 3, 119, 119, 119, 6, 108, 97, 109, 98, 100, 97, 2, 99, 120, 0, 0, 1, 0, 1 }\nQuery:\n Message {\n  Header {\n    ID: 1\n    Response: false\n    OpCode: query\n    Authoritative Answer: false\n    Truncation: false\n    Recursion Desired: true\n    Recursion Available: false\n    Z: 0\n    Response Code: no_error\n  }\n  Questions {\n    Question {\n      Name: www.lambda.cx.\n      QType: A\n      QClass: IN\n    }\n  }\n  Ansewrs {\n  }\n  Authorities {\n  }\n  Additional {\n  }\n}\nRecv: { 0, 1, 129, 128, 0, 1, 0, 2, 0, 0, 0, 0, 3, 119, 119, 119, 6, 108, 97, 109, 98, 100, 97, 2, 99, 120, 0, 0, 1, 0, 1, 192, 12, 0, 5, 0, 1, 0, 0, 7, 8, 0, 2, 192, 16, 192, 16, 0, 1, 0, 1, 0, 0, 7, 8, 0, 4, 155, 138, 137, 134 }\nResponse:\nMessage {\n  Header {\n    ID: 1\n    Response: true\n    OpCode: query\n    Authoritative Answer: false\n    Truncation: false\n    Recursion Desired: true\n    Recursion Available: true\n    Z: 0\n    Response Code: no_error\n  }\n  Questions {\n    Question {\n      Name: www.lambda.cx.\n      QType: A\n      QClass: IN\n    }\n  }\n  Ansewrs {\n    Resource Record {\n      Name: www.lambda.cx.\n      Type: CNAME\n      Class: IN\n      TTL: 1800\n      Resource Data Length: 2\n      Resource Data: lambda.cx.\n    }\n    Resource Record {\n      Name: lambda.cx.\n      Type: A\n      Class: IN\n      TTL: 1800\n      Resource Data Length: 4\n      Resource Data: 155.138.137.134\n    }\n  }\n  Authorities {\n  }\n  Additional {\n  }\n}\n```\n\n### Example Code\n\n```zig\nconst std = @import(\"std\");\nconst io = std.io;\nconst network = @import(\"network\");\nconst dns = @import(\"zig-dns/src/dns.zig\");\n\n// [...] Main function, allocator, etc.\n\ntry network.init();\ndefer network.deinit();\nconst sock = try network.connectToHost(allocator, \"8.8.8.8\", 53, .udp);\ndefer sock.close();\nconst writer = sock.writer();\n\nconst message = try dns.createQuery(allocator, \"lambda.cx\", .A);\ndefer message.deinit();\n\nvar message_bytes = try message.to_bytes();\ntry writer.writeAll(message_bytes);\n\nvar recv = [_]u8{0} ** 1024;\nconst recv_size = try sock.receive(\u0026recv);\n\nconst response = try dns.Message.from_bytes(allocator, recv[0..recv_size]);\ndefer response.deinit();\n\nstd.debug.print(\"Response:\\n{any}\\n\", .{ response });\n```\n\nOutput:\n\n```\nResponse:\nMessage {\n  Header {\n    ID: 1\n    Response: true\n    OpCode: query\n    Authoritative Answer: false\n    Truncation: false\n    Recursion Desired: true\n    Recursion Available: true\n    Z: 0\n    Response Code: no_error\n  }\n  Questions {\n    Question {\n      Name: www.lambda.cx.\n      QType: A\n      QClass: IN\n    }\n  }\n  Ansewrs {\n    Resource Record {\n      Name: www.lambda.cx.\n      Type: CNAME\n      Class: IN\n      TTL: 1800\n      Resource Data Length: 2\n      Resource Data: lambda.cx.\n    }\n    Resource Record {\n      Name: lambda.cx.\n      Type: A\n      Class: IN\n      TTL: 1800\n      Resource Data Length: 4\n      Resource Data: 155.138.137.134\n    }\n  }\n  Authorities {\n  }\n  Additional {\n  }\n}\n```\n\n### Iterative Example\nSee [iterative.zig](src/iterative.zig) as an example for how to use this library iteratively.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantecatalfamo%2Fzig-dns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdantecatalfamo%2Fzig-dns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantecatalfamo%2Fzig-dns/lists"}