跳转到主要内容

Twisted的I2P绑定

项目描述

这是一个希望是临时的txi2p分支,以帮助Tahoe-LAFS项目在Python 3移植工作中取得进展。

travis coveralls

txi2p是一套针对Twisted 10.1或更高版本的I2P绑定。它目前需要Python 2。

txi2p将在Python 3.3+上运行(需要Twisted 15.4或更高版本)。

txi2p支持I2P的SAM和BOB API。默认API是SAM。

安装

您可以从PyPI安装txi2p

$ pip install txi2p-tahoe

或通过下载源代码并运行

$ pip install .

位于源目录内部。

快速入门

如果您不熟悉使用端点或端点字符串,请阅读Twisted 端点文档。

使用端点类

连接到 I2P 网站

from twisted.internet import reactor
from twisted.internet.endpoints import clientFromString
from txi2p.sam import SAMI2PStreamClientEndpoint

samEndpoint = clientFromString(reactor, 'tcp:127.0.0.1:7656')
endpoint = SAMI2PStreamClientEndpoint.new(samEndpoint, 'stats.i2p')
d = endpoint.connect(factory)

使服务器监听 I2P 目标

from twisted.internet import reactor
from twisted.internet.endpoints import clientFromString
from txi2p.sam import SAMI2PStreamServerEndpoint

samEndpoint = clientFromString(reactor, 'tcp:127.0.0.1:7656')
endpoint = SAMI2PStreamServerEndpoint.new(samEndpoint, '/path/to/keyfile')
d = endpoint.listen(factory)

使用端点字符串

需要 Twisted 14.0 或更高版本。

连接到 I2P 网站

from twisted.internet import reactor
from twisted.internet.endpoints import clientFromString

endpoint = clientFromString(reactor, 'i2p:stats.i2p')
d = endpoint.connect(factory)

使服务器监听 I2P 目标

from twisted.internet import reactor
from twisted.internet.endpoints import serverFromString

endpoint = serverFromString(reactor, 'i2p:/path/to/keyfile')
d = endpoint.listen(factory)

使用特定 API 连接

from twisted.internet import reactor
from twisted.internet.endpoints import clientFromString

endpoint = clientFromString(reactor, 'i2p:stats.i2p:api=BOB')
d = endpoint.connect(factory)

使用非标准 API 主机或端口连接

from twisted.internet import reactor
from twisted.internet.endpoints import clientFromString

endpoint = clientFromString(reactor, 'i2p:stats.i2p:api=SAM:apiEndpoint=tcp\:127.0.0.1\:31337')
d = endpoint.connect(factory)

端点字符串

Twisted 插件 clientFromString()serverFromString() 仅适用于 Twisted 14.0 或更高版本。

客户端和服务器字符串都支持以下关键字参数

  • api=<apiName> - 要么是 SAMBOB

  • apiEndpoint=<endpointString> - 指向 API 的转义客户端端点字符串,例如 tcp:127.0.0.1:2827

  • options=keyOne:valueOne,keyTwo:valueTwo - 以逗号分隔的键值列表作为 I2CP 选项。请参阅 I2CP 规范 了解可用选项。

客户端

客户端字符串格式

i2p:<host>[:port][:key=value]*

支持参数

SAM

  • 昵称

  • 自动关闭

  • 密钥文件

  • 本地端口

  • 签名类型

BOB

  • 隧道昵称

  • 内部主机

  • 内部端口

服务器

服务器字符串格式

i2p:<keyfile>[:port][:key=value]*

支持参数

SAM

  • 昵称

  • 自动关闭

  • 签名类型

BOB

  • 隧道昵称

  • 输出主机

  • 输出端口

重要更改

0.3.2

  • 新目标的默认签名类型为 Ed25519。

    • 如果 SAM 服务器不支持该类型(Java I2P 0.9.16 及更早版本),txi2p 将回退到 ECDSA_SHA256_P256,然后是旧默认值 DSA_SHA1。

0.3

  • 现在支持 SAM API 上的端口。

    • 之前的 port 选项不再被忽略。

    • 新的 localPort 选项用于设置客户端的本地端口。

  • SAMI2PStreamServerEndpoint API 已更改,不再需要反应器。

文档

API 文档可在 https://txi2p.readthedocs.org 查找。

项目详情


下载文件

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

源分发

txi2p-tahoe-0.3.7.tar.gz (45.7 kB 查看哈希值)

上传时间

构建分发

txi2p_tahoe-0.3.7-py3-none-any.whl (44.8 kB 查看哈希值)

上传时间 Python 3

支持者

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