跳转到主要内容

基于Twisted的Tor控制器客户端,具有状态跟踪和配置抽象。https://txtorcon.readthedocs.org https://github.com/meejah/txtorcon

项目描述

github-actions coveralls codecov ReadTheDocs ReadTheDocs

txtorcon

万英尺高空

txtorcon是使用Twisted网络库为Python实现control-specTor

这对于编写基于事件的Python程序以控制或使用Tor非常有用。如果你的Twisted程序支持端点(例如,twistd),你的服务器或客户端可以立即使用Tor,无需更改代码。启动自己的Tor或连接到其中一个并获取实时流、电路、中继更新;读取和更改配置;监控事件;构建电路;创建洋葱服务;等等(ReadTheDocs)。

一些可能具有启发性的示例代码

下载

from twisted.internet.task import react
from twisted.internet.defer import inlineCallbacks, ensureDeferred
from twisted.internet.endpoints import UNIXClientEndpoint

import treq
import txtorcon


async def main(reactor):
    tor = await txtorcon.connect(
        reactor,
        UNIXClientEndpoint(reactor, "/var/run/tor/control")
    )

    print("Connected to Tor version {}".format(tor.version))

    url = u'https://www.torproject.org:443'
    print(u"Downloading {}".format(repr(url)))
    resp = await treq.get(url, agent=tor.web_agent())

    print(u"   {} bytes".format(resp.length))
    data = await resp.text()
    print(u"Got {} bytes:\n{}\n[...]{}".format(
        len(data),
        data[:120],
        data[-120:],
    ))

    print(u"Creating a circuit")
    state = await tor.create_state()
    circ = await state.build_circuit()
    await circ.when_built()
    print(u"  path: {}".format(" -> ".join([r.ip for r in circ.path])))

    print(u"Downloading meejah's public key via above circuit...")
    config = await tor.get_config()
    resp = await treq.get(
        u'https://meejah.ca/meejah.asc',
        agent=circ.web_agent(reactor, config.socks_endpoint(reactor)),
    )
    data = await resp.text()
    print(data)


@react
def _main(reactor):
    return ensureDeferred(main(reactor))

现在在Debian/Ubuntu上试试

例如,通过洋葱服务(又名隐藏服务)提供一些文件

$ sudo apt-get install --install-suggests python3-txtorcon
$ twistd -n web --port "onion:80" --path ~/public_html

阅读更多

所有文档从docs/index.rst开始。也托管在txtorcon.rtfd.org

您应该从介绍开始(在RTD上托管)。

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

txtorcon-24.8.0.tar.gz (312.8 kB 查看哈希)

上传时间

构建分布

txtorcon-24.8.0-py3-none-any.whl (261.3 kB 查看哈希)

上传时间 Python 3

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面