gatenet.hotspot package

Submodules

gatenet.hotspot.backend module

class gatenet.hotspot.backend.BackendResult(ok, message='')[source]

Bases: object

message: str = ''
ok: bool
class gatenet.hotspot.backend.HotspotBackend[source]

Bases: ABC

abstractmethod devices()[source]
Return type:

List[Dict[str, str]]

abstractmethod start()[source]
Return type:

BackendResult

abstractmethod stop()[source]
Return type:

BackendResult

gatenet.hotspot.dhcp module

DHCP server management for hotspot functionality.

class gatenet.hotspot.dhcp.DHCPServer(ip_range, gateway, dns_servers=None)[source]

Bases: object

Manage DHCP server for hotspot clients.

Example

>>> from gatenet.hotspot import DHCPServer
>>> dhcp = DHCPServer("192.168.4.0/24", "192.168.4.1")
>>> dhcp.start()
>>> dhcp.stop()
start()[source]

Start the DHCP server.

Returns:

True if started successfully, False otherwise

Return type:

bool

stop()[source]

Stop the DHCP server.

Returns:

True if stopped successfully, False otherwise

Return type:

bool

gatenet.hotspot.hotspot module

Main hotspot management class for creating and controlling Wi-Fi access points.

class gatenet.hotspot.hotspot.Hotspot(config, backend=None)[source]

Bases: object

Create and manage Wi-Fi hotspots on Linux/macOS systems.

Example

>>> from gatenet.hotspot import Hotspot, HotspotConfig
>>> config = HotspotConfig(ssid="MyHotspot", password="mypassword123")
>>> hotspot = Hotspot(config)
>>> hotspot.start()
>>> hotspot.get_connected_devices()
>>> hotspot.stop()
get_connected_devices()[source]

Get list of devices connected to the hotspot.

Returns:

List of connected devices with MAC, IP, and hostname

Return type:

List[Dict]

Example

>>> devices = hotspot.get_connected_devices()
>>> print(f"Connected devices: {len(devices)}")
start()[source]

Start the hotspot.

Returns:

True if started successfully, False otherwise

Return type:

bool

Example

>>> hotspot = Hotspot(HotspotConfig("TestHotspot", "password123"))
>>> success = hotspot.start()
stop()[source]

Stop the hotspot.

Returns:

True if stopped successfully, False otherwise

Return type:

bool

class gatenet.hotspot.hotspot.HotspotConfig(ssid, password=None, interface='wlan0', ip_range='192.168.4.0/24', gateway='192.168.4.1', channel=6, hidden=False)[source]

Bases: object

Configuration for hotspot creation.

channel: int = 6
gateway: str = '192.168.4.1'
hidden: bool = False
interface: str = 'wlan0'
ip_range: str = '192.168.4.0/24'
password: Optional[str] = None
ssid: str

gatenet.hotspot.security module

Security configuration for hotspot access points.

class gatenet.hotspot.security.SecurityConfig(password=None, security_type=SecurityType.WPA2)[source]

Bases: object

Manage security settings for Wi-Fi hotspots.

Example

>>> from gatenet.hotspot import SecurityConfig, SecurityType
>>> config = SecurityConfig("mypassword123", SecurityType.WPA2)
>>> config.validate_password()
>>> strong_password = SecurityConfig.generate_password()
static generate_password(length=12, include_symbols=True)[source]

Generate a strong random password.

Parameters:
  • length (int) – Password length (minimum 8)

  • include_symbols (bool) – Include special characters

Returns:

Strong random password

Return type:

str

Example

>>> password = SecurityConfig.generate_password(16)
>>> len(password) == 16  # True
get_hostapd_config()[source]

Generate hostapd configuration for the security settings.

Returns:

Configuration lines for hostapd

Return type:

str

get_security_level()[source]

Get a human-readable security level description.

Returns:

Security level description

Return type:

str

validate_password()[source]

Validate the password strength.

Returns:

True if password meets security requirements

Return type:

bool

Example

>>> config = SecurityConfig("weakpass")
>>> config.validate_password()  # False
>>> config = SecurityConfig("StrongPass123!")
>>> config.validate_password()  # True
class gatenet.hotspot.security.SecurityType(*values)[source]

Bases: Enum

Security types for Wi-Fi access points.

