profburial / tordetect
轻松检测Tor用户。
v1.1
2015-12-23 22:10 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2024-09-14 17:32:00 UTC
README
我爱Tor及其代表的大部分东西。然而,在某些用例中,人们可能会用Tor来做坏事。
*** 声明 ***
如果您想要做任何严肃的事情,那么您可能不应该直接使用这个库。它维护一个包含Tor出口节点列表的json文件,这个文件应该存储在更严肃的应用程序的其他地方。
支持
如果您在商业项目中使用了这个库或其组件,请考虑考虑道德授权
安装
composer require profburial/tordetect 1.1
使用
创建一个可写的json文件来存储您的IP数据。
// Get a list of Tor exit nodes $ips = (new ProfBurial\TorDetect\Client( __DIR__."/_data/torexitnodes.json", // File for storing ips 24 // Update every 24 hours ))->get(); // array(1067) { // [0]=> // string(13) "1.169.207.157" // [1]=> // string(12) "2.107.22.186" // [2]=> // string(11) "2.111.64.26" // [3]=> // string(11) "2.221.39.34" // ... // } // Check an ip address against your list of exit nodes $check = (new ProfBurial\TorDetect\Client( __DIR__."/_data/torexitnodes.json", // File for storing ips 24 // Update every 24 hours ))->check('127.0.0.1'); // bool(false) if not found // '127.0.0.1' if found
测试
单元测试
phpunit tests/ClientUnitTest.php
集成测试
phpunit tests/ClientIntegrationTest.php