Skip to main content

I2P bindings for Twisted

Project description

This is a hopefully temporary fork of txi2p, to help Tahoe-LAFS project to get unstuck in Python 3 porting efforts.

travis coveralls

txi2p is a set of I2P bindings for Twisted 10.1 or greater. It currently requires Python 2.

txi2p will run on Python 3.3+ (requiring Twisted 15.4 or greater).

txi2p supports both the SAM and BOB APIs for I2P. The default API is SAM.

Installation

You can install txi2p from PyPI:

$ pip install txi2p-tahoe

or by downloading the source and running:

$ pip install .

inside the source directory.

Quickstart

If you are not familiar with using endpoints or endpoint strings, read the Twisted endpoints documentation.

Using endpoint classes

To connect to an I2P site:

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)

To have a server listen on an I2P Destination:

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)

Using endpoint strings

Requires Twisted 14.0 or greater.

To connect to an I2P site:

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

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

To have a server listen on an I2P Destination:

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

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

To connect using a specific API:

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

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

To connect using a non-standard API host or port:

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)

Endpoint strings

The Twisted plugin for clientFromString() and serverFromString() will only work for Twisted 14.0 or greater.

Both client and server strings support the following keyword arguments:

  • api=<apiName> - Either SAM or BOB.

  • apiEndpoint=<endpointString> - An escaped client endpoint string pointing to the API, e.g. tcp\:127.0.0.1\:2827.

  • options=keyOne\:valueOne,keyTwo\:valueTwo - I2CP options as a comma-separated key:value list. See the I2CP specification for available options.

Clients

Client string format:

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

Supported arguments:

SAM

  • nickname

  • autoClose

  • keyfile

  • localPort

  • sigType

BOB

  • tunnelNick

  • inhost

  • inport

Servers

Server string format:

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

Supported arguments:

SAM

  • nickname

  • autoClose

  • sigType

BOB

  • tunnelNick

  • outhost

  • outport

Important changes

0.3.2

  • The default signature type for new Destinations is Ed25519.

    • If the SAM server does not support that (Java I2P 0.9.16 and earlier), txi2p will fall back on ECDSA_SHA256_P256, followed by the old default DSA_SHA1.

0.3

  • Ports are now supported on the SAM API.

    • Previous port options are no longer ignored.

    • New localPort option for setting the client’s local port.

  • The SAMI2PStreamServerEndpoint API has changed to no longer require a reactor.

Documentation

API documentation is available at https://txi2p.readthedocs.org

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

txi2p-tahoe-0.3.5.tar.gz (37.4 kB view details)

Uploaded Source

Built Distribution

txi2p_tahoe-0.3.5-py2.py3-none-any.whl (44.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file txi2p-tahoe-0.3.5.tar.gz.

File metadata

  • Download URL: txi2p-tahoe-0.3.5.tar.gz
  • Upload date:
  • Size: 37.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.48.1 CPython/3.9.1

File hashes

Hashes for txi2p-tahoe-0.3.5.tar.gz
Algorithm Hash digest
SHA256 c110a320aff1a8371966bd72cdc98e6cf071a02f5abffd0dea346bf807a57def
MD5 31f3e107e998df9287fd7d6e17ffd5da
BLAKE2b-256 f8b6b0192e7c5f5b99346dac04b745ddd7f1cb09ca7aa2e6de3804ff09b66046

See more details on using hashes here.

File details

Details for the file txi2p_tahoe-0.3.5-py2.py3-none-any.whl.

File metadata

  • Download URL: txi2p_tahoe-0.3.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 44.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.48.1 CPython/3.9.1

File hashes

Hashes for txi2p_tahoe-0.3.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 143fe2954ea30c055b43752848c96154b42c12d3a92dd4f94aa98fa3b515457f
MD5 90d5baa83c4bd24c691cb64a590f2b87
BLAKE2b-256 20b3cc7fa67148cea836d8be8e7738786e8f07cd1866b185bb0b93e1e802920c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page