-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Enrico Sola
authored and
Enrico Sola
committed
Feb 11, 2018
0 parents
commit 53f8aef
Showing
9 changed files
with
2,631 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Tor detector | ||
|
||
A very simple library to detect Tor connections using PHP 7 without any dependency. | ||
|
||
# Usage | ||
|
||
Before using the library, you have to set the path to the file that contains the list of all Tor exit points, if you don't have the list you can set an arbitrary file name instead. | ||
To set the library path, use this method: | ||
|
||
`PHPTorDetector\PHPTorDetector::setListPath('nodes.txt');` | ||
|
||
If the file doesn't exist or is empty or you just want to update its content, you can use this method to download the updated list and overwrite new list in the file: | ||
|
||
`PHPTorDetector\PHPTorDetector::updateFile();` | ||
|
||
Once you have the list, you can check if an IP address is part of the Tor network by using this method: | ||
|
||
`$result = PHPTorDetector\PHPTorDetector::isTor('IP ADDRESS HERE');` | ||
|
||
If you want to get the IP address of the client you can use this method: | ||
|
||
`$address = PHPTorDetector\PHPTorDetector::getClientIPAddress();` | ||
|
||
Are you looking for the Node.js version? Give a look [here](https://github.com/RyanJ93/tor-detector). |
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,28 @@ | ||
{ | ||
"name": "ryanj93/php-tor-detector", | ||
"version": "1.1.0", | ||
"description": "A very simple library to detect Tor connections using PHP 7 without any dependency.", | ||
"type": "library", | ||
"license": "GPL-3.0-or-later", | ||
"homepage": "https://github.com/RyanJ93/php-tor-detector#readme", | ||
"authors": [{ | ||
"name": "Enrico Sola", | ||
"email": "sola.enrico.93@gmail.com", | ||
"homepage": "https://www.enricosola.com" | ||
}], | ||
"require": { | ||
"php": ">=7.0" | ||
}, | ||
"keywords": [ | ||
"tor", | ||
"proxy", | ||
"validator", | ||
"utilities", | ||
"security" | ||
], | ||
"autoload": { | ||
"files": [ | ||
"php-tor-detector.php" | ||
] | ||
} | ||
} |
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,14 @@ | ||
<?php | ||
require dirname(__FILE__) . '/php-tor-detector.php'; | ||
|
||
$address = '89.234.157.254'; | ||
|
||
//Set the list path. | ||
PHPTorDetector\PHPTorDetector::setListPath('nodes.txt'); | ||
|
||
//Update the content fo the list (or create the list if the file doesn't exist or is empty). | ||
PHPTorDetector\PHPTorDetector::updateFile(); | ||
|
||
//Check if this IP address is a Tor exit point. | ||
$result = PHPTorDetector\PHPTorDetector::isTor($address); | ||
echo 'Is this client (' . $address . ') part of the Tor network? ' . ( $result === true ? 'Yes' : 'No' ) . '.' . PHP_EOL; |
Oops, something went wrong.