Skip to main content

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/)[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 forward but runs in a blocking synchronous context.
  • Useful for scripts that do not use asyncio natively.

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


Download files

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

Source Distribution

outray-0.0.2.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

outray-0.0.2-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file outray-0.0.2.tar.gz.

File metadata

  • Download URL: outray-0.0.2.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

Hashes for outray-0.0.2.tar.gz
Algorithm Hash digest
SHA256 77dca8cf05ecd51736fa8f220b497d3f07717c4483e03d712f467f9771159aaa
MD5 1044e0c6822d8517ce91a986b3d30478
BLAKE2b-256 b212b6c28f9c7d92f6a12ccc4db4fc95657ef251e84f8801b91cf4b04562290e

See more details on using hashes here.

File details

Details for the file outray-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: outray-0.0.2-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

Hashes for outray-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a9604581eee21a0ee37f3d5775ff19d4416c0ac5933b6d1d4d96cfcbf4898658
MD5 66030131982b175d404ea57ffae08489
BLAKE2b-256 edd8bc629667a46f6a08a19ab68360e786730453ef3bd54941bfbff9218edf83

See more details on using hashes here.

Supported by

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