-
-
Notifications
You must be signed in to change notification settings - Fork 938
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
dnsLookupIpVersion
option (#1264)
Co-authored-by: Szymon Marczak <[email protected]> Co-authored-by: Sindre Sorhus <[email protected]>
- Loading branch information
1 parent
e00dbbc
commit 7f643bb
Showing
5 changed files
with
171 additions
and
5 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
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
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,20 @@ | ||
export type DnsLookupIpVersion = 'auto' | 'ipv4' | 'ipv6'; | ||
type DnsIpFamily = 0 | 4 | 6; | ||
|
||
const conversionTable = { | ||
auto: 0, | ||
ipv4: 4, | ||
ipv6: 6 | ||
}; | ||
|
||
export const isDnsLookupIpVersion = (value: any): boolean => { | ||
return value in conversionTable; | ||
}; | ||
|
||
export const dnsLookupIpVersionToFamily = (dnsLookupIpVersion: DnsLookupIpVersion): DnsIpFamily => { | ||
if (isDnsLookupIpVersion(dnsLookupIpVersion)) { | ||
return conversionTable[dnsLookupIpVersion] as DnsIpFamily; | ||
} | ||
|
||
throw new Error('Invalid DNS lookup IP version'); | ||
}; |
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
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