Skip to content

Commit 280265e

Browse files
committed
Fix: voice_confirm setting was ignored (guided voice flow never triggered); skip STUN monitor when on (0.1.12)
- get_settings/set_setting теперь знают voice_confirm — флаг сохраняется и читается, без этого кнопка «Глубокий поиск» не видела его и гайд-поток не запускался (фича «ничего не делала») - при voice_confirm ON не поднимаем STUN-монитор голоса: на сетях, где Google STUN мёртв, он ложно «ронял» и переключал даже подтверждённую человеком стратегию (watchdog по сайтам остаётся) - регресс-тесты на оба случая
1 parent f29c190 commit 280265e

4 files changed

Lines changed: 64 additions & 5 deletions

File tree

freeconnect/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""FreeConnect — обёртка над zapret с автоподбором стратегии обхода."""
22

3-
__version__ = "0.1.11"
3+
__version__ = "0.1.12"

freeconnect/app.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,10 +666,12 @@ def get_settings(self) -> dict:
666666
"auto_enable": self.cfg.get("auto_enable", True),
667667
"game_filter": self.cfg.get("game_filter", False),
668668
"doh": self.cfg.get("doh", False),
669+
"voice_confirm": self.cfg.get("voice_confirm", False),
669670
}
670671

671672
def set_setting(self, key: str, value) -> dict:
672-
if key not in ("autostart", "monitor", "auto_enable", "game_filter", "doh"):
673+
if key not in ("autostart", "monitor", "auto_enable", "game_filter", "doh",
674+
"voice_confirm"):
673675
return self.get_settings()
674676
val = bool(value)
675677
if key == "autostart":
@@ -1004,9 +1006,15 @@ def on_result(sc: StrategyScore):
10041006

10051007
# ---- мониторы (голос по UDP + доступность сервисов по TCP/TLS) ----
10061008
def _start_monitors(self) -> None:
1007-
if self.cfg.get("monitor", True):
1009+
if not self.cfg.get("monitor", True):
1010+
return
1011+
# STUN-монитор голоса запускаем ТОЛЬКО когда точная проверка голоса выключена:
1012+
# его сигнал (пинг Google STUN) ненадёжен и на части сетей STUN мёртв вовсе —
1013+
# тогда он ложно «роняет» и переключает даже стратегию, где голос реально живой
1014+
# (в т.ч. подтверждённую человеком). С voice_confirm доверяем человеку + watchdog.
1015+
if not self.cfg.get("voice_confirm", False):
10081016
self.monitor.start()
1009-
self.watchdog.start()
1017+
self.watchdog.start()
10101018

10111019
def _stop_monitors(self) -> None:
10121020
self.monitor.stop()

installer/FreeConnect.iss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
; Сборка: ISCC.exe installer\FreeConnect.iss -> installer\Output\FreeConnect-Setup.exe
44

55
#define MyAppName "FreeConnect"
6-
#define MyAppVersion "0.1.11"
6+
#define MyAppVersion "0.1.12"
77
#define MyAppPublisher "FreeConnect"
88
#define MyAppExeName "FreeConnect.exe"
99

tests/test_voice_confirm.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,56 @@ def test_cancel_during_wait(self):
137137
self.assertFalse(t.is_alive())
138138

139139

140+
class TestVoiceConfirmSetting(unittest.TestCase):
141+
"""Регресс: флаг voice_confirm должен читаться get_settings и сохраняться
142+
set_setting — иначе кнопка «Глубокий поиск» не увидит его и гайд не запустится
143+
(ровно тот баг, что фича «ничего не делала»)."""
144+
145+
def test_roundtrip(self):
146+
from freeconnect import config
147+
api = fcapp.Api.__new__(fcapp.Api)
148+
api.cfg = {"voice_confirm": False, "monitor": True, "auto_enable": True,
149+
"game_filter": False, "doh": False}
150+
api.enabled = False
151+
orig = config.save
152+
config.save = lambda cfg: None
153+
try:
154+
self.assertIn("voice_confirm", api.get_settings())
155+
self.assertFalse(api.get_settings()["voice_confirm"])
156+
api.set_setting("voice_confirm", True)
157+
self.assertTrue(api.cfg["voice_confirm"]) # сохранилось
158+
self.assertTrue(api.get_settings()["voice_confirm"]) # и читается
159+
finally:
160+
config.save = orig
161+
162+
163+
class TestMonitorGating(unittest.TestCase):
164+
"""При voice_confirm ON ненадёжный STUN-монитор голоса НЕ поднимается (иначе он
165+
ложно уронил бы подтверждённую человеком стратегию); watchdog по сайтам — да."""
166+
167+
def _api(self, voice_confirm):
168+
api = fcapp.Api.__new__(fcapp.Api)
169+
api.cfg = {"monitor": True, "voice_confirm": voice_confirm}
170+
171+
class _M:
172+
def __init__(s): s.started = False
173+
def start(s): s.started = True
174+
api.monitor = _M()
175+
api.watchdog = _M()
176+
return api
177+
178+
def test_voice_confirm_skips_stun_monitor(self):
179+
api = self._api(True)
180+
api._start_monitors()
181+
self.assertFalse(api.monitor.started) # STUN-монитор НЕ поднят
182+
self.assertTrue(api.watchdog.started) # watchdog поднят
183+
184+
def test_off_starts_both(self):
185+
api = self._api(False)
186+
api._start_monitors()
187+
self.assertTrue(api.monitor.started)
188+
self.assertTrue(api.watchdog.started)
189+
190+
140191
if __name__ == "__main__":
141192
unittest.main()

0 commit comments

Comments
 (0)