-
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.
- Loading branch information
0 parents
commit 3740ad6
Showing
11 changed files
with
4,618 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Javascript Node CircleCI 2.0 configuration file | ||
# | ||
# Check https://circleci.com/docs/2.0/language-javascript/ for more details | ||
# | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
# specify the version you desire here | ||
- image: circleci/node:8.11 | ||
|
||
# Specify service dependencies here if necessary | ||
# CircleCI maintains a library of pre-built images | ||
# documented at https://circleci.com/docs/2.0/circleci-images/ | ||
# - image: circleci/mongo:3.4.4 | ||
|
||
working_directory: ~/repo | ||
|
||
steps: | ||
- checkout | ||
|
||
# Download and cache dependencies | ||
- restore_cache: | ||
keys: | ||
- v1-dependencies-{{ checksum "package.json" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- v1-dependencies- | ||
|
||
- run: yarn install | ||
|
||
- save_cache: | ||
paths: | ||
- node_modules | ||
key: v1-dependencies-{{ checksum "package.json" }} | ||
|
||
# eslint | ||
- run: | ||
name: "elsint" | ||
command: yarn eslint | ||
|
||
|
||
# prettier | ||
- run: | ||
name: "prettier" | ||
command: yarn prettier:check | ||
|
||
# test | ||
- run: | ||
name: "test" | ||
command: yarn test | ||
|
||
# coverage | ||
- run: | ||
name: "coverage" | ||
command: yarn coverage --ci --testResultsProcessor="jest-junit" | ||
environment: | ||
JEST_JUNIT_OUTPUT: "reports/junit/js-test-results.xml" | ||
|
||
- store_test_results: | ||
path: reports/junit | ||
- store_artifacts: | ||
path: reports/junit | ||
|
||
# coveralls | ||
- run: | ||
name: "coveralls" | ||
command: yarn coverage --coverageReporters=text-lcov | yarn coveralls |
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,19 @@ | ||
module.exports = { | ||
env: { | ||
commonjs: true, | ||
es6: true, | ||
node: true | ||
}, | ||
extends: 'eslint:recommended', | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
}, | ||
rules: { | ||
indent: ['error', 2], | ||
'linebreak-style': ['error', 'unix'], | ||
quotes: ['error', 'single'], | ||
semi: ['error', 'always'], | ||
indent: ['error', 2, { SwitchCase: 1 }], | ||
'no-console': 'off', | ||
}, | ||
}; |
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,4 @@ | ||
node_modules | ||
coverage | ||
*.swp | ||
yarn-error.log |
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,6 @@ | ||
* | ||
!index.js | ||
!utils.js | ||
!package.json | ||
!README.md | ||
!LICENSE |
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,15 @@ | ||
{ | ||
"printWidth": 80, | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"useTabs": false, | ||
"parser": "babylon", | ||
"overrides": [ | ||
{ | ||
"files": "*.json", | ||
"options": { "parser": "json", "printWidth": 200 } | ||
} | ||
] | ||
} |
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,134 @@ | ||
# DoH (DNS over HTTPS) Command Line Client, RFC-8484 Compatible | ||
|
||
[`@sagi.io/doh`](https://www.npmjs.com/package/@sagi.io/doh) is an RFC-8484 compliant Node.js [DNS over HTTPS](https://en.wikipedia.org/wiki/DNS_over_HTTPS) command line tool. | ||
|
||
[![CircleCI](https://circleci.com/gh/sagi/doh-node.svg?style=svg)](https://circleci.com/gh/sagi/doh-node) | ||
[![Coverage Status](https://coveralls.io/repos/github/sagi/doh-node/badge.svg?branch=master)](https://coveralls.io/github/sagi/doh-node?branch=master) | ||
[![MIT License](https://img.shields.io/npm/l/@sagi.io/doh.svg?style=flat-square)](http://opensource.org/licenses/MIT) | ||
[![version](https://img.shields.io/npm/v/@sagi.io/doh.svg?style=flat-square)](http://npm.im/@sagi.io/doh) | ||
|
||
## Installation: | ||
~~~ | ||
$ npm i -g @sagi.io/doh | ||
~~~ | ||
|
||
Usage: | ||
~~~ | ||
Usage: doh name [type] [class] [@dohUrl] [-p<port>] [-u<userAgent>] [-v] [-g]; | ||
~~~ | ||
|
||
If only `name` (domain name) is provided, it defaults to using Cloudflare's DNS-over-HTTPS server | ||
(`@cloudflare-dns.com/dns-query`). | ||
|
||
## Examples | ||
|
||
~~~ | ||
$ doh sagi.io | ||
~~~ | ||
|
||
Output: | ||
~~~json | ||
{ | ||
"id": 9013, | ||
"type": "response", | ||
"flags": 384, | ||
"flag_qr": true, | ||
"opcode": "QUERY", | ||
"flag_aa": false, | ||
"flag_tc": false, | ||
"flag_rd": true, | ||
"flag_ra": true, | ||
"flag_z": false, | ||
"flag_ad": false, | ||
"flag_cd": false, | ||
"rcode": "NOERROR", | ||
"questions": [ | ||
{ | ||
"name": "sagi.io", | ||
"type": "A", | ||
"class": "IN" | ||
} | ||
], | ||
"answers": [ | ||
{ | ||
"name": "sagi.io", | ||
"type": "A", | ||
"ttl": 300, | ||
"class": "IN", | ||
"flush": false, | ||
"data": "151.101.1.195" | ||
}, | ||
{ | ||
"name": "sagi.io", | ||
"type": "A", | ||
"ttl": 300, | ||
"class": "IN", | ||
"flush": false, | ||
"data": "151.101.65.195" | ||
} | ||
], | ||
"authorities": [], | ||
"additionals": [] | ||
} | ||
~~~ | ||
|
||
~~~ | ||
$ doh mx sagi.io @https://dns.google.com/experimental | ||
~~~ | ||
|
||
Output: | ||
~~~json | ||
{ | ||
"id": 0, | ||
"type": "response", | ||
"flags": 384, | ||
"flag_qr": true, | ||
"opcode": "QUERY", | ||
"flag_aa": false, | ||
"flag_tc": false, | ||
"flag_rd": true, | ||
"flag_ra": true, | ||
"flag_z": false, | ||
"flag_ad": false, | ||
"flag_cd": false, | ||
"rcode": "NOERROR", | ||
"questions": [ | ||
{ | ||
"name": "sagi.io", | ||
"type": "MX", | ||
"class": "IN" | ||
} | ||
], | ||
"answers": [ | ||
{ | ||
"name": "sagi.io", | ||
"type": "MX", | ||
"ttl": 299, | ||
"class": "IN", | ||
"flush": false, | ||
"data": { | ||
"preference": 10, | ||
"exchange": "mxa.mailgun.org" | ||
} | ||
}, | ||
{ | ||
"name": "sagi.io", | ||
"type": "MX", | ||
"ttl": 299, | ||
"class": "IN", | ||
"flush": false, | ||
"data": { | ||
"preference": 10, | ||
"exchange": "mxb.mailgun.org" | ||
} | ||
} | ||
], | ||
"authorities": [], | ||
"additionals": [] | ||
} | ||
~~~ | ||
|
||
Probably some time the future we'll add a `DiG`-like output. | ||
|
||
## License | ||
MIT |
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,39 @@ | ||
#!/usr/bin/env node | ||
const doh = require('@sagi.io/dns-over-https'); | ||
const { parseArgv, parseDohUrl } = require('./utils'); | ||
|
||
(async () => { | ||
const cliOptions = parseArgv(process.argv); | ||
const { | ||
dohUrl, | ||
userAgent, | ||
name, | ||
method, | ||
type, | ||
klass, | ||
port: userPort, | ||
verbose, | ||
} = cliOptions; | ||
|
||
const { protocol, hostname, path } = parseDohUrl(dohUrl); | ||
|
||
const useHttps = protocol === 'https:'; | ||
const port = userPort ? userPort : useHttps ? 443 : 80; | ||
|
||
if (verbose) { | ||
console.log(JSON.stringify(cliOptions, null, 2)); | ||
} | ||
|
||
const r = await doh.query({ | ||
method, | ||
hostname, | ||
path, | ||
port, | ||
userAgent, | ||
name, | ||
type, | ||
klass, | ||
useHttps, | ||
}); | ||
console.log(JSON.stringify(r, null, 2)); | ||
})(); |
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,45 @@ | ||
{ | ||
"name": "@sagi.io/doh", | ||
"version": "0.0.1", | ||
"description": "RFC-8484 Compliant DNS-over-HTTPS Command Line Tool", | ||
"main": "index.js", | ||
"author": "Sagi Kedmi <git@sagi.io> (https://sagi.io)", | ||
"license": "MIT", | ||
"bin": { | ||
"doh": "./index.js" | ||
}, | ||
"scripts": { | ||
"start": "node index.js", | ||
"prettier:check": "prettier --list-different index.js", | ||
"eslint": "eslint index.js", | ||
"test": "jest", | ||
"coverage": "jest --coverage" | ||
}, | ||
"dependencies": { | ||
"@sagi.io/dns-over-https": "^0.0.2" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "^3.0.2", | ||
"eslint": "^5.9.0", | ||
"eslint-plugin-jest": "^22.0.0", | ||
"jest": "^23.6.0", | ||
"jest-junit": "^5.2.0", | ||
"prettier": "^1.14.3" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/sagi/doh-node.git" | ||
}, | ||
"keywords": [ | ||
"dns-over-https", | ||
"doh", | ||
"cli", | ||
"command line", | ||
"dns over https", | ||
"dns", | ||
"https", | ||
"dnshttps", | ||
"security", | ||
"privacy" | ||
] | ||
} |
Oops, something went wrong.