{"id":38712595,"url":"https://github.com/tom-code/dnsfun","last_synced_at":"2026-01-17T11:00:50.878Z","repository":{"id":57213699,"uuid":"461617282","full_name":"tom-code/dnsfun","owner":"tom-code","description":"funny dns server in javascript","archived":false,"fork":false,"pushed_at":"2022-02-27T15:26:02.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-09T04:44:37.635Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/tom-code.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}},"created_at":"2022-02-20T21:09:04.000Z","updated_at":"2022-03-03T03:23:31.000Z","dependencies_parsed_at":"2022-08-29T02:10:31.758Z","dependency_job_id":null,"html_url":"https://github.com/tom-code/dnsfun","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tom-code/dnsfun","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tom-code%2Fdnsfun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tom-code%2Fdnsfun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tom-code%2Fdnsfun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tom-code%2Fdnsfun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tom-code","download_url":"https://codeload.github.com/tom-code/dnsfun/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tom-code%2Fdnsfun/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28506593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T10:25:30.148Z","status":"ssl_error","status_checked_at":"2026-01-17T10:25:29.718Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":[],"created_at":"2026-01-17T11:00:35.574Z","updated_at":"2026-01-17T11:00:50.760Z","avatar_url":"https://github.com/tom-code.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dnsfun\nsmall embeddable dns server\n\n## install library\nnpm install dnsfun\n\n## minimal example - responding loopback to A and AAAA queries\n```javascript\ndns = require('dnsfun')\n\nvar server = dns.Create();\n\nserver.on_message((request) =\u003e {\n\n    console.log(request);\n\n    var response = request.createResponse();\n\n    // respond with not implemented to opcode different than query\n    if (request.flagsDecoded.opcode != dns.OPCODE.QUERY) {\n        response.flags = {\n                           response: true,\n                           opcode: request.flagsDecoded.opcode,\n                           replyCode: dns.RCODE.NOTIMPL\n                         };\n        server.send(resp);\n        return;\n    }\n\n    // respond with loopback to all A and AAAA queries\n    for (const query of request.queries) {\n        if ((query.type == dns.TYPE.A) \u0026\u0026 (query.class == dns.CLASS.IN)) {\n            response.answers.push({\n                                    name: query.name,\n                                    type: dns.TYPE.A,\n                                    class: dns.CLASS.IN,\n                                    ttl: 3600,\n                                    data: [127, 0, 0, 1]\n                                  });\n        }\n\n        if ((query.type == dns.TYPE.AAAA) \u0026\u0026 (query.class == dns.CLASS.IN)) {\n            response.answers.push({\n                                    name: query.name,\n                                    type: dns.TYPE.AAAA,\n                                    class: dns.CLASS.IN,\n                                    ttl: 3600,\n                                    data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n                                  });\n        }\n    }\n\n    if (response.answers.length \u003e 0) {\n        response.flags.replyCode = dns.RCODE.NOERROR;\n        authoritativeAnswer = true;\n    } else {\n        response.flags.replyCode = dns.RCODE.NAMEERROR;\n    }\n\n    console.log(response);\n    server.send(response);\n});\n\nserver.bind('udp6', port=53, block=true);\n```\n\n\n\n\n\n## example - demonstrating different RRs\n```javascript\ndns = require('dnsfun')\n\nvar server = dns.Create();\nserver.on_message((request) =\u003e {\n    console.log(request);\n    var response = request.createResponse();\n    if (request.flagsDecoded.opcode != dns.OPCODE.QUERY) {\n        response.flags = {response: true, opcode: request.flagsDecoded.opcode, replyCode: dns.RCODE.NOTIMPL};\n        server.send(resp);\n        return;\n    }\n\n    response.answers = [];\n    // respond with 127.0.0.1 to all A queries\n    for (const query of request.queries) {\n        if ((query.type == dns.TYPE.A) \u0026\u0026 (query.class == dns.CLASS.IN)) {\n            response.answers.push({name: query.name, type: dns.TYPE.A, class: dns.CLASS.IN, ttl: 3600, data: [127, 0, 0, 1]});\n        }\n    }\n\n    // add aaaa record\n    response.answers.push({name: \"v6.fun\", type: dns.TYPE.AAAA, class: dns.CLASS.IN, ttl: 3600, data: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]});\n\n    // add some srv record to response\n    const srv = {priority: 1, weight: 3, port: 1212, target: \"x.y.z\"}\n    response.answers.push({name: \"_svc._proto.name\", type: dns.TYPE.SRV, class: dns.CLASS.IN, ttl: 3600, data: srv});\n\n    // cname\n    response.answers.push({name: \"abc\", type: dns.TYPE.CNAME, class: dns.CLASS.IN, ttl: 3600, data: dns.encodeName(\"x.e.z\")});\n\n    // cname2\n    response.answers.push({name: \"bbb\", type: dns.TYPE.CNAME, class: dns.CLASS.IN, ttl: 3600, data: {cname: 'o.i.tt'}});\n\n    // NS\n    response.answers.push({name: \"ccc\", type: dns.TYPE.NS, class: dns.CLASS.IN, ttl: 3600, data: dns.encodeName(\"x.e.o\")});\n\n    // MX\n    response.answers.push({name: \"ddd\", type: dns.TYPE.MX, class: dns.CLASS.IN, ttl: 3600, data: {preference: 1, exchange: \"a.a.a\"}});\n\n    // SOA\n    const soa = {mname: \"a1.a2\", rname: \"a1.a3\", serial: 100, refresh: 101, retry: 102, expire: 103, minimum: 104};\n    response.answers.push({name: \"ccc\", type: dns.TYPE.SOA, class: dns.CLASS.IN, ttl: 3600, data: soa});\n\n    // add a record into additional section\n    response.additional.push({name: \"a1.fun\", type: dns.TYPE.A, class: dns.CLASS.IN, ttl: 3600, data: [1, 2, 3, 4]});\n\n    response.flags = {response: true, opcode: dns.OPCODE.QUERY, replyCode: dns.RCODE.NOERROR, authoritativeAnswer: true};\n\n    console.log(response);\n    server.send(response);\n});\n\nserver.bind('udp6', port=53, block=true);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftom-code%2Fdnsfun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftom-code%2Fdnsfun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftom-code%2Fdnsfun/lists"}