跳转到主要内容

I2P绑定Twisted

项目描述

travis coveralls

txi2p 是为 10.1 或更高版本的 Twisted 提供的一组 I2P 绑定。它目前需要 Python 2。

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

安装

您可以从 PyPI 安装 txi2p

$ pip2 install txi2p

或通过下载源文件并在源目录下运行

$ pip2 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> - SAM 或 BOB。

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

客户端

客户端字符串格式

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已更改,不再需要reactor。

文档

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

项目详情


下载文件

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

源代码分发

txi2p-0.3.2.tar.gz (33.1 kB 查看散列)

上传时间 源代码

由以下机构支持

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