Metadata-Version: 2.4
Name: pyrevproxy
Version: 1.0.0
Summary: Asynchronous TCP Reverse Proxy
Author-email: xffc <xffc.sk@gmail.com>
License-Expression: MIT
Classifier: Programming Language :: Python :: 3.8
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# pyrevproxy

Asynchronous TCP reverse proxy written in Python, built on `asyncio`. It listens on a local port and forwards all traffic to a remote host/port, piping data in both directions.

## Features

- Asynchronous, non-blocking TCP forwarding using `asyncio.start_server`
- Configurable listen port (defaults to the remote port if not set)
- Configurable chunk size for data transfer
- Simple CLI with timestamped logging

## Requirements

- Python >= 3.8 (untested on older versions)

## Installation

### From PyPI
 
```bash
pip install pyrevproxy
```
 
### From source
 
Clone the repository and install it with `pip`:
 
```bash
git clone https://github.com/xffc/pyrevproxy
cd pyrevproxy
pip install .
```

## Usage

```bash
pyrevproxy [host] [port] [-l LISTEN] [-s SIZE]
```

### Arguments

| Argument | Description |
|------------------|-------------------------------------------------------------------|
| `host`           | Remote host to connect to                                         |
| `port`           | Remote port to connect to                                         |
| `-l`, `--listen` | Local port to listen on (defaults to `port` if omitted)           |
| `-s`, `--size`   | Maximum chunk size in bytes for each read/write (default: `4096`) |

### Examples

Forward local port 8080 to `example.com:80`:

```bash
pyrevproxy example.com 80 --listen 8080
```

Listen and connect on the same port (e.g. proxy port 443 to a remote host on 443):

```bash
pyrevproxy example.com 443
```

Use a larger chunk size for higher-throughput connections:

```bash
pyrevproxy example.com 80 --listen 8080 --size 65536
```

## Running without installing

You can also run the module directly from source:

```bash
python -m pyrevproxy example.com 80 --listen 8080
```

## How it works

For each incoming client connection, `pyrevproxy` opens a new connection to the configured remote host/port and starts two concurrent pipes:

- client → remote
- remote → client

Each pipe reads data in chunks (`--size` bytes at a time) and writes it to the other side until either end closes the connection or an error occurs. Connection and disconnection events are logged with timestamps.

## License

[MIT](LICENSE)
