Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong parsing result for TXT records containing semicolons #34

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
cfba4d6
stringify the JSON output so we can parse it back
jcnelson Mar 9, 2016
ac40453
Add support for URI records
jcnelson Mar 9, 2016
a81f03a
Merge pull request #1 from jcnelson/master
shea256 Mar 9, 2016
33a8712
upgrade testing system and fix bugs
shea256 Apr 16, 2016
607f50f
Merge branch 'master' of github.com:blockstack/dns-zonefile
shea256 Apr 16, 2016
b101c49
fix error in unit tests
shea256 Apr 16, 2016
f5ae708
update readme
shea256 Apr 17, 2016
0183118
replace let with var to pass tests
shea256 Apr 17, 2016
9095eef
add in es6 support
shea256 Apr 17, 2016
86d95ed
update package.json; update library npm name
shea256 Apr 17, 2016
624a920
update package name to zone-file
shea256 Apr 17, 2016
e9a00c3
add in npm shields
shea256 Apr 17, 2016
7fee2b7
reorganize repo and rename it to blockstack-zones
shea256 Apr 18, 2016
872b404
update readme
shea256 Apr 18, 2016
55f0875
update readme title
shea256 Apr 18, 2016
cb10343
expand on unit tests
shea256 Apr 18, 2016
93840b6
update license
shea256 Apr 18, 2016
e46f47c
update readme
shea256 Apr 18, 2016
6ca1aa1
fix exporting
shea256 Apr 18, 2016
92997b3
remove lib folder from git history
shea256 Apr 18, 2016
647031a
Update README.md
shea256 Apr 19, 2016
07ca299
upgrade zone-file library
shea256 Feb 22, 2017
8ae4474
update package.json
shea256 Feb 23, 2017
6b86b5e
add an .npmignore; update package.json
shea256 Feb 23, 2017
72dc991
Update README.md
shea256 Feb 23, 2017
ecd4864
add support and tests for txt records with multiple strings --- requi…
kantai Jan 29, 2018
3a1b68c
fix string joining logic in + type testing
kantai Jan 31, 2018
8b90584
bump version, add unit tests related to the zonefiles generated by va…
kantai Feb 1, 2018
5765688
switch babel preset from deprecated es2015 to env
kantai Feb 1, 2018
23d9933
use a const declaration
kantai Feb 2, 2018
75a839f
Merge pull request #2 from blockstack/feature/multi-string-txts
kantai Feb 2, 2018
78e3111
first pass at replace for-in with for-of
kantai Jan 3, 2019
149d1ab
add babel, flow configs
kantai Jan 3, 2019
5a33a15
rename es6 to js
kantai Jan 3, 2019
c84d449
pass flow tests in makeZoneFile
kantai Jan 3, 2019
ee2e67a
add eslint
kantai Jan 4, 2019
5637c32
flow everywhere
kantai Jan 4, 2019
43ff36b
add circleci
kantai Jan 4, 2019
8c49321
bump to full version
kantai Jan 4, 2019
9f39b12
add unit tests for (1) how makeZoneFile is used in blockstack.js (2) …
kantai Jan 5, 2019
22cfd69
Merge pull request #5 from blockstack/feature/refactor
kantai Jan 6, 2019
58b0ffa
chore: file renames from js to ts
zone117x Jan 29, 2021
4d36bd5
fix: flow to typescript syntax
zone117x Jan 29, 2021
0e0d5e1
fix: unit tests from tape to jest
zone117x Jan 29, 2021
8a6e897
feat: move test file to correct dir
zone117x Jan 29, 2021
0b02445
fix: replaced various tooling with tsdx
zone117x Jan 29, 2021
1a91722
fix: lint fixes
zone117x Jan 29, 2021
8d8dcc8
fix: Windows line endings borked during git checkout
zone117x Jan 29, 2021
2d8de0f
chore: codecov upload
zone117x Jan 29, 2021
aeb80d9
fix: non-optionals and txt array normalization
zone117x Jan 29, 2021
431c4ed
chore: restore txt result to string or string array
zone117x Jan 29, 2021
55cdded
Merge pull request #6 from blockstack/refactor/typescript
zone117x Feb 1, 2021
6d0a138
build: make esm version
aulneau Apr 16, 2021
4e49bff
Merge pull request #7 from blockstack/build/esm
aulneau Apr 16, 2021
1cdb9e9
Removing the unnecessary $ from terminal commands.
Akirtovskis Jun 9, 2021
6276c48
Merge pull request #8 from Akirtovskis/patch-1
zone117x Jul 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI
on: [push]
jobs:
build:
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}

runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['10.x', '12.x', '14.x']
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf

- name: Checkout repo
uses: actions/checkout@v2

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1

- name: Lint
run: npm run lint

- name: Test
run: npm run test --ci --coverage

- name: Build
run: npm run build

- name: codecov
run: npm run codecovUpload
49 changes: 38 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,43 @@
# logs
# Logs
logs
*.log
npm-debug.log*

# Folder view configuration files
.DS_Store
Desktop.ini
# Runtime data
pids
*.pid
*.seed

# Thumbnail cache files
._*
Thumbs.db
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Files that might appear on external disks
.Spotlight-V100
.Trashes
# Coverage directory used by tools like istanbul
coverage

.idea
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
node_modules

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# Misc
unused

# Babel
lib
dist

# Webstorm
.idea
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Node.js: Debug TSDX Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/tsdx/dist/index.js",
"test",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}
]
}
4 changes: 3 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#License
# License

ISC License (ISC)

Copyright (c) 2014, Elgs Qian Chen
Copyright (c) 2016, Halfmoon Labs Inc.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
Expand Down
136 changes: 46 additions & 90 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,60 @@
dns-zonefile
============
An [RFC1035 compliant](http://www.ietf.org/rfc/rfc1035.txt) DNS zone file
parser and generator for Node.js and browser.
# Zone File JS

# Installation
[![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.svg)](https://www.npmjs.com/package/zone-file)
[![npm](https://img.shields.io/npm/v/zone-file.svg)](https://www.npmjs.com/package/zone-file)
[![npm](https://img.shields.io/npm/dm/zone-file.svg)](https://www.npmjs.com/package/zone-file)
[![Slack](http://chat.blockstack.org/badge.svg)](http://chat.blockstack.org/)

## Bower Install
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.

`bower install dns-zonefile --save`
### Installation

## Standalone
```bash
npm install zone-file
```

### Usage

`sudo npm install dns-zonefile -g`
#### Making Zone Files

## Module
```js
import { makeZoneFile } from 'zone-file'
let zoneFileText = makeZoneFile(zoneFileJson)
```

`npm install dns-zonefile`
#### Parsing Zone Files

```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" }
]
}

let zoneFile = new ZoneFile(zoneFileData)
let zoneFileString = zoneFile.toString()
let zoneFileJson = zoneFile.toJSON()
```

### Examples
### Background Info

#### Forward DNS Zone
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:

Expand Down Expand Up @@ -128,7 +153,7 @@ _xmpp-client._tcp IN SRV 10 0 5222 jabber
_xmpp-server._tcp IN SRV 10 0 5269 jabber
```

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

This JSON will produce a zone file for a reverse DNS zone (the `$ORIGIN`
keyword is recommended for reverse DNS zones):
Expand Down Expand Up @@ -185,72 +210,3 @@ $TTL 3600
1 IN PTR HOST1.MYDOMAIN.COM.
2 IN PTR HOST2.MYDOMAIN.COM.
```

## 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:

```
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:

```
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:

```javascript
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:

```javascript
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.
52 changes: 0 additions & 52 deletions bin/zonefile

This file was deleted.

20 changes: 0 additions & 20 deletions bower.json

This file was deleted.

Loading