{"id":17766659,"url":"https://github.com/floatdrop/dns-graceful-stack-switch","last_synced_at":"2025-03-15T13:30:53.275Z","repository":{"id":10141084,"uuid":"12215923","full_name":"floatdrop/dns-graceful-stack-switch","owner":"floatdrop","description":"Monkey patch DNS lookup method for node.js.","archived":false,"fork":false,"pushed_at":"2015-11-05T07:49:28.000Z","size":488,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-14T01:31:43.511Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/floatdrop.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}},"created_at":"2013-08-19T12:22:40.000Z","updated_at":"2022-04-12T02:29:52.000Z","dependencies_parsed_at":"2022-08-31T03:11:41.101Z","dependency_job_id":null,"html_url":"https://github.com/floatdrop/dns-graceful-stack-switch","commit_stats":null,"previous_names":["floatdrop/dns-gracefull-stack-switch"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fdns-graceful-stack-switch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fdns-graceful-stack-switch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fdns-graceful-stack-switch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fdns-graceful-stack-switch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floatdrop","download_url":"https://codeload.github.com/floatdrop/dns-graceful-stack-switch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243507761,"owners_count":20301888,"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":[],"created_at":"2024-10-26T20:34:02.043Z","updated_at":"2025-03-15T13:30:53.270Z","avatar_url":"https://github.com/floatdrop.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"dns-graceful-stack-switch \n========\n\n[![Build Status](https://travis-ci.org/floatdrop/dns-graceful-stack-switch.png?branch=master)](https://travis-ci.org/floatdrop/dns-graceful-stack-switch) [![NPM version](https://badge.fury.io/js/dns-graceful-stack-switch.png)](http://badge.fury.io/js/dns-graceful-stack-switch)\n\nMonkey patch DNS lookup method for node.js.\n\n### Why?\n\nIf you used node.js with disabled IPv4 - you got exception (ENETUNREACH) in most of network operations, but ```ping6 address``` working fine. \n\nTo fix this error with minimal amount of code (you still can use [```dns.resolve6```](http://nodejs.org/docs/v0.8.25/api/dns.html#dns_dns_resolve6_domain_callback) and get valid IPv6 addresses) - monkey patched lookup method was written.\n\n### How?\n\n```javascript\n// Monkey patch\nrequire('dns-graceful-stack-switch')(6);\n// Remove monkey patch\nrequire('dns-graceful-stack-switch')(null, true);\n```\n\nThis module returns ```function(defaultVersion, remove)```. \n\n * ```defaultVersion``` - IP stack version that will be used first to lookup address. If it fails - another will be used. Defaults to `process.env.NODE_DNS_GRACEFUL_STACK_SWITCH_DEFAULT` and after that to `4`.\n * ```remove``` - remove monkeypatch. Defaults to `false`.\n\nAfter executing dns.lookup will be loaded with ```require``` and ```lookup``` method will be replaced.\n\n\n### Node.JS way\n\nThis bug was \"[patched](https://github.com/joyent/node/commit/edd2fcccf022c7014b374674012283422faa1bed)\" in Node.js, but magic option in ```net.connect``` (which gives you ability to write right http.Agent) released only in Node.js 0.11.6.\n\n### To run the tests:\n\nUnix/Macintosh:\n\n    make test\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatdrop%2Fdns-graceful-stack-switch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloatdrop%2Fdns-graceful-stack-switch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatdrop%2Fdns-graceful-stack-switch/lists"}