# libdns

> DNS library for server and proxy

Latest version **0.2.4** (published 2018-02-05) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install libdns
pnpm add libdns
yarn add libdns
bun add libdns
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.4 |
| Published | 2018-02-05 |
| First published | 2017-05-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | kaija |
| Maintainers | kaija |
| Keywords | DNS, proxy, server |

## Links

- npm: https://www.npmjs.com/package/libdns
- Repository: https://github.com/kaija/dns-express
- Homepage: https://github.com/kaija/dns-express#readme
- Issues: https://github.com/kaija/dns-express/issues
- npm.io page: https://npm.io/package/libdns

## Dependencies (4)

- [cares](https://npm.io/package/cares.md) ^1.1.8
- [mocha](https://npm.io/package/mocha.md) ^3.4.2
- [bunyan](https://npm.io/package/bunyan.md) ^1.8.10
- [ipaddr.js](https://npm.io/package/ipaddr.js.md) ^1.3.0

## Recent versions

- 0.2.4 (latest) — 2018-02-05
- 0.2.3 — 2018-02-05
- 0.2.2 — 2018-02-05
- 0.2.1 — 2017-06-04
- 0.2.0 — 2017-06-04
- 0.1.1 — 2017-06-02
- 0.1.0 — 2017-05-31

## README

# libdns
DNS library for server and proxy

This library is forked from https://github.com/trevoro/node-named

## Enhancement

* Support proxy mode with multiple nameserver upstream
* Support hook callback before and after query
* Example of DNS blacklist. https://www.projecthoneypot.org/httpbl.php

## Support Record Type

* A
* AAAA
* SOA
* MX
* TXT
* SRV


## How to use?

```sh
npm install --save libdns
```

### Create a multiple upstream DNS proxy

```javascript
var named = require('libdns');

var proxy = named.createProxy(['8.8.8.8', '168.95.1.1']);

proxy.listen(53, '127.0.0.1', function() {
    console.log("Listen DNS on port 53");
});

```


### Bump some domain

```javascript
var named = require('libdns');

function before_query(domain){
    console.log(domain);
    if (domain.endsWith('.apple.com')) {
        r={}
        r.answer = [{name: domain, class: 1, type:1, ttl:300, address:'1.1.1.1'}];
        return r;
    }else{
        return {};
    }
};

function after_query(response){
    console.log(response);
    response.answer = [ { name: response.question[0].name,
        class: 1,
        type: 1,
        ttl: 299,
        address: '8.8.8.8' }];
};

var proxy = named.createProxy(['8.8.8.8', '168.95.1.1'], {before: before_query, after: after_query});

proxy.listen(53, '127.0.0.1', function() {
    console.log("Listen DNS on port 53");
});
```

---
_Source: https://npm.io/package/libdns · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
