Update public source

This commit is contained in:
2026-10-06 21:08:12 +03:00
commit f231cc5b1f
102 changed files with 48249 additions and 0 deletions
+194
View File
@@ -0,0 +1,194 @@
import logging
import subprocess
import signal
import shlex
class WiFiManager:
def __init__(
self,
config,
session,
interface
):
self.config = config
self.session = session
self.interface = interface
self.process = None
self.log = logging.getLogger(
"wifi"
)
cmd = [
"sudo",
"-n",
str(self.config.hcxdumptool),
"-i",
self.interface,
"-w",
str(self.session.capture_file),
]
#
# Каналы WiFi
#
# Каналы собираются отдельно для каждого
# включённого диапазона.
#
# a - диапазон 2.4 GHz
# b - диапазон 5 GHz
# c - диапазон 6 GHz
#
channels = []
if self.config.wifi_enable_2_4ghz:
if self.config.wifi_channels_2_4ghz:
channels.append(
self.config.wifi_channels_2_4ghz
)
if self.config.wifi_enable_5ghz:
if self.config.wifi_channels_5ghz:
channels.append(
self.config.wifi_channels_5ghz
)
if self.config.wifi_enable_6ghz:
if self.config.wifi_channels_6ghz:
channels.append(
self.config.wifi_channels_6ghz
)
if channels:
cmd.extend(
[
"-c",
",".join(channels)
]
)
#
# Дополнительные параметры
#
# Берутся из config.yaml
#
# Позволяют добавлять новые ключи
# без изменения программы
#
if self.config.wifi_extra_args:
cmd.extend(
shlex.split(
self.config.wifi_extra_args
)
)
self.cmd = cmd
def start(self):
if self.process is not None:
return
self.log.info(
"Starting hcxdumptool"
)
self.log.debug(
"Command: %s",
" ".join(self.cmd)
)
self.process = subprocess.Popen(
self.cmd
)
self.log.info(
"hcxdumptool started, pid=%s",
self.process.pid
)
def stop(self):
if not self.process:
return
self.log.info(
"Stopping hcxdumptool"
)
self.process.send_signal(
signal.SIGTERM
)
try:
self.process.wait(
timeout=10
)
self.log.info(
"hcxdumptool stopped with code %s",
self.process.returncode
)
except subprocess.TimeoutExpired:
self.log.warning(
"hcxdumptool did not stop, killing..."
)
self.process.kill()
self.process.wait(
timeout=5
)
self.process = None