Python library for gateways, networks, and devices.
Project description
gatenet ๐ฐ๏ธ
Gatenet is a comprehensive Python networking toolkit for diagnostics, service discovery, hotspot management, mesh networking, and building robust microservices with TCP/UDP/HTTP and radio capabilities.
๐ Resources
- ๐ Documentation - Complete guides and API reference
- ๐ฎ Interactive Sandbox - Try Gatenet in your browser
- ๐ Changelog - Latest features and updates
- โก Quick Start
- ๐ Core Features
- ๐ป Code Examples
- ๐ก Hotspot Management
- ๐ Service Discovery
- ๐งช Testing & Development
Perfect for network engineers, security researchers, IoT developers, and anyone building network-aware applications.
๐ฆ Installation
pip install gatenet
Requirements: Python 3+ โข Cross-platform (Linux, macOS, Windows)
๐ Core Features
๐ง Network Diagnostics
- Smart Ping: ICMP and TCP ping with jitter analysis and packet loss statistics
- Advanced Traceroute: Multi-protocol route tracing with hop-by-hop analysis
- Bandwidth Testing: Real-time upload/download speed measurement
- Port Scanner: Fast async port scanning with service detection
- DNS Tools: Forward/reverse lookups with comprehensive error handling
- Geo Location: IP geolocation with ISP and organization data
๐ก Hotspot Management (v0.12.0)
- Cross-Platform AP Creation: Linux (hostapd) and macOS (Internet Sharing) support
- Advanced Security: WPA2, WPA3, WEP, and open network configurations
- DHCP Integration: Automatic IP assignment with configurable ranges
- Device Monitoring: Real-time connected device tracking
- Password Management: Secure password generation with complexity validation
๐ Microservice Framework
- Production HTTP Servers: FastAPI-based with automatic JSON handling
- Robust TCP/UDP: Connection pooling, timeouts, and retry logic
- Full Async Support: Native asyncio integration for high-performance apps
- Middleware System: Extensible request/response processing
- Health Monitoring: Built-in health checks and metrics collection
๐ฐ๏ธ Advanced Networking
- Mesh Networks: Self-healing topology with encrypted communication
- Radio Integration: LoRa, ESP, and SDR hardware support
- GPS Tracking: Location-aware network operations
- Protocol Extension: Plugin architecture for custom protocols
โก Quick Start
๐ HTTP Microservice
from gatenet.http_.server import HTTPServer
app = HTTPServer(host="0.0.0.0", port=8080)
@app.route("/api/health", method="GET")
def health_check(request):
return {"status": "healthy", "service": "gatenet-api"}
@app.route("/api/ping", method="POST")
def ping_service(request):
from gatenet.diagnostics.ping import ping
host = request.json.get("host", "8.8.8.8")
result = ping(host, count=3)
return {"host": host, "result": result}
if __name__ == "__main__":
app.serve() # Production-ready server
๐ก Hotspot Creation
from gatenet.hotspot import Hotspot, SecurityConfig
# Create a secure WPA2 hotspot
security = SecurityConfig(
security_type="WPA2",
password="MySecureNetwork123!" # Or auto-generate
)
hotspot = Hotspot(
ssid="GatenetAP",
interface="wlan0", # Linux: wlan0, macOS: en0
security=security
)
# Start the access point
if hotspot.start():
print(f"Hotspot '{hotspot.ssid}' is running!")
print(f"Connected devices: {hotspot.get_connected_devices()}")
# Stop when done
# hotspot.stop()
๐ Smart Service Discovery
from gatenet.discovery.ssh import _identify_service
from gatenet.discovery.service_discovery import ServiceDiscovery
# Quick service identification
service = _identify_service(22, "SSH-2.0-OpenSSH_8.9p1")
print(f"Detected: {service}") # "OpenSSH 8.9p1"
# Advanced discovery with multiple detectors
discovery = ServiceDiscovery()
discovery.add_detector("http").add_detector("ssh").add_detector("ftp")
result = discovery.identify_service(80, "nginx/1.18.0 (Ubuntu)")
print(f"Service: {result}") # "Nginx Web Server"
๐ฐ๏ธ Network Diagnostics
from gatenet.diagnostics import ping, traceroute, scan_ports
# Advanced ping with statistics
result = ping("google.com", count=5, timeout=3)
print(f"Average RTT: {result['avg_rtt']}ms")
print(f"Packet Loss: {result['packet_loss']}%")
print(f"Jitter: {result['jitter']}ms")
# Traceroute with hop analysis
hops = traceroute("github.com", max_hops=15)
for i, hop in enumerate(hops, 1):
print(f"Hop {i}: {hop['ip']} ({hop['hostname']}) - {hop['rtt']}ms")
# Fast async port scanning
open_ports = scan_ports("192.168.1.1", [22, 80, 443, 8080])
print(f"Open ports: {open_ports}")
๐ป Code Examples
๐ง Async TCP Client
import asyncio
from gatenet.client.tcp import AsyncTCPClient
async def tcp_example():
client = AsyncTCPClient("127.0.0.1", 8080, timeout=10)
try:
await client.connect()
response = await client.send("Hello Server!")
print(f"Server response: {response}")
except Exception as e:
print(f"Connection failed: {e}")
finally:
await client.close()
asyncio.run(tcp_example())
๐ Production HTTP Client
from gatenet.http_.client import HTTPClient
# RESTful API client with automatic retry
client = HTTPClient(
base_url="https://api.example.com",
timeout=30,
retries=3
)
# GET with custom headers
response = client.get("/users/123", headers={
"Authorization": "Bearer token123",
"User-Agent": "Gatenet/1.0"
})
# POST with JSON payload
user_data = {"name": "Alice", "email": "alice@example.com"}
response = client.post("/users", json=user_data)
print(f"Status: {response['status']}")
print(f"Data: {response['data']}")
๐ก Advanced Hotspot Configuration
from gatenet.hotspot import Hotspot, SecurityConfig, DHCPServer
# Enterprise-grade hotspot setup
security = SecurityConfig.generate_secure_config(
security_type="WPA3",
password_length=16 # Auto-generated secure password
)
dhcp = DHCPServer(
interface="wlan0",
ip_range="192.168.100.10-192.168.100.100",
gateway="192.168.100.1",
dns_servers=["8.8.8.8", "1.1.1.1"]
)
hotspot = Hotspot(
ssid="Enterprise-WiFi",
interface="wlan0",
security=security,
dhcp_server=dhcp,
channel=6,
hidden=False
)
# Monitor hotspot status
if hotspot.start():
while hotspot.is_running():
devices = hotspot.get_connected_devices()
print(f"Active connections: {len(devices)}")
for device in devices:
print(f" {device['mac']} -> {device['ip']} ({device['hostname']})")
time.sleep(30) # Update every 30 seconds
๐ก Hotspot Management
Gatenet provides enterprise-grade Wi-Fi access point management with cross-platform support:
โจ Key Features
- ๐ Multiple Security Types: WPA3, WPA2, WEP, and Open networks
- ๐ Cross-Platform: Native Linux (hostapd) and macOS (Internet Sharing) support
- ๐ง DHCP Integration: Automatic IP assignment with custom ranges and DNS
- ๐ Real-Time Monitoring: Live device tracking and connection statistics
- ๐ Password Management: Secure generation with complexity validation
- โ๏ธ Advanced Configuration: Channel selection, broadcast control, bandwidth limits
๐ Quick Setup
from gatenet.hotspot import Hotspot
# Minimal setup - auto-configured for your platform
hotspot = Hotspot(ssid="MyNetwork", password="SecurePass123!")
hotspot.start()
๐ Service Discovery
Intelligent service identification using multiple detection strategies:
๐ฏ Detection Methods
- Banner Analysis: Deep packet inspection of service banners
- Port Mapping: Well-known port to service correlation
- Keyword Detection: Flexible pattern matching
- Custom Detectors: Extensible plugin architecture
๐ ๏ธ Supported Services
| Protocol | Services | Detection Method |
|---|---|---|
| SSH | OpenSSH, Dropbear, PuTTY | Banner parsing |
| HTTP | Apache, Nginx, IIS, Tomcat | Server headers |
| FTP | vsftpd, ProFTPD, FileZilla | Welcome messages |
| Postfix, Exchange, Dovecot | SMTP/IMAP banners | |
| Database | MySQL, PostgreSQL, MongoDB | Connection strings |
| Custom | Your services | Plugin detectors |
๐ง Custom Detector Example
from gatenet.service_detectors import ServiceDetector
class DockerDetector(ServiceDetector):
"""Detect Docker daemon on port 2376."""
def detect(self, port: int, banner: str) -> str:
if port == 2376 and "docker" in banner.lower():
return "Docker Daemon"
return None
# Register and use
discovery = ServiceDiscovery()
discovery.add_detector(DockerDetector())
๐งช Testing & Development
๐ฏ Comprehensive Test Suite
# Run all tests
pytest
# Test specific modules
pytest src/tests/hotspot/
pytest src/tests/diagnostics/
# Generate coverage report
pytest --cov=gatenet --cov-report=html
๐ ๏ธ Development Tools
# Install development dependencies
pip install -e ".[dev]"
# Code formatting
black src/ tests/
isort src/ tests/
# Type checking
mypy src/
# Documentation
make -C docs html
Interactive Development
- Try in Browser - No installation required
- Web Dashboard - Visual interface for all tools
- CLI Interface - Command-line access to all features
๐ Resources
- ๐ API Reference
- ๐ Changelog
- ๐ Code of Conduct
- ๐ค Contributing
- ๐ก๏ธ Security
- ๐ License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gatenet-0.12.1.tar.gz.
File metadata
- Download URL: gatenet-0.12.1.tar.gz
- Upload date:
- Size: 58.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
921feee2dddcab330b1fd7cfb4aa145b79d5a667f5e8104615b44c104329e7b0
|
|
| MD5 |
98e0dc32aeb9522b60e5200316f76edc
|
|
| BLAKE2b-256 |
87b0b129e02d166b9d005f9c35113a56c5e16ca97529864e9b12c97df6e99acb
|
File details
Details for the file gatenet-0.12.1-py3-none-any.whl.
File metadata
- Download URL: gatenet-0.12.1-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a203835010196a2d7b16fdfcc9b85552c8ceb4d7b1a73013022481a6ab614df
|
|
| MD5 |
bf9206cb76423809a1807317407146be
|
|
| BLAKE2b-256 |
3b59602bc879e1d3f0baf530f5166448199035b1df2cce71be0d846db05e39e2
|