Skip to content

Commit

Permalink
feat(mitm): allow a user to configure dns provider
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Oct 11, 2021
1 parent 5ed488b commit c361d5c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/main/BasicInterfaces/Hero.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ const Hero = require('@ulixee/hero');
- userAgent `strong`. This sets your browser's user agent string. Prefixing this string with a tilde (~) allows for dynamic options.
- browserEmulatorId `string` defaults to `default-browser-emulator`. Chooses the BrowserEmulator plugin which emulates the properties that help Hero look like a normal browser.
- humanEmulatorId `string` defaults to `default-human-emulator`. Chooses the HumanEmulator plugin which drives the mouse/keyboard movements.
- dnsOverTlsProvider `object`. Configure the host and port to use for DNS over TLS. This feature replicates the Chrome feature that is used if the host DNS provider supports DNS over TLS or DNS over HTTPS. A `null` value will disable this feature.
- host `string`. The DNS provider host address. Google=8.8.8.8, Cloudflare=1.1.1.1, Quad9=9.9.9.9.
- servername `string`. The DNS provider tls servername. Google=dns.google, Cloudflare=cloudflare-dns.com, Quad9=dns.quad9.net.
- geolocation `IGeolocation`. Overrides the geolocation of the user. Will automatically grant permissions to all origins for geolocation.
- latitude `number`. Latitude between -90 and 90.
- longitude `number`. Longitude between -180 and 180.
Expand Down
1 change: 1 addition & 0 deletions interfaces/ICorePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export interface IBrowserEmulatorConfig {
geolocation?: IGeolocation;
timezoneId?: string;
locale?: string;
dnsOverTlsProvider?: IDnsSettings['dnsOverTlsConnection'];
}

// decorator for browser emulator classes. hacky way to check the class implements statics we need
Expand Down
2 changes: 1 addition & 1 deletion interfaces/ISessionCreateOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default interface ISessionCreateOptions extends ISessionOptions {
geolocation?: IGeolocation;
dependencyMap?: { [clientPluginId: string]: string[] };
corePluginPaths?: string[];

dnsOverTlsProvider?: { host: string; port: number };
showBrowser?: boolean;
showBrowserInteractions?: boolean;
allowManualBrowserInteraction?: boolean;
Expand Down
6 changes: 6 additions & 0 deletions plugins/default-browser-emulator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default class DefaultBrowserEmulator extends BrowserEmulator {
public locale: string;
public viewport: IViewport;
public geolocation: IGeolocation;
public dnsOverTlsProvider: IDnsSettings['dnsOverTlsConnection'];

protected readonly data: IBrowserData;
private readonly domOverridesBuilder: DomOverridesBuilder;
Expand Down Expand Up @@ -82,10 +83,15 @@ export default class DefaultBrowserEmulator extends BrowserEmulator {
this.viewport = config.viewport;
this.timezoneId = config.timezoneId;
this.geolocation = config.geolocation;
this.dnsOverTlsProvider = config.dnsOverTlsProvider;
}

public onDnsConfiguration(settings: IDnsSettings): void {
configureSessionDns(this, settings);

if (this.dnsOverTlsProvider !== undefined) {
settings.dnsOverTlsConnection = this.dnsOverTlsProvider;
}
}

public onTcpConfiguration(settings: ITcpSettings): void {
Expand Down

0 comments on commit c361d5c

Please sign in to comment.