forked from alepolidori/astproxy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(privateIp): added private ip fallback to physical phones (#15)
Co-authored-by: tonyco97 <[email protected]>
- Loading branch information
1 parent
7afd1c0
commit 77b79c4
Showing
2 changed files
with
32 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Provides common utilities functions. | ||
* | ||
* @class util | ||
* @static | ||
*/ | ||
|
||
/** | ||
* Checks if an IP address is private. | ||
* | ||
* @method isPrivateIP | ||
* @static | ||
* @param {string} ip The IP address to check | ||
* @return {boolean} True if the IP is private, otherwise False. | ||
*/ | ||
function isPrivateIP(ip) { | ||
const privateRanges = [ | ||
/^10\./, | ||
/^172\.(1[6-9]|2[0-9]|3[0-1])\./, | ||
/^192\.168\./, | ||
]; | ||
|
||
return privateRanges.some((range) => range.test(ip)); | ||
} | ||
|
||
// public interface | ||
exports.isPrivateIP = isPrivateIP; |