i2plib
i2plib is a modern asynchronous library for building I2P applications.
Installing
pip install i2plib
Requirements:
Python version >= 3.5
I2P router with SAM API enabled
Connecting to a remote I2P destination
import asyncio
import i2plib
async def connect_test(destination):
session_name = "test-connect"
# create a SAM stream session
await i2plib.create_session(session_name)
# connect to a destination
reader, writer = await i2plib.stream_connect(session_name, destination)
# write data to a socket
writer.write(b"PING")
# asynchronously receive data
data = await reader.read(4096)
print(data.decode())
# close the connection
writer.close()
# run event loop
loop = asyncio.get_event_loop()
loop.run_until_complete(connect_test("dummy.i2p"))
loop.stop()
Accept connections in I2P
import asyncio
import i2plib
async def accept_test():
session_name = "test-accept"
# create a SAM stream session
await i2plib.create_session(session_name)
# accept a connection
reader, writer = await i2plib.stream_accept(session_name)
# first string on a client connection always contains clients I2P destination
dest = await reader.readline()
remote_destination = i2plib.Destination(dest.decode().strip())
# read for the actual incoming data from the client
data = await reader.read(4096)
print(data.decode())
# send data back
writer.write(b"PONG")
# close the connection
writer.close()
# run event loop
loop = asyncio.get_event_loop()
loop.run_until_complete(accept_test())
loop.stop()
Server tunnel
Expose a local service to I2P like that:
import asyncio
import i2plib
loop = asyncio.get_event_loop()
# making your local web server available in the I2P network
tunnel = i2plib.ServerTunnel(("127.0.0.1", 80))
asyncio.ensure_future(tunnel.run())
try:
loop.run_forever()
except KeyboardInterrupt:
pass
finally:
loop.close()
Client tunnel
Bind a remote I2P destination to a port on your local host:
import asyncio
import i2plib
loop = asyncio.get_event_loop()
# bind irc.echelon.i2p to 127.0.0.1:6669
tunnel = i2plib.ClientTunnel("irc.echelon.i2p", ("127.0.0.1", 6669))
asyncio.ensure_future(tunnel.run())
try:
loop.run_forever()
except KeyboardInterrupt:
pass
finally:
loop.close()
More examples
You can see more demo applications in docs/examples directory of the source repository.
Resources
Aknowledgments
Metadata
Release files for i2plib 0.0.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| i2plib-0.0.14.tar.gz | 14.6 kB | Without provenance | Details for i2plib-0.0.14.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| i2plib-0.0.14-py3-none-any.whl | Python 3 | none | any | Details for i2plib-0.0.14-py3-none-any.whl |
Total release size: 25.5 kB
Release files / i2plib-0.0.14.tar.gz
| Download URL | i2plib-0.0.14.tar.gz |
|---|---|
| Size | 14.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68ea06cec53759e462ad4ee8c74f1fed5f39c1c3a3fbbbd83bf1ed2ef85d657a
|
|
BLAKE2b-256 checksum How to use checksums |
93196d70d9c0352ea1e88fd988ca3d11325d235503eec9b90a2a9cf85c2e137b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5
|
Release files / i2plib-0.0.14-py3-none-any.whl
| Download URL | i2plib-0.0.14-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
98147edda01196b8b0cec1414f1a53b08f87564bfeea652dd47339711b51c13b
|
|
BLAKE2b-256 checksum How to use checksums |
de2b42ff78fd80062fada1344fe5a5a58d3bd308c571a9a9ccb9592a423a1239
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5
|
Security for i2plib 0.0.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.