{"id":15374638,"url":"https://github.com/nktnet1/dns-lookup-sync","last_synced_at":"2026-01-02T18:06:54.441Z","repository":{"id":204289908,"uuid":"711531730","full_name":"nktnet1/dns-lookup-sync","owner":"nktnet1","description":"Synchronous version of dnsPromises.lookup","archived":false,"fork":false,"pushed_at":"2024-07-18T01:00:56.000Z","size":1074,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T08:19:19.463Z","etag":null,"topics":["dns","dns-lookup","dns-sync","domain","ipv4","ipv6","lookup","resolve","sync","synchronous"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/dns-lookup-sync","language":"TypeScript","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/nktnet1.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":"2023-10-29T14:58:45.000Z","updated_at":"2024-09-14T08:19:31.000Z","dependencies_parsed_at":"2023-11-25T13:25:04.410Z","dependency_job_id":"4447424c-38e3-4b62-bd25-6784f989e88a","html_url":"https://github.com/nktnet1/dns-lookup-sync","commit_stats":null,"previous_names":["nktnet1/dns-lookup-sync"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nktnet1%2Fdns-lookup-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nktnet1%2Fdns-lookup-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nktnet1%2Fdns-lookup-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nktnet1%2Fdns-lookup-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nktnet1","download_url":"https://codeload.github.com/nktnet1/dns-lookup-sync/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243847056,"owners_count":20357317,"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-lookup","dns-sync","domain","ipv4","ipv6","lookup","resolve","sync","synchronous"],"created_at":"2024-10-01T13:59:14.068Z","updated_at":"2026-01-02T18:06:54.378Z","avatar_url":"https://github.com/nktnet1.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# [![DNS Lookup Sync](logo.svg)](https://github.com/nktnet1/dns-lookup-sync)\n\n[![pipeline](https://github.com/nktnet1/dns-lookup-sync/actions/workflows/pipeline.yml/badge.svg)](https://github.com/nktnet1/dns-lookup-sync/actions/workflows/pipeline.yml)\n\u0026nbsp;\n[![codecov](https://codecov.io/gh/nktnet1/dns-lookup-sync/branch/main/graph/badge.svg?token=RAC7SKJTGU)](https://codecov.io/gh/nktnet1/dns-lookup-sync)\n\u0026nbsp;\n[![Maintainability](https://api.codeclimate.com/v1/badges/46c9b884916b726d91ed/maintainability)](https://codeclimate.com/github/nktnet1/dns-lookup-sync/maintainability)\n\u0026nbsp;\n[![Snyk Security](https://snyk.io/test/github/nktnet1/dns-lookup-sync/badge.svg)](https://snyk.io/test/github/nktnet1/dns-lookup-sync)\n\u0026nbsp;\n[![GitHub top language](https://img.shields.io/github/languages/top/nktnet1/dns-lookup-sync)](https://github.com/search?q=repo%3Anktnet1%2Fdns-lookup-sync++language%3ATypeScript\u0026type=code)\n\n[![NPM Version](https://img.shields.io/npm/v/dns-lookup-sync?logo=npm)](https://www.npmjs.com/package/dns-lookup-sync?activeTab=versions)\n\u0026nbsp;\n[![install size](https://packagephobia.com/badge?p=dns-lookup-sync)](https://packagephobia.com/result?p=dns-lookup-sync)\n\u0026nbsp;\n[![Depfu](https://badges.depfu.com/badges/8f864f96bde332adb2a53fb30c4832a6/overview.svg)](https://depfu.com/github/nktnet1/dns-lookup-sync?project_id=39390)\n\u0026nbsp;\n[![NPM License](https://img.shields.io/npm/l/dns-lookup-sync)](https://opensource.org/license/mit/)\n\u0026nbsp;\n[![GitHub issues](https://img.shields.io/github/issues/nktnet1/dns-lookup-sync.svg?style=social)](https://github.com/nktnet1/dns-lookup-sync/issues)\n\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=nktnet1_dns-lookup-sync\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=nktnet1_dns-lookup-sync)\n\u0026nbsp;\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/b56caf9395e743deaccd3a0a67d22819)](https://app.codacy.com/gh/nktnet1/dns-lookup-sync/dashboard?utm_source=gh\u0026utm_medium=referral\u0026utm_content=\u0026utm_campaign=Badge_grade)\n\u0026nbsp;\n[![DeepSource](https://app.deepsource.com/gh/nktnet1/dns-lookup-sync.svg/?label=active+issues\u0026show_trend=true\u0026token=_1JuBM2nzzo4t4DqFTdPMwwo)](https://app.deepsource.com/gh/nktnet1/dns-lookup-sync/)\n\u0026nbsp;\n[![codebeat badge](https://codebeat.co/badges/20b443c6-3784-4b63-99de-c69f0701a633)](https://codebeat.co/projects/github-com-nktnet1-dns-lookup-sync-main)\n\u0026nbsp;\n[![GitHub stars](https://img.shields.io/github/stars/nktnet1/dns-lookup-sync.svg?style=social)](https://github.com/nktnet1/dns-lookup-sync/stargazers)\n\n[![Downloads Total](https://badgen.net/npm/dt/dns-lookup-sync)](https://moiva.io/?npm=dns-lookup-sync)\n\u0026nbsp;\n[![Downloads Yearly](https://badgen.net/npm/dy/dns-lookup-sync)](https://moiva.io/?npm=dns-lookup-sync)\n\u0026nbsp;\n[![Downloads Monthly](https://badgen.net/npm/dm/dns-lookup-sync)](https://moiva.io/?npm=dns-lookup-sync)\n\u0026nbsp;\n[![Downloads Weekly](https://badgen.net/npm/dw/dns-lookup-sync)](https://moiva.io/?npm=dns-lookup-sync)\n\u0026nbsp;\n[![Downloads Daily](https://badgen.net/npm/dd/dns-lookup-sync)](https://moiva.io/?npm=dns-lookup-sync)\n\n---\n\nSynchronous version of [dnsPromises.lookup](https://nodejs.org/api/dns.html#dnspromiseslookuphostname-options)\n\n[![Try with Replit](https://replit.com/badge?caption=Try%20with%20Replit)](https://replit.com/@nktnet1/dns-lookup-sync-example#index.js)\n\n\u003c/div\u003e\n\n---\n\n- [1. Installation](#1-installation)\n- [2. Usage](#2-usage)\n    - [2.1. hostname](#21-hostname)\n    - [2.2. options](#22-options)\n    - [2.3. return](#23-return)\n- [3. License](#3-license)\n- [4. Limitations](#4-limitations)\n- [5. Caveats](#5-caveats)\n\n## 1. Installation\n\n```\nnpm install dns-lookup-sync\n```\n\n## 2. Usage\n\nTry with [Replit](https://replit.com/@nktnet1/dns-lookup-sync-example#index.js).\n\nThe API is identical to [dnsPromises.lookup](https://nodejs.org/api/dns.html#dnspromiseslookuphostname-options), with the promise being unwrapped in the return type to achieve synchronicity.\n\n```\ndnsLookupSync(hostname, options);\n```\n\n\u003cdetails closed\u003e\n\u003csummary\u003eExamples (click to view)\u003c/summary\u003e\n\n\u003cbr/\u003e\n\nLooking up `'localhost'` with default options\n\n```javascript\nconst dnsLookupSync = require('dns-lookup-sync');\n\nconsole.log(dnsLookupSync('localhost'));\n\n// Sample output:\n// { address: '127.0.0.1', family: 4 }\n\n```\n\nLooking up a list of addresses from `'www.google.com'`\n\n```javascript\nconst dnsLookupSync = require('dns-lookup-sync');\n\nconsole.log(dnsLookupSync('www.google.com', { all: true }));\n\n// Sample output:\n// [\n//   { address: '172.217.167.100', family: 4 },\n//   { address: '2404:6800:4006:80b::2004', family: 6 }\n// ]\n```\n\n\n\u003c/details\u003e\n\n\u003cbr/\u003e\n\n### 2.1. hostname\n\nHostname string to look up. For example,\n- `'localhost'`\n- `'www.google.com'`\n\n### 2.2. options\n\nIf an integer is passed, for example `4`, it is equivalent to passing the object `{ family: 4 }`.\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth\u003eOption\u003c/th\u003e\n    \u003cth\u003eDescription\u003c/th\u003e\n    \u003cth\u003eExample\u003c/th\u003e\n    \u003cth\u003eDefault\u003c/th\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\n    \u003ctd\u003efamily\u003cbr /\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/td\u003e\n    \u003ctd\u003e\n      The record family. Must be \u003ccode\u003e4\u003c/code\u003e, \u003ccode\u003e6\u003c/code\u003e, or \u003ccode\u003e0\u003c/code\u003e. The value \u003ccode\u003e0\u003c/code\u003e indicates that IPv4 and IPv6 addresses are both returned.\n    \u003c/td\u003e\n    \u003ctd\u003e\u003ccode\u003e4\u003c/code\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ccode\u003e0\u003c/code\u003e\u003c/td\u003e\n\n  \u003ctr\u003e\n    \u003ctd\u003ehints\u003cbr/\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/td\u003e\n    \u003ctd\u003eOne or more \u003ca href=\"https://nodejs.org/api/dns.html#supported-getaddrinfo-flags\"\u003esupported getaddrinfo flags\u003c/a\u003e. Multiple flags may be passed by bitwise ORing their values.\u003c/td\u003e\n    \u003ctd\u003e\n      \u003ccode\u003edns.ADDRCONFIG\u003c/code\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\u003ccode\u003eundefined\u003c/code\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\n    \u003ctd\u003eall\u003cbr/\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/td\u003e\n    \u003ctd\u003eWhen true, the \u003ccode\u003ednsLookupSync\u003c/code\u003e will return all addresses in an array. Otherwise, returns a single address\u003c/td\u003e\n    \u003ctd\u003e\n      \u003ccode\u003etrue\u003c/code\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\u003ccode\u003efalse\u003c/code\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\n    \u003ctd\u003everbatim\u003cbr/\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/td\u003e\n    \u003ctd\u003e\n      When true, the returns the IPv4 and IPv6 addresses in the order the DNS resolver returned them. When false, IPv4 addresses are placed before IPv6 addresses.\n    \u003c/td\u003e\n    \u003ctd\u003e\n      \u003ccode\u003etrue\u003c/code\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\u003ca href=\"https://nodejs.org/api/dns.html#dnspromiseslookuphostname-options\"\u003esee docs\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n### 2.3. return\n\nBy default, i.e.  `options.all === false`, a `LookupAddress` of the form\n```typescript\n{ address: string, family: number };\n```\n\nis returned. For example `localhost` may resolve to:\n```javascript\n{ address: '127.0.0.1', family: 4 }\n```\n\nOtherwise, an array of `LookupAddress` is returned. For example, [www.google.com](https://www.google.com) may resolve to:\n```javascript\n[\n  { address: '142.250.204.4', family: 4 },\n  { address: '2404:6800:4006:814::2004', family: 6 }\n]\n```\n\n\n## 3. License\n\n\u003cdetails closed\u003e\n\u003csummary\u003e\n  Massachusetts Institute of Technology\n  (\u003ca href=\"https://opensource.org/license/mit\" target=\"_blank\"\u003eMIT\u003c/a\u003e)\n\u003c/summary\u003e\n\n\u003cbr/\u003e\n\n```\nCopyright (c) 2023 Khiet Tam Nguyen\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the “Software”),\nto deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense,\nand/or sell copies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\nTHE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\nDEALINGS IN THE SOFTWARE.\n```\n\n\u003c/details\u003e\n\n## 4. Limitations\n\nThere are currently no known limitations.\n\n## 5. Caveats\n\nThis module was inspired by\n[dns-sync](https://github.com/skoranga/node-dns-sync), although focuses\nprimarily on providing the most up-to-date version of\n[dnsPromises.lookup](https://nodejs.org/api/dns.html#dnspromiseslookuphostname-options) in a synchronous manner.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnktnet1%2Fdns-lookup-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnktnet1%2Fdns-lookup-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnktnet1%2Fdns-lookup-sync/lists"}