Metadata-Version: 2.4
Name: philiprehberger-net-scanner
Version: 0.1.6
Summary: LAN device discovery and TCP port scanning
Project-URL: Homepage, https://github.com/philiprehberger/py-net-scanner#readme
Project-URL: Repository, https://github.com/philiprehberger/py-net-scanner
Project-URL: Issues, https://github.com/philiprehberger/py-net-scanner/issues
Project-URL: Changelog, https://github.com/philiprehberger/py-net-scanner/blob/main/CHANGELOG.md
Author: Philip Rehberger
License-Expression: MIT
License-File: LICENSE
Keywords: discovery,network,port,scanner,security
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# philiprehberger-net-scanner

[![Tests](https://github.com/philiprehberger/py-net-scanner/actions/workflows/publish.yml/badge.svg)](https://github.com/philiprehberger/py-net-scanner/actions/workflows/publish.yml)
[![PyPI version](https://img.shields.io/pypi/v/philiprehberger-net-scanner.svg)](https://pypi.org/project/philiprehberger-net-scanner/)
[![License](https://img.shields.io/github/license/philiprehberger/py-net-scanner)](LICENSE)

LAN device discovery and TCP port scanning.

## Installation

```bash
pip install philiprehberger-net-scanner
```

## Usage

### Network Discovery

```python
from philiprehberger_net_scanner import scan_network

devices = scan_network("192.168.1.0/24", timeout=2.0)
for device in devices:
    print(f"{device.ip} - {device.hostname or 'unknown'} ({device.response_time_ms:.1f}ms)")
```

### Port Scanning

```python
from philiprehberger_net_scanner import scan_ports

# Scan common ports
ports = scan_ports("192.168.1.1", ports="common")
for port in ports:
    print(f"Port {port.number}: {port.state} ({port.service})")

# Scan specific range
ports = scan_ports("192.168.1.1", ports=range(1, 1024), timeout=0.5)

# Scan specific ports
ports = scan_ports("192.168.1.1", ports=[22, 80, 443, 3306, 5432])
```

### Async Port Scanning

```python
import asyncio
from philiprehberger_net_scanner import async_scan_ports

ports = asyncio.run(async_scan_ports("192.168.1.1", ports=range(1, 65536), timeout=0.5))
```

## API

### `scan_network(cidr, timeout?, max_workers?, resolve_hostnames?) -> list[Device]`

Discover devices on a network using TCP connect probes.

### `scan_ports(host, ports?, timeout?, max_workers?) -> list[PortResult]`

Scan TCP ports on a host. `ports` can be `"common"`, a `range`, or a `list[int]`.

### `async_scan_ports(host, ports?, timeout?, concurrency?) -> list[PortResult]`

Async version using asyncio for high-performance scanning.


## Development

```bash
pip install -e .
python -m pytest tests/ -v
```

## License

MIT
