@warren-bank/dns-server
Advanced tools
Comparing version 1.0.0 to 2.0.0
@@ -20,6 +20,12 @@ const help = ` | ||
"-h" <filepath> | ||
"--hosts-file" <filepath> | ||
Specify path to input 'hosts' JSON file. | ||
[required] | ||
"-H" <host [=] IP> | ||
"--host" <host [=] IP> | ||
Specify a single 'hosts' key/value pair. | ||
[option can be used more than once] | ||
"-p" <number> | ||
"--port" <number> | ||
@@ -29,3 +35,4 @@ Specify port number for DNS server. | ||
"--fallback-server" <IP[:port]> | ||
"-f" <IP> | ||
"--fallback-server" <IP> | ||
Specify fallback DNS server | ||
@@ -32,0 +39,0 @@ to resolve hostnames not found in "--hosts-file". |
@@ -9,2 +9,3 @@ const process_argv = require('@warren-bank/node-process-argv') | ||
"--hosts-file": {file: "json"}, | ||
"--host": {many: true}, | ||
"--port": {num: "int"}, | ||
@@ -18,5 +19,6 @@ "--fallback-server": {} | ||
"--hosts-file": ["-h", "--hosts", "--file", "-j", "--json"], | ||
"--hosts-file": ["-h"], | ||
"--host": ["-H"], | ||
"--port": ["-p"], | ||
"--fallback-server": ["-f", "-s"] | ||
"--fallback-server": ["-f"] | ||
} | ||
@@ -46,2 +48,18 @@ | ||
if (Array.isArray(argv_vals["--host"]) && argv_vals["--host"].length){ | ||
const split_token = /[\s:=]+/ | ||
for (let host of argv_vals["--host"]) { | ||
const tokens = host.split(split_token).filter(t => !!t) | ||
if (tokens.length === 2) { | ||
if (!argv_vals["--hosts-file"]){ | ||
argv_vals["--hosts-file"] = {} | ||
} | ||
argv_vals["--hosts-file"][tokens[0]] = tokens[1] | ||
} | ||
} | ||
} | ||
if (!argv_vals["--hosts-file"]){ | ||
@@ -48,0 +66,0 @@ console.log("ERROR: 'hosts.json' file is required.") |
{ | ||
"name": "@warren-bank/dns-server", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"main": "lib/process_cli.js", | ||
@@ -5,0 +5,0 @@ "description": "A tiny DNS server. Supports a 'hosts' JSON data file. Supports a fallback DNS server.", |
@@ -32,6 +32,12 @@ ### [`dns-server`](https://github.com/warren-bank/node-dns-server) | ||
"-h" <filepath> | ||
"--hosts-file" <filepath> | ||
Specify path to input 'hosts' JSON file. | ||
[required] | ||
"-H" <host [=] IP> | ||
"--host" <host [=] IP> | ||
Specify a single 'hosts' key/value pair. | ||
[option can be used more than once] | ||
"-p" <number> | ||
"--port" <number> | ||
@@ -41,3 +47,4 @@ Specify port number for DNS server. | ||
"--fallback-server" <IP[:port]> | ||
"-f" <IP> | ||
"--fallback-server" <IP> | ||
Specify fallback DNS server | ||
@@ -58,4 +65,18 @@ to resolve hostnames not found in "--hosts-file". | ||
* only host names that match this exact string value are resolved to its corresponding IP address value | ||
* [example](./tests/1a-start-dns-server/hosts.json) | ||
#### Examples: | ||
* of specifying a [`hosts.json`](./tests/1-hosts-file/1a-start-dns-server/hosts.json) file | ||
```bash | ||
dns-server \ | ||
-h "/path/to/hosts.json" | ||
``` | ||
* of specifying 'hosts' mappings without a `hosts.json` file: | ||
```bash | ||
dns-server \ | ||
-H "foo.local = 192.168.0.101" \ | ||
-H "bar.local = 192.168.0.102" \ | ||
-H "baz.local = 192.168.0.103" | ||
``` | ||
- - - - | ||
@@ -62,0 +83,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27349
205
92