RingLinkRingLink
Python

Expose python services to RingLink

RingLink Python SDK is a library that allows you to embed RingLink mesh network capabilities into your Python applications. You can programmatically connect to your RingLink network, for example, to access other devices on the network or to publish local services to the RingLink network.

The RingLink SDK is built on a user-space TCP/IP stack, developers do not need to modify system network settings or require elevated privileges. This makes it flexible to connect to an existing RingLink network.

The current RingLink Python SDK is in the alpha stage. Its features are incomplete and the API may change.

Features

  • IPv4
  • IPv6 (In Tunnel)
  • Incoming TCP proxy
  • TCP server and client
  • UDP

Getting Started

Using the RingLink SDK in Python is very easy, just install the ringlink package.

pip install ringlink

Requirements

Before using the RingLink Python SDK, please ensure you meet the following requirements:

  • Python 3.9 or above
  • A Config Key

Example

Publish a local service to the RingLink network via proxy:

import asyncio
from ringlink import auto
 
async def main():
    stack = await auto("53cd98d2", "<your-config-key>")
    with stack.tcp_proxy("0.0.0.0:80", "127.0.0.1:8000"):
        # run your server here, typically a web server run forever
        pass
 
 
asyncio.run(main())

In this code, a RingLink instance is first created using the auto function, passing your config key and network ID. Then, RingLink.tcp_proxy is used to create a proxy tunnel. The first parameter is the local address and port to listen on (usually 0.0.0.0), and the second is the address and port of the service to be published.

When this code runs, RingLink automatically creates a TCP proxy tunnel. Other devices on the current RingLink network accessing <private-ip>:80 will be forwarded to the local 127.0.0.1:8000.

On this page