Comparing version 1.0.0 to 1.1.0
@@ -1,8 +0,14 @@ | ||
const Pkg = require('./../package.json'); | ||
require('es6-promise').polyfill(); | ||
require('isomorphic-fetch'); | ||
const IsIP = require('is-ip'); | ||
const Url = require ('url'); | ||
const Dohdec = require('dohdec'); | ||
const Fetch = require('node-fetch'); | ||
const Pkg = require('./../package.json'); | ||
const IsIP = require('is-ip'); | ||
const Url = require ('url'); | ||
const Qs = require('querystring'); | ||
const Fetch = fetch; | ||
const CT_TYPE = 'application/dns-json'; | ||
const USER_AGENT = `${Pkg.name} v${Pkg.version}`; | ||
const TYPES = { | ||
@@ -14,3 +20,4 @@ DNS_PROVIDERS: { | ||
DNS_OVER_HTTPS: { | ||
GOOGLE: 'https://dns.google.com/resolve' | ||
GOOGLE: 'https://dns.google.com/resolve', | ||
CLOUDFLARE: 'https://cloudflare-dns.com/dns-query' | ||
} | ||
@@ -28,2 +35,23 @@ }; | ||
getDns () { | ||
return async (name, opts) => { | ||
opts = Object.assign({}, { | ||
rrtype: 'A', | ||
url: TYPES.DNS_OVER_HTTPS.CLOUDFLARE, | ||
name: Qs.escape(name) | ||
}, opts); | ||
opts.rrtype = opts.rrtype.toUpperCase(); | ||
const lookup = await fetch( | ||
`${opts.url}?ct=${CT_TYPE}&name=${opts.name}&type=${opts.rrtype}`, { | ||
headers: { | ||
'User-Agent': USER_AGENT | ||
} | ||
}); | ||
return lookup.json(); | ||
}; | ||
} | ||
set () { | ||
@@ -44,5 +72,6 @@ let ctx = this; | ||
const getDns = ctx.getDns(); | ||
const _dnsRequest = (provider === TYPES.DNS_PROVIDERS.CLOUDFLARE) ? | ||
await Dohdec(_url.hostname) : | ||
await Dohdec(_url.hostname, { | ||
await getDns(_url.hostname) : | ||
await getDns(_url.hostname, { | ||
url: TYPES.DNS_OVER_HTTPS[TYPES.DNS_PROVIDERS.GOOGLE] | ||
@@ -49,0 +78,0 @@ }); |
{ | ||
"name": "fdoh", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Fetch DNS over HTTPS", | ||
@@ -33,4 +33,7 @@ "main": "index.js", | ||
"dependencies": { | ||
"dohdec": "^1.0.0", | ||
"is-ip": "^2.0.0" | ||
"es6-promise": "^4.2.4", | ||
"is-ip": "^2.0.0", | ||
"isomorphic-fetch": "^2.2.1", | ||
"querystring": "^0.2.0", | ||
"url": "^0.11.0" | ||
}, | ||
@@ -37,0 +40,0 @@ "devDependencies": { |
@@ -9,3 +9,3 @@ # FDOH | ||
The point of this utility is to be able to utilize node-fetch with your DNS queries running over HTTPS from Cloudflare [1.1.1.1](https://1.1.1.1) or Google DNS over HTTPS. | ||
The point of this utility is to be able to utilize fetch with your DNS queries running over HTTPS from Cloudflare [1.1.1.1](https://1.1.1.1) or Google DNS over HTTPS. | ||
@@ -39,6 +39,1 @@ ### Fetch Example | ||
### Dependencies | ||
- [dohdec](https://github.com/hildjj/dohdec) | ||
- [is-ip](https://github.com/sindresorhus/is-ip) |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
9205
10
121
5
38
2
+ Addedes6-promise@^4.2.4
+ Addedisomorphic-fetch@^2.2.1
+ Addedquerystring@^0.2.0
+ Addedurl@^0.11.0
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedes6-promise@4.2.8(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.7(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedisomorphic-fetch@2.2.1(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addednode-fetch@1.7.3(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedpunycode@1.4.1(transitive)
+ Addedqs@6.14.0(transitive)
+ Addedquerystring@0.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedside-channel@1.1.0(transitive)
+ Addedside-channel-list@1.0.0(transitive)
+ Addedside-channel-map@1.0.1(transitive)
+ Addedside-channel-weakmap@1.0.2(transitive)
+ Addedurl@0.11.4(transitive)
+ Addedwhatwg-fetch@3.6.20(transitive)
- Removeddohdec@^1.0.0
- Removed@leichtgewicht/ip-codec@2.0.5(transitive)
- Removedansi-regex@2.1.13.0.1(transitive)
- Removedcamelcase@5.3.1(transitive)
- Removedcliui@4.1.0(transitive)
- Removedcode-point-at@1.1.0(transitive)
- Removedcross-spawn@6.0.6(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removeddns-packet@5.6.1(transitive)
- Removeddohdec@1.1.0(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedexeca@1.0.0(transitive)
- Removedfind-up@3.0.0(transitive)
- Removedget-caller-file@1.0.3(transitive)
- Removedget-stream@4.1.0(transitive)
- Removedinvert-kv@2.0.0(transitive)
- Removedis-fullwidth-code-point@1.0.02.0.0(transitive)
- Removedisexe@2.0.0(transitive)
- Removedlcid@2.0.0(transitive)
- Removedlocate-path@3.0.0(transitive)
- Removedmap-age-cleaner@0.1.3(transitive)
- Removedmem@4.3.0(transitive)
- Removedmimic-fn@2.1.0(transitive)
- Removednice-try@1.0.5(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removednpm-run-path@2.0.2(transitive)
- Removednumber-is-nan@1.0.1(transitive)
- Removedonce@1.4.0(transitive)
- Removedos-locale@3.1.0(transitive)
- Removedp-defer@1.0.0(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedp-is-promise@2.1.0(transitive)
- Removedp-limit@2.3.0(transitive)
- Removedp-locate@3.0.0(transitive)
- Removedp-try@2.2.0(transitive)
- Removedpath-exists@3.0.0(transitive)
- Removedpath-key@2.0.1(transitive)
- Removedpump@3.0.2(transitive)
- Removedrequire-directory@2.1.1(transitive)
- Removedrequire-main-filename@1.0.1(transitive)
- Removedsemver@5.7.2(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedshebang-command@1.2.0(transitive)
- Removedshebang-regex@1.0.0(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedstring-width@1.0.22.1.1(transitive)
- Removedstrip-ansi@3.0.14.0.0(transitive)
- Removedstrip-eof@1.0.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
- Removedwhich@1.3.1(transitive)
- Removedwhich-module@2.0.1(transitive)
- Removedwrap-ansi@2.1.0(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedy18n@4.0.3(transitive)
- Removedyargs@12.0.5(transitive)
- Removedyargs-parser@11.1.1(transitive)