-
Notifications
You must be signed in to change notification settings - Fork 1
fix: filter out duplicate dns results MONGOSH-2027 #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -272,6 +272,25 @@ export class RFC8252HTTPServer { | |
| }); | ||
| }; | ||
|
|
||
| private static async _getAllInterfaces( | ||
|
||
| hostname: string | ||
| ): Promise<{ address: string; family: number }[]> { | ||
| const dnsResults = await dns.lookup(hostname, { | ||
| all: true, | ||
| hints: ADDRCONFIG, | ||
| }); | ||
|
|
||
| return dnsResults | ||
| .filter( | ||
| (dns, index, arr) => | ||
| arr.findIndex( | ||
| (otherDns) => | ||
| dns.address === otherDns.address && dns.family === otherDns.family | ||
| ) === index | ||
| ) | ||
| .map(({ address, family }) => ({ address, family })); | ||
| } | ||
|
|
||
| /** | ||
| * Add a redirect from a local URL served on the server to an external URL. | ||
| */ | ||
|
|
@@ -368,14 +387,11 @@ export class RFC8252HTTPServer { | |
| // to do what Node.js does by default when only a host is provided, | ||
| // namely listening on all interfaces. | ||
| let hostname = this.redirectUrl.hostname; | ||
| if (hostname.startsWith('[') && hostname.endsWith(']')) | ||
| if (hostname.startsWith('[') && hostname.endsWith(']')) { | ||
| hostname = hostname.slice(1, -1); | ||
| const dnsResults = ( | ||
| await dns.lookup(hostname, { | ||
| all: true, | ||
| hints: ADDRCONFIG, | ||
| }) | ||
| ).map(({ address, family }) => ({ address, family })); | ||
| } | ||
|
|
||
| const dnsResults = await RFC8252HTTPServer._getAllInterfaces(hostname); | ||
|
|
||
| this.logger.emit('mongodb-oidc-plugin:local-listen-resolved-hostname', { | ||
| url: this.redirectUrl.toString(), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.