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 ab665d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
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 ab665d2

Please sign in to comment.