Skip to main content

Python library for gateways, networks, and devices.

Project description

gatenet ๐Ÿ›ฐ๏ธ

PyPI

Static Badge Changelog

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.

CI codecov

๐Ÿ”— Resources

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
Email 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


Built with โค๏ธ for the networking community

Documentation License

Coverage

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gatenet-0.12.1.tar.gz (58.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gatenet-0.12.1-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

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

Hashes for gatenet-0.12.1.tar.gz
Algorithm Hash digest
SHA256 921feee2dddcab330b1fd7cfb4aa145b79d5a667f5e8104615b44c104329e7b0
MD5 98e0dc32aeb9522b60e5200316f76edc
BLAKE2b-256 87b0b129e02d166b9d005f9c35113a56c5e16ca97529864e9b12c97df6e99acb

See more details on using hashes here.

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

Hashes for gatenet-0.12.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3a203835010196a2d7b16fdfcc9b85552c8ceb4d7b1a73013022481a6ab614df
MD5 bf9206cb76423809a1807317407146be
BLAKE2b-256 3b59602bc879e1d3f0baf530f5166448199035b1df2cce71be0d846db05e39e2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page