Skip to content

Commit

Permalink
Support got agent option
Browse files Browse the repository at this point in the history
  • Loading branch information
Joachim Basmaison committed Nov 24, 2022
1 parent 4356411 commit 8c216fc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 0 additions & 2 deletions pkg/dohdec-cli/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export class DnsCli extends Command {
)
.option('-d, --dns', 'Use DNS format instead of JSON (ignored for TLS)')
.option('-s, --dnssec', 'Request DNSsec records')
.option('-k, --dnssecCheckingDisabled', 'Disable DNSsec validation')
.option(
'-e, --ecs <number>',
'Use this many bits for EDNS Client Subnet (ECS)',
Expand Down Expand Up @@ -181,7 +180,6 @@ For more debug information:
ecsSubnet: this.argv.ecsSubnet,
ecs: this.argv.ecs,
dnssec: this.argv.dnssec,
dnssecCheckingDisabled: this.argv.dnssecCheckingDisabled,
}
try {
if (net.isIP(opts.name)) {
Expand Down
7 changes: 4 additions & 3 deletions pkg/dohdec-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@
},
"dependencies": {
"commander": "^9.4.1",
"dohdec": "^5.0.3"
"dohdec": "../dohdec"
},
"devDependencies": {
"@types/node": "^18.11.2",
"jsrsasign": "^10.5.27",
"minami": "^1.2.3",
"mock-dns-server": "^5.0.3",
"mock-dns-server": "../mock-dns-server",
"nock": "^13.2.9",
"typescript": "^4.8.4"
"typescript": "^4.8.4",
"https-proxy-agent": "5.0.1"
},
"engines": {
"node": ">=14.20"
Expand Down
5 changes: 5 additions & 0 deletions pkg/dohdec/lib/doh.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export class DNSoverHTTPS extends DNSutils {
* @param {Writable} [opts.verboseStream=process.stderr] Where to write
* verbose output.
* @param {boolean} [opts.http2=false] Use http/2 if it is available.
* GOT Agent objects
* @param {object} [opts.agent=Agents] Pass down got agent option
*/
constructor(opts = {}) {
const {
Expand All @@ -69,6 +71,7 @@ export class DNSoverHTTPS extends DNSutils {
preferPost: true,
contentType: WF_DNS,
http2: false,
agent: undefined,
...rest,
}

Expand Down Expand Up @@ -132,6 +135,7 @@ export class DNSoverHTTPS extends DNSutils {
retry: {
limit: 0,
},
agent: this.opts.agent,
}).buffer()
this.hexDump(2, response)
this.verbose(1, 'RESPONSE:', () => packet.decode(response))
Expand Down Expand Up @@ -181,6 +185,7 @@ export class DNSoverHTTPS extends DNSutils {
retry: {
limit: 0,
},
agent: this.opts.agent,
}
)

Expand Down
4 changes: 4 additions & 0 deletions pkg/dohdec/types/doh.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type {Agents} from 'got';

/**
* Options for doing DOH lookups.
*
Expand Down Expand Up @@ -46,13 +48,15 @@ export class DNSoverHTTPS extends DNSutils {
verbose?: number;
verboseStream?: Writable;
http2?: boolean;
agent?: Agents;
});
opts: {
userAgent: string;
url: string;
preferPost: boolean;
contentType: string;
http2: boolean;
agent: Agents;
};
hooks: {
beforeRequest: ((options: any) => void)[];
Expand Down

0 comments on commit 8c216fc

Please sign in to comment.