Skip to main content

philiprehberger-net-scanner

Tests PyPI version Last updated

LAN device discovery and TCP port scanning.

Installation

pip install philiprehberger-net-scanner

Usage

Network Discovery

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

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])

Single port check

from philiprehberger_net_scanner import is_port_open

if is_port_open("example.com", 443, timeout=1.0):
    print("HTTPS is reachable")

Async Port Scanning

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

Function / Class Description
scan_network(cidr, timeout=1.0, max_workers=64, resolve_hostnames=True) Discover devices on a network using TCP connect probes
scan_ports(host, ports="common", timeout=1.0, max_workers=128) Scan TCP ports on a host ("common", range, or list[int])
async_scan_ports(host, ports="common", timeout=1.0, concurrency=128) Asyncio-based version of scan_ports
is_port_open(host, port, timeout=1.0) One-off boolean check for a single TCP port
Device Discovered host: ip, hostname, mac, response_time_ms
PortResult Scan result: number, state ("open"/"closed"/"filtered"), service

Development

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

Support

If you find this project useful:

⭐ Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License

MIT

Release files for philiprehberger-net-scanner 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for philiprehberger-net-scanner 0.2.0
File Size Uploaded
philiprehberger_net_scanner-0.2.0.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for philiprehberger-net-scanner 0.2.0
File Interpreter ABI Platform
philiprehberger_net_scanner-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.8 kB

Release files / philiprehberger_net_scanner-0.2.0.tar.gz

Download URL philiprehberger_net_scanner-0.2.0.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c732012733e7b9fa902efad5ead7cd8bcefb9de41a75d248df871cf67e6cc8f1
BLAKE2b-256 checksum
How to use checksums
a17eab4462efb310073376ae3ac5381f2e1fd862c25c06031a374eab52899ef5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / philiprehberger_net_scanner-0.2.0-py3-none-any.whl

Download URL philiprehberger_net_scanner-0.2.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
881a6a2e88d0dcb7caa4856c57e704f03d9ed140b90fca8f5e13cbd20f564d64
BLAKE2b-256 checksum
How to use checksums
0ad6a817d0a38c48675fa161e2839aed9d2c4eb8e8017ffa314e09ef801d013f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page