dunglas/php-torcontrol

Tor 控制库

资助包维护!
dunglas

v1.0.1 2016-01-22 08:01 UTC

This package is auto-updated.

Last update: 2024-08-27 02:39:56 UTC


README

TorControl 是一个用于控制 Tor 服务器的 PHP 库。

Build Status SensioLabsInsight StyleCI

特性

  • 通过网络套接字、SSL 网络套接字或 UNIX 套接字连接到 Tor 服务器
  • 支持空、密码和 cookie 文件认证方法
  • 自动认证空和 cookie 文件方法
  • 多行回复
  • 使用 PHPUnit 进行单元测试
  • 使用 Composer 安装

安装

注意:如果您使用的是 Symfony 框架,您应该使用 DunglasTorControlBundle

如果尚未安装,请安装 Composer

将 php-torcontrol 添加到您的 composer.json

composer require dunglas/php-torcontrol

用法

<?php

// Autoloading using composer
require 'vendor/autoload.php';

// Connect to the TOR server using password authentication
$tc = new TorControl\TorControl(
    array(
        'hostname' => 'localhost',
        'port'     => 9051,
        'password' => 'MySecr3tPassw0rd',
        'authmethod' => 1
    )
);

$tc->connect();

$tc->authenticate();

// Renew identity
$res = $tc->executeCommand('SIGNAL NEWNYM');

// Echo the server reply code and message
echo $res[0]['code'].': '.$res[0]['message'];

// Quit
$tc->quit();

相关

致谢

PHP TorControl 由 Kévin Dunglas 创建。