Metadata-Version: 2.4
Name: mytunnelSDK
Version: 1.2.0
Summary: A Python SDK for ...
Author-email: Bhargav Barman <bhargavbprd@gmail.com>
License: Custom
Keywords: sdk,api
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.31.0
Requires-Dist: httpx>=0.24.0
Requires-Dist: websocket-client>=1.6.0
Requires-Dist: python-dotenv>=1.0.0
Dynamic: license-file

# Tunnel SDK

This is the production-ready Python SDK for the Tunnel Gateway. It allows you to establish secure WebSocket tunnels and seamlessly proxy HTTP traffic to your local development server.

## Features

* **Thread-safe**: Runs in the background without blocking your main application loop. No `asyncio` required!
* **Header Authentication**: Secures your API key in HTTP headers (`Authorization: Bearer`), preventing exposure in URL logs.
* **Payload Compression**: Transparent zlib compression for data exchange over WebSocket, boosting bandwidth efficiency and speed.
* **Connection Pooling**: Optimized HTTP connection pooling with keep-alive limits for high-concurrency dispatching.
* **Automated Reconnection**: Built-in exponential backoff means you don't have to manually manage network hiccups.
* **Smart Streaming**: Automatically switches to chunked streaming for large files, keeping memory overhead low.
* **Context Manager**: Start and stop the tunnel cleanly using `with Tunnel.from_env() as tunnel:`.
* **Events API**: Listen to hooks like `on_connect`, `on_disconnect`, and `on_error`.

## Quick Start

Create a `.env` file in your root folder:
```env
TUNNEL_API_KEY=your-secret-key
TUNNEL_TARGET_PATH=/api
TUNNEL_PORT=5000
```

Run the tunnel:
```python
from tunnel_sdk import Tunnel

with Tunnel.from_env() as tunnel:
    # This blocks until interrupted!
    tunnel.wait()
```

When connected, you'll see a success message like:
```
============================================================
TUNNEL CONNECTED SUCCESSFULLY!
Public URL : https://your-gateway.com/api
Forwarding to : http://127.0.0.1:5000
============================================================
```

## SDK Information

The SDK provides an API to access current connection statistics and configuration info:

```python
from tunnel_sdk import Tunnel

with Tunnel.from_env() as tunnel:
    # Print SDK info as a dictionary
    print(tunnel.sd.info())
    
    tunnel.wait()
```

The dictionary returned by `tunnel.sd.info()` contains information like:
* `sdk_version`: The SDK version.
* `protocol_version`: The protocol version.
* `is_connected`: Whether the tunnel is currently connected.
* `uptime`: The time in seconds the tunnel has been running.
* `reconnect_count`: The number of times the tunnel has reconnected.
* `statistics`: A dictionary containing stats like requests handled, bytes uploaded/downloaded, and active requests.

## Structure

* `client.py` - The main `Tunnel` interface.
* `connection.py` - WebSocket loop and reconnect logic.
* `dispatcher.py` - HTTP request proxying via `httpx`.
* `protocol.py` - Data structures and base64 encoders.
* `config.py` - Environment loader.

For full API reference, see `docs/sdk_reference.md` in the project root.
