扭曲的I2P绑定
txi2p的Python项目详细描述
txi2p是Twisted的一组i2p绑定 10.1或更高。它目前需要python 2。
txi2p支持i2p的sam和bob api。默认api是sam。
安装
您可以从pypi安装txi2p:
$ pip2 install txi2p
或者下载源并运行:
$ pip2 install .
在源目录中。
快速启动
如果您不熟悉使用端点或端点字符串,请阅读 Twisted endpoints文档。
使用端点类
连接到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)
使用端点字符串
需要Twisted14.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)
端点字符串
clientFromString()和serverFromString()的twisted插件将 仅适用于Twisted14.0或更高版本。
客户端和服务器字符串都支持以下关键字参数:
- api=<apiName>-可以是SAM或BOB。
- apiEndpoint=<endpointString>-转义的客户端终结点字符串指向 到api,例如tcp\:127.0.0.1\:2827。
客户
客户端字符串格式:
i2p:<host>[:port][:key=value]*
支持的参数:
sam
- nickname
- autoClose
- keyfile
- localPort
- options
- sigType
bob
- tunnelNick
- inhost
- inport
- options
服务器
服务器字符串格式:
i2p:<keyfile>[:port][:key=value]*
支持的参数:
sam
- nickname
- autoClose
- options
- sigType
bob
- tunnelNick
- outhost
- outport
- options
重要更改
0.3.2
- 新目的地的默认签名类型为ed25519。
- 如果山姆服务器不支持(JavaI2P0.916和更早),TXI2P 将返回ecdsa_sha256_p256,然后是旧的默认dsa_sha1。
0.3
- sam api现在支持端口。
- 以前的port选项不再被忽略。
- 新的localPort选项,用于设置客户端的本地端口。
- SAMI2PStreamServerEndpointapi已更改为不再需要 反应堆。