Python SDK for outray.dev tunneling service
Project description
Outray
outray is a Python library for creating HTTP, TCP, and UDP tunnels using https://outray.dev/. It allows you to forward local services to a remote endpoint easily.
Install via pip:
pip install outray
Features
- HTTP tunnel proxy (
HttpListener) - TCP tunnel proxy (
TCPListener) - UDP tunnel proxy (
UDPListener) - Forward a tunnel asynchronously or synchronously
- Built-in error handling and logging
Usage Example
- Asynchronous
import asyncio
from outray import forward, http
async def main():
listener = http("http://localhost:8080")
await forward(listener)
asyncio.run(main())
- Synchronous
import asyncio
from outray import forward, http
listener = http("http://localhost:8080")
forward_sync(listener)
API
## Environment Variables
Outray supports configuration via environment variables. These are optional but recommended.
### `OUTRAY_API_KEY`
Your API key used to authenticate tunnel connections.
```bash
export OUTRAY_API_KEY=your_api_key_here
If not provided explicitly, forward and forward_sync will automatically read this value from the environment.
Equivalent code usage:
await forward(l1)
await forward(l1, api_key="API_KEY")
OUTRAY_API_URI
The WebSocket endpoint used to establish tunnels.
export OUTRAY_API_URI=wss://api.outray.app
If not provided explicitly, this value is also read from the environment.
Equivalent code usage:
await forward(l1, api_key="API_KEY", ws_url="API_URL")
Creating a Listener
TCP
from outray import tcp
listener = tcp(local_host="localhost", local_port=8090, remote_port=20710)
UDP
from outray import udp
listener = udp(local_host="localhost", local_port=9000, remote_port=30710)
HTTP
from outray import http
listener = http(url="http://localhost:8080", subdomain="my-subdomain")
Forwarding a Tunnel
Asynchronous (forward)
from outray import forward
import asyncio
asyncio.run(forward(listener))
forward(listener, ws_url=None, force_takeover=None, ping_interval=20, ping_timeout=20, api_key=None)- Forwards the listener to the remote WebSocket tunnel.
- Handles reconnects automatically.
Synchronous (forward_sync)
from outray import forward_sync
forward_sync(listener)
- Same as
forwardbut runs in a blocking synchronous context. - Useful for scripts that do not use
asyncionatively.
Logging
outray uses the standard Python logging module. To see detailed tunnel events:
import logging
logger = logging.getLogger("outray")
logger.setLevel(logging.DEBUG)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file outray-0.0.3.tar.gz.
File metadata
- Download URL: outray-0.0.3.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23d4173ae09d0c20dbe46c2e3e676eedf76fb25a8673b299a34487f76355fc91
|
|
| MD5 |
df668c4bc07160dfc0e65a00dd071de4
|
|
| BLAKE2b-256 |
eb738de713dad20c90023ca966f3941e1797567aa3c79261cb29985db9325411
|
File details
Details for the file outray-0.0.3-py3-none-any.whl.
File metadata
- Download URL: outray-0.0.3-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d93660a5801bc31369c0c8ea3bb5cb56f41a4ec573cdc064c1203078cfa5a87
|
|
| MD5 |
7f2645aa3d09aea3c60a3eed5b973fe6
|
|
| BLAKE2b-256 |
3bc19795375c5d085695b7a3e5dd690b3b8f53e558378608b7eb01cbc210e5f3
|