npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

fwdns

v1.1.3

Published

A DNS Forwarder

Readme

fwdns

A DNS Forwarder, with some interesting features.

QuickStart

$ npm i fwdns -g
$ fwdns -h

  Usage: fwdns [options]

  Options:

    -h, --help                                       output usage information
    -V, --version                                    output the version number
    -p, --port [6666]                                Port to bind
    -l, --listen [127.0.0.1]                         Address to listen
    -z, --zone [8.8.8.8]                             Default zone, use system by default
    -t, --timeout [5000]                             Timeout forwarding requests
    --renew-timeout [3600]                           Timeout of auto renewal
    -f, --forward-zone [/path/to/forward/zone.json]  Forward zone setting, {"hosts": ["8.8.8.8"], "names": ["google.com"]}
    -s, --local-zone [/path/to/local/zone.json]      Local zone setting, {"abc.com": "127.0.0.1"}

Features

Fast Zone Switching

It's a very rare edge case for using a DNS forwarder when there is over thousands of forward-zone settings. There is a fork of dnsmasq solving the similar problems, both dnsmasq and unbound's CPU reach 100% over 10K of zones.

With a pre-indexed map, we can archive less then 1ms for the query over 10K zones search, the algorithm is the same as this fork although in JavaScript, the implementation is much more easier. (but slower)

Here is some benchmark result compare to regular loop, (code):

EndsWithLoop#hit x 758 ops/sec ±1.93% (81 runs sampled)
RegExpLoop#hit x 90.88 ops/sec ±1.84% (66 runs sampled)
ReverseIndex#hit x 719,606 ops/sec ±1.02% (83 runs sampled)
EndsWithLoop#miss x 365 ops/sec ±1.26% (77 runs sampled)
RegExpLoop#miss x 114 ops/sec ±1.12% (69 runs sampled)
ReverseIndex#miss x 560,464 ops/sec ±0.91% (83 runs sampled)

Cache and Auto Renewal

All records that get from backends, will be cache in the memory and expire regards to the TTL, via node-cache.

Additionally, a auto renewal policy is added for better performance. When the item is added to the cache, the timer start to renew the result in the right time if possible, right time means 0.8 of TTL, and when the query is not being seen for an hour, give up the next renewal.

Race Query

Sometimes the backend zones can be busy or the network maybe unstable for a while, we can waste some network and CPU resources to duplicate the request to different servers, and take the first response, this can be easily archive by async's race function.

Performance

Might be slightly slower then others at the first time or both hit cache due to JavaScript's performance.

But I think with the auto renewal and race query, this maybe faster then others in the most daily usages, from client's aspect.

Dependencies's performance

The libraries this project depends to, are not being maintained for a while, there are some performance tweaks can be done.

For example, the packing processes of DNS packet in dnsd, gets improved to 3x faster due to commit:

- Original x 4,172 ops/sec ±1.49% (82 runs sampled)
+ indexOf & substring x 11,699 ops/sec ±1.06% (84 runs sampled)
+ Buffer.from x 11,663 ops/sec ±1.17% (81 runs sampled)
+ Body Buffer x 12,691 ops/sec ±1.11% (84 runs sampled)