All Projects → l-n-s → i2plib

l-n-s / i2plib

Licence: MIT License
🐍 i2plib: A modern asynchronous library for building I2P applications

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to i2plib

snekcord
A work-in-progress Discord API wrapper written in Python.
Stars: ✭ 15 (-34.78%)
Mutual labels:  asyncio
distex
Distributed process pool for Python
Stars: ✭ 101 (+339.13%)
Mutual labels:  asyncio
nardis
A small web framework based on ASGI
Stars: ✭ 14 (-39.13%)
Mutual labels:  asyncio
i2psam
C++ SAMv3 library
Stars: ✭ 27 (+17.39%)
Mutual labels:  i2p
fastapi-users
Ready-to-use and customizable users management for FastAPI
Stars: ✭ 1,920 (+8247.83%)
Mutual labels:  asyncio
aioaria2
An async/await wrapper around aria2-json-rpc with websocket support
Stars: ✭ 20 (-13.04%)
Mutual labels:  asyncio
aioppspp
IETF PPSP RFC7574 in Python/asyncio
Stars: ✭ 21 (-8.7%)
Mutual labels:  asyncio
aiounittest
Test python asyncio-based code with ease.
Stars: ✭ 53 (+130.43%)
Mutual labels:  asyncio
idataapi-transform
Full async support toolkit for IDataAPI for efficiency work, read data from API/ES/csv/xlsx/json/redis/mysql/mongo/kafka, write to ES/csv/xlsx/json/redis/mysql/mongo/kafka, provide CLI and python API
Stars: ✭ 36 (+56.52%)
Mutual labels:  asyncio
aiorwlock
Read/Write Lock - synchronization primitive for asyncio
Stars: ✭ 90 (+291.3%)
Mutual labels:  asyncio
mqttools
MQTT version 5.0 client and broker using asyncio
Stars: ✭ 44 (+91.3%)
Mutual labels:  asyncio
memoize
Caching library for asynchronous Python applications.
Stars: ✭ 53 (+130.43%)
Mutual labels:  asyncio
trualias
Mentally computable verification codes for email aliases implemented as a postfix tcp table or milter; uses asyncio.
Stars: ✭ 33 (+43.48%)
Mutual labels:  asyncio
asynchronous
A D port of Python's asyncio library
Stars: ✭ 35 (+52.17%)
Mutual labels:  asyncio
py17track
📦 A simple API to track package info from 17track.com
Stars: ✭ 20 (-13.04%)
Mutual labels:  asyncio
glQiwiApi
The ultrarapid and multifunctional wrapper over QIWI and YooMoney
Stars: ✭ 44 (+91.3%)
Mutual labels:  asyncio
website
PySlackers website for invites and learning resources
Stars: ✭ 61 (+165.22%)
Mutual labels:  asyncio
python-insteonplm
Python 3 asyncio module for interfacing with Insteon Powerline modems
Stars: ✭ 34 (+47.83%)
Mutual labels:  asyncio
aioprometheus
A Prometheus Python client library for asyncio-based applications
Stars: ✭ 114 (+395.65%)
Mutual labels:  asyncio
asyncqlio
A fully async ORM for Python 3.5+
Stars: ✭ 25 (+8.7%)
Mutual labels:  asyncio

i2plib

https://travis-ci.com/l-n-s/i2plib.svg?branch=master Latest Read The Docs https://codecov.io/github/l-n-s/i2plib/coverage.svg?branch=master

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].