OPEN = 'open'
WEP = 'wep'
WPA = 'wpa'
WPA2 = 'wpa2'
WPA3 = 'wpa3'

Module contents

Gatenet hotspot module for creating and managing Wi-Fi access points.

This module provides functionality to create software access points, manage DHCP services, and control connected devices.

class gatenet.hotspot.BackendResult(ok, message='')[source]

Bases: object

message: str = ''
ok: bool
class gatenet.hotspot.DHCPServer(ip_range, gateway, dns_servers=None)[source]

Bases: object

Manage DHCP server for hotspot clients.

Example

>>> from gatenet.hotspot import DHCPServer
>>> dhcp = DHCPServer("192.168.4.0/24", "192.168.4.1")
>>> dhcp.start()
>>> dhcp.stop()
start()[source]

Start the DHCP server.

Returns:

True if started successfully, False otherwise

Return type:

bool

stop()[source]

Stop the DHCP server.

Returns:

True if stopped successfully, False otherwise

Return type:

bool

class gatenet.hotspot.Hotspot(config, backend=None)[source]

Bases: object

Create and manage Wi-Fi hotspots on Linux/macOS systems.

Example

>>> from gatenet.hotspot import Hotspot, HotspotConfig
>>> config = HotspotConfig(ssid="MyHotspot", password="mypassword123")
>>> hotspot = Hotspot(config)
>>> hotspot.start()
>>> hotspot.get_connected_devices()
>>> hotspot.stop()
get_connected_devices()[source]

Get list of devices connected to the hotspot.

Returns:

List of connected devices with MAC, IP, and hostname

Return type:

List[Dict]

Example

>>> devices = hotspot.get_connected_devices()
>>> print(f"Connected devices: {len(devices)}")
start()[source]

Start the hotspot.

Returns:

True if started successfully, False otherwise

Return type:

bool

Example

>>> hotspot = Hotspot(HotspotConfig("TestHotspot", "password123"))
>>> success = hotspot.start()
stop()[source]

Stop the hotspot.

Returns:

True if stopped successfully, False otherwise

Return type:

bool

class gatenet.hotspot.HotspotBackend[source]

Bases: ABC

abstractmethod devices()[source]
Return type:

List[Dict[str, str]]

abstractmethod start()[source]
Return type:

BackendResult

abstractmethod stop()[source]
Return type:

BackendResult

class gatenet.hotspot.HotspotConfig(ssid, password=None, interface='wlan0', ip_range='192.168.4.0/24', gateway='192.168.4.1', channel=6, hidden=False)[source]

Bases: object

Configuration for hotspot creation.

channel: int = 6
gateway: str = '192.168.4.1'
hidden: bool = False
interface: str = 'wlan0'
ip_range: str = '192.168.4.0/24'
password: Optional[str] = None
ssid: str
class gatenet.hotspot.SecurityConfig(password=None, security_type=SecurityType.WPA2)[source]

Bases: object

Manage security settings for Wi-Fi hotspots.

Example

>>> from gatenet.hotspot import SecurityConfig, SecurityType
>>> config = SecurityConfig("mypassword123", SecurityType.WPA2)
>>> config.validate_password()
>>> strong_password = SecurityConfig.generate_password()
static generate_password(length=12, include_symbols=True)[source]

Generate a strong random password.

Parameters:
  • length (int) – Password length (minimum 8)

  • include_symbols (bool) – Include special characters

Returns:

Strong random password

Return type:

str

Example

>>> password = SecurityConfig.generate_password(16)
>>> len(password) == 16  # True
get_hostapd_config()[source]

Generate hostapd configuration for the security settings.

Returns:

Configuration lines for hostapd

Return type:

str

get_security_level()[source]

Get a human-readable security level description.

Returns:

Security level description

Return type:

str

validate_password()[source]

Validate the password strength.

Returns:

True if password meets security requirements

Return type:

bool

Example

>>> config = SecurityConfig("weakpass")
>>> config.validate_password()  # False
>>> config = SecurityConfig("StrongPass123!")
>>> config.validate_password()  # True
class gatenet.hotspot.SecurityType(*values)[source]

Bases: Enum

Security types for Wi-Fi access points.

OPEN = 'open'
WEP = 'wep'
WPA = 'wpa'
WPA2 = 'wpa2'
WPA3 = 'wpa3'