Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zone-file

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zone-file - npm Package Compare versions

Comparing version 0.0.0 to 0.2.0

src/index.es6

11

package.json
{
"name": "zone-file",
"version": "0.0.0",
"version": "0.2.0",
"description": "A DNS zone file parser and generator",

@@ -8,3 +8,3 @@ "main": "lib/index",

"compile": "babel --presets es2015 src -d lib",
"test": "npm run compile; node lib/unitTests.js",
"test": "npm run compile; node lib/testing/unitTests.js",
"prepublish": "npm run compile"

@@ -14,3 +14,3 @@ },

"type": "git",
"url": "https://github.com/blockstack/dns-zone-file-js.git"
"url": "https://github.com/blockstack/zone-file-js.git"
},

@@ -25,6 +25,9 @@ "keywords": [

],
"author": "Halfmoon Labs Inc.",
"author": "Blockstack Inc.",
"license": "ISC",
"contributors": [
{
"name": "Ryan Shea"
},
{
"name": "Elgs Chen"

@@ -31,0 +34,0 @@ },

@@ -1,40 +0,59 @@

# DNS Zone File JS
# Zone File JS
[![CircleCI](https://img.shields.io/circleci/project/blockstack/dns-zone-file-js/master.svg)](https://circleci.com/gh/blockstack/dns-zone-file-js/tree/master)
[![Slack](http://slack.blockstack.org/badge.svg)](http://slack.blockstack.org/)
[![CircleCI](https://img.shields.io/circleci/project/blockstack/zone-file-js/master.svg)](https://circleci.com/gh/blockstack/zone-file-js/tree/master)
[![npm](https://img.shields.io/npm/l/zone-file-js.svg)](https://www.npmjs.com/package/zone-file)
[![npm](https://img.shields.io/npm/v/zone-file-js.svg)](https://www.npmjs.com/package/zone-file)
[![npm](https://img.shields.io/npm/dm/zone-file-js.svg)](https://www.npmjs.com/package/zone-file)
[![Slack](http://chat.blockstack.org/badge.svg)](http://chat.blockstack.org/)
An [RFC1035-compliant](http://www.ietf.org/rfc/rfc1035.txt) DNS zone file parser and generator for Node.js and the browser.
An [RFC1035-compliant](http://www.ietf.org/rfc/rfc1035.txt) DNS zone file parser and generator for Node.js and the browser. Based on the `dns-zonefile` library by Elgs Qian Chen.
### Installation
#### Bower Install
```bash
$ bower install dns-zonefile --save
$ npm install zone-file
```
#### Standalone
### Usage
```bash
$ sudo npm install dns-zonefile -g
#### Making Zone Files
```js
import { makeZoneFile } from 'zone-file'
let zoneFileText = makeZoneFile(zoneFileJson)
```
#### Module
#### Parsing Zone Files
```bash
$ npm install dns-zonefile
```js
import { parseZoneFile } from 'zone-file'
let zoneFileJson = parseZoneFile(zoneFileText)
```
### Usage
#### Zone File Objects
#### Zone Information
```js
import { ZoneFile } from 'zone-file'
_dns-zonefile_ accepts both zone data expressed as a JSON object or plain text
zone file. It supports `SOA`, `NS`, `A`, `AAAA`, `CNAME`, `MX`, `PTR`, `SRV` and `TXT` record types
as well as the `$ORIGIN` keyword (for zone-wide use only). Each record type
(and the `$ORIGIN` keyword) is optional, though _bind_ expects to find at least
an `SOA` record in a valid zone file.
let zoneFileData = {
"$origin": "MYDOMAIN.COM.",
"$ttl": 3600,
"a": [
{ "name": "@", "ip": "127.0.0.1" },
{ "name": "www", "ip": "127.0.0.1" }
]
}
#### Forward DNS Zone
let zoneFile = new ZoneFile(zoneFileData)
let zoneFileString = zoneFile.toString()
let zoneFileJson = zoneFile.toJSON()
```
### Background Info
This library accepts both zone data expressed as a JSON object or as a plain text zone file. It supports `SOA`, `NS`, `A`, `AAAA`, `CNAME`, `MX`, `PTR`, `SRV`, `TXT` and `URI` record types as well as the `$ORIGIN` keyword (for zone-wide use only). Each record type
(and the `$ORIGIN` keyword) is optional, although _bind_ expects to find at least an `SOA` record in a valid zone file.
#### Forward DNS Zone Files
The following JSON produces a zone file for a forward DNS zone:

@@ -137,3 +156,3 @@

#### Reverse DNS Zone
#### Reverse DNS Zone Files

@@ -195,71 +214,1 @@ This JSON will produce a zone file for a reverse DNS zone (the `$ORIGIN`

```
### Standalone Usage
To use _dns-zonefile_ to generate a zone file from JSON from the command line,
place the desired JSON data in a file (`zonefile_data.json` in this example)
and run the following command. Note that the resulting zone file will be
printed to the console; to save the zone file to disk (`my_zone.conf` in this
example), use redirection as in this example:
```bash
$ zonefile -g zonefile_data.json > my_zone.conf
```
To use _dns-zonefile_ to parse a zone file to JSON from the command line, place
the desired zone file data in a file (`zonefile_data.txt` in this example) and
run the following command. Note that the resulting JSON will be printed to the
console; to save the JSON to disk (`my_zone.json` in this example), use
redirection as in this example:
```bash
$ zonefile -p zonefile_data.txt > my_zone.json
```
If the `-g` and `-p` are omitted, `-g` will be assumed if the lower cased
filename contains `.json`, otherwise, `-p` will be assumed.
`zonefile -v` or `zonefile --version` will print the version information.
## Module Usage
_dns-zonefile_ can also be used as a module. Simply use `require()` to include
it, then invoke its `generate()` function as shown in the following example:
```js
var zonefile = require('dns-zonefile');
var options = require('./zonefile_forward.json');
var output = zonefile.generate(options);
console.log(output);
```
`options` can either be a parsed JSON object as shown above, or a regular
Javascript object containing the same required fields.
It is also possible to parse a zone file to JSON by invoking its `parse()`
function as shown in the following example:
```js
var zonefile = require('dns-zonefile');
var text = fs.readFileSync('./zonefile_forward.txt', 'utf8');
output = zonefile.parse(text);
console.log(output);
```
### License
ISC License (ISC)
Copyright (c) 2014, Elgs Qian Chen
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc