-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #340 from younesaassila/v2.3.8
Release version 2.3.8
- Loading branch information
Showing
22 changed files
with
476 additions
and
1,438 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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,27 @@ | ||
import { Address4, Address6 } from "ip-address"; | ||
|
||
const ip4LinkLocalSubnet = new Address4("169.254.0.0/16"); | ||
const ip4LoopbackSubnet = new Address4("127.0.0.0/8"); | ||
const ip4PrivateASubnet = new Address4("10.0.0.0/8"); | ||
const ip4PrivateBSubnet = new Address4("172.16.0.0/12"); | ||
const ip4PrivateCSubnet = new Address4("192.168.0.0/16"); | ||
|
||
export default function isPrivateIp(address: string): boolean { | ||
try { | ||
const ip4 = new Address4(address); | ||
return ( | ||
ip4.isInSubnet(ip4LinkLocalSubnet) || | ||
ip4.isInSubnet(ip4LoopbackSubnet) || | ||
ip4.isInSubnet(ip4PrivateASubnet) || | ||
ip4.isInSubnet(ip4PrivateBSubnet) || | ||
ip4.isInSubnet(ip4PrivateCSubnet) | ||
); | ||
} catch (error) {} | ||
|
||
try { | ||
const ip6 = new Address6(address); | ||
return ip6.isLinkLocal() || ip6.isLoopback(); | ||
} catch (error) {} | ||
|
||
return false; | ||
} |
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
Oops, something went wrong.