-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add: expandShortcuts - add: bin/import - use async for parseZoneFile and expandShortcuts - SOA: capture comments
- Loading branch information
Showing
9 changed files
with
406 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
name: Module Tests | ||
name: Tests | ||
|
||
on: [ push ] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
|
||
on: [ pull_request ] | ||
|
||
name: Test Coverage | ||
name: Coverage | ||
|
||
jobs: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
#### 1.N.N - YYYY-MM-DD | ||
|
||
|
||
#### 0.2.0 - 2022-03-22 | ||
|
||
- add expandShortcuts | ||
- added bin/import | ||
- use async for parseZoneFile and expandShortcuts | ||
- SOA: capture comments | ||
|
||
|
||
#### 0.1.0 - 2022-03-17 | ||
|
||
- Bind zonefile parser, using nearley: #1 | ||
|
||
- stab #1: parses cadillac.net | ||
- test #2: add isi.edu zone | ||
- allow comments after SOA closing parens | ||
- DRY the grammar -> object functions | ||
- add \r to eol, for windows | ||
- local copy of builtin-whitespace, adds \r char | ||
- ci: remove windows support, times out, I think upstream nearley issue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!node | ||
|
||
const fs = require('fs') | ||
const path = require('path') | ||
const os = require('os') | ||
|
||
const dz = require('../index') | ||
|
||
const filePath = process.argv[2] | ||
if (!filePath) usage() | ||
|
||
function usage () { | ||
console.log(`\n ${process.argv[1]} file\n`) | ||
process.exit(1) | ||
} | ||
|
||
console.log(`reading file ${filePath}`) | ||
|
||
fs.readFile(filePath, (err, buf) => { | ||
if (err) throw err | ||
|
||
const base = path.basename(filePath) | ||
const asString = fileAsString(buf, base) | ||
|
||
dz.parseZoneFile(asString) | ||
.then(dz.expandShortcuts) | ||
.then(zoneArray => { | ||
// console.log(zoneArray) | ||
switch (process.argv[3]) { | ||
case 'toBind': | ||
toBind(zoneArray, base) | ||
break | ||
case 'toTinydns': | ||
toTinydns(zoneArray) | ||
break | ||
default: | ||
console.log(zoneArray) | ||
} | ||
}) | ||
.catch(e => { | ||
console.error(e.message) | ||
}) | ||
}) | ||
|
||
function fileAsString (buf, base) { | ||
let str = buf.toString() | ||
|
||
if (!/^\$ORIGIN/m.test(str)) { | ||
console.log(`inserting $ORIGIN ${base}`) | ||
str = `$ORIGIN ${base}.${os.EOL}${str}` | ||
} | ||
// console.log(str) | ||
return str | ||
} | ||
|
||
function toBind (zoneArray, origin) { | ||
for (const rr of zoneArray) { | ||
let out = rr.toBind() | ||
const reduceRE = new RegExp(`^([^\\s]+).${origin}.`) | ||
out = out.replace(reduceRE, '$1') | ||
process.stdout.write(out) | ||
} | ||
} | ||
|
||
function toTinydns (zoneArray) { | ||
for (const rr of zoneArray) { | ||
process.stdout.write(rr.toTinydns()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.