nikserg/yii2-curl-tor

此包的最新版本(0.0.5)没有可用的许可信息。

支持Curl中的TOR代理

0.0.5 2019-02-27 15:16 UTC

This package is auto-updated.

Last update: 2024-09-28 04:00:53 UTC


README

为Yii2提供Curl中的TOR代理支持。

安装

composer require nikserg/yii2-curl-tor

使用方法

$curl = new CurlTor('localhost', 9050, 9051, 'OInf80v0cc83lascm9Jf');

其中

'localhost' - TOR实例的主机

9050 - 客户端端口

9051 - 控制端口

'OInf80v0cc83lascm9Jf' - 认证令牌

默认情况下,TOR是禁用的。 CurlTor 作为常规的 Curl 模型运行。要启用TOR,请使用 $curlTor->enableTor()

关于控制端口和认证令牌

这些内容用于在运行时更改TOR身份(您的IP地址)。为此,请使用 $curlTor->newIdentity()。如果您不打算使用此类功能,则可以忽略此内容。如何设置

  1. /etc/torrc 中取消注释

#ControlPort 9051

#HashedControlPassword 16:872860B76453A77D60CA2BB8C1A7042072093276A3D701AD684053EC4C

  1. 使用命令 tor --hash-password mypass 生成密码,其中 mypass 是所需的密码

  2. 将结果插入到 #HashedControlPassword

  3. 使用 sudo service tor restart 重新启动TOR

您已设置完毕。现在您可以使用

$curl->newIdentity();

几秒钟后,您将获得新的IP。