Metadata-Version: 2.4
Name: auto-portforward
Version: 0.1.0
Summary: Monitor for local or remote opened ports
Author: soraxas
License: MIT License
        
        Copyright (c) 2025, soraxas
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: textual==3.2.0
Provides-Extra: dev
Requires-Dist: build; extra == "dev"
Requires-Dist: dapperdata; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: pytest-pretty; extra == "dev"
Requires-Dist: ruamel.yaml; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: toml-sort; extra == "dev"
Dynamic: license-file

# auto portforward

<div align="center">
  <img src="https://raw.githubusercontent.com/soraxas/auto-portforward/refs/heads/master/assets/screenshot.png" alt="auto-portforward">
</div>

## Overview

**auto-portforward** is a Python-based TUI application for monitoring processes and managing port forwarding on local or remote (SSH) machines. It provides a real-time, interactive process tree and can automatically set up SSH reverse port forwarding for processes listening on specific ports.

## Features

- TUI interface
- Monitor processes and their listening ports on local or remote (SSH)
- Automatic SSH reverse port forwarding for selected ports
- Works with or without [psutil](https://pypi.org/project/psutil/) (falls back to lsof/ps)
- Handles sudo password for privileged commands
- Clean resource management (no zombie processes, robust cleanup)

## Installation

```sh
pipx install auto-portforward
```

## Usage

Run the TUI application with:

```sh
auto-portforward [options] [ssh_host]
```

### CLI Options

- `-l`, `--local` : Use the local process monitor
- `--mock`        : Use a mock process monitor (for testing)
- `[ssh_host]`    : SSH host to connect to

Examples:

- Monitor local machine:
  ```sh
  python -m auto_portforward.cli --local
  ```
- Monitor a remote host via SSH:
  ```sh
  python -m auto_portforward.cli myuser@myhost
  ```

### Sudo Password Handling

Some features (like listing all listening ports) may require sudo privileges.

- **Environment variable:**
  ```sh
  export AP_SUDO_PASSWORD=yourpassword
  auto-portforward my@host
  ```

