{"id":15647373,"url":"https://github.com/256dpi/newdns","last_synced_at":"2025-04-30T12:41:10.844Z","repository":{"id":57510041,"uuid":"200272891","full_name":"256dpi/newdns","owner":"256dpi","description":"A library for building custom DNS servers in Go.","archived":false,"fork":false,"pushed_at":"2024-04-09T07:43:59.000Z","size":106,"stargazers_count":50,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T16:11:55.404Z","etag":null,"topics":["dns","dns-server","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","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/256dpi.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}},"created_at":"2019-08-02T17:23:45.000Z","updated_at":"2025-03-28T17:15:08.000Z","dependencies_parsed_at":"2024-06-20T14:13:12.755Z","dependency_job_id":null,"html_url":"https://github.com/256dpi/newdns","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/256dpi%2Fnewdns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/256dpi%2Fnewdns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/256dpi%2Fnewdns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/256dpi%2Fnewdns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/256dpi","download_url":"https://codeload.github.com/256dpi/newdns/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251701963,"owners_count":21629925,"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","dns-server","go","golang"],"created_at":"2024-10-03T12:19:01.788Z","updated_at":"2025-04-30T12:41:10.826Z","avatar_url":"https://github.com/256dpi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# newdns\n\n[![Test](https://github.com/256dpi/newdns/actions/workflows/test.yml/badge.svg)](https://github.com/256dpi/newdns/actions/workflows/test.yml)\n[![GoDoc](https://godoc.org/github.com/256dpi/newdns?status.svg)](http://godoc.org/github.com/256dpi/newdns)\n[![Release](https://img.shields.io/github/release/256dpi/newdns.svg)](https://github.com/256dpi/newdns/releases)\n \n**A library for building custom DNS servers in Go.**\n\nThe newdns library wraps the widely used, but low-level [github.com/miekg/dns](https://github.com/miekg/dns) package with a simple interface to quickly build custom DNS servers. The implemented server only supports a subset of record types (A, AAAA, CNAME, MX, TXT) and is intended to be used as a leaf authoritative name server only. It supports UDP and TCP as transport protocols and implements EDNS0. Conformance is tested by issuing a corpus of tests against a zone in AWS Route53 and comparing the response and behavior.\n\nThe intention of this project is not to build a feature-complete alternative to \"managed zone\" offerings by major cloud platforms. However, some projects may require frequent synchronization of many records between a custom database and a cloud-hosted \"managed zone\". In this scenario, a custom DNS server that queries the own database might be a lot simpler to manage and operate. Also, the distributed nature of the DNS system offers interesting qualities that could be leveraged by future applications.\n\n## Example\n\n```go\n// create zone\nzone := \u0026newdns.Zone{\n    Name:             \"example.com.\",\n    MasterNameServer: \"ns1.hostmaster.com.\",\n    AllNameServers: []string{\n        \"ns1.hostmaster.com.\",\n        \"ns2.hostmaster.com.\",\n        \"ns3.hostmaster.com.\",\n    },\n    Handler: func(name string) ([]newdns.Set, error) {\n        // return apex records\n        if name == \"\" {\n            return []newdns.Set{\n                {\n                    Name: \"example.com.\",\n                    Type: newdns.A,\n                    Records: []newdns.Record{\n                        {Address: \"1.2.3.4\"},\n                    },\n                },\n                {\n                    Name: \"example.com.\",\n                    Type: newdns.AAAA,\n                    Records: []newdns.Record{\n                        {Address: \"1:2:3:4::\"},\n                    },\n                },\n            }, nil\n        }\n\n        // return sub records\n        if name == \"foo\" {\n            return []newdns.Set{\n                {\n                    Name: \"foo.example.com.\",\n                    Type: newdns.CNAME,\n                    Records: []newdns.Record{\n                        {Address: \"bar.example.com.\"},\n                    },\n                },\n            }, nil\n        }\n\n        return nil, nil\n    },\n}\n\n// create server\nserver := newdns.NewServer(newdns.Config{\n    Handler: func(name string) (*newdns.Zone, error) {\n        // check name\n        if newdns.InZone(\"example.com.\", name) {\n            return zone, nil\n        }\n\n        return nil, nil\n    },\n    Logger: func(e newdns.Event, msg *dns.Msg, err error, reason string) {\n        fmt.Println(e, err, reason)\n    },\n})\n\n// run server\ngo func() {\n    err := server.Run(\":1337\")\n    if err != nil {\n        panic(err)\n    }\n}()\n\n// print info\nfmt.Println(\"Query apex: dig example.com @0.0.0.0 -p 1337\")\nfmt.Println(\"Query other: dig foo.example.com @0.0.0.0 -p 1337\")\n\n// wait forever\nselect {}\n```\n\n## Credits\n\n- https://github.com/miekg/dns\n- https://github.com/coredns/coredns\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F256dpi%2Fnewdns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F256dpi%2Fnewdns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F256dpi%2Fnewdns/lists"}