fix proxy
This commit is contained in:
@@ -2196,9 +2196,8 @@ class BotInterface:
|
|||||||
await send_message_safe(bot, params.chat_id, "⚠️ Баланс исчерпан — задача остановлена")
|
await send_message_safe(bot, params.chat_id, "⚠️ Баланс исчерпан — задача остановлена")
|
||||||
return
|
return
|
||||||
|
|
||||||
reading = params.get_reading_time()
|
|
||||||
try:
|
try:
|
||||||
result = await self.browser_service.visit_page(params.url, reading)
|
result = await self.browser_service.visit_page(params.url, params.get_reading_time())
|
||||||
params.total_visits += 1
|
params.total_visits += 1
|
||||||
if result.success:
|
if result.success:
|
||||||
params.successful_visits += 1
|
params.successful_visits += 1
|
||||||
|
|||||||
@@ -155,9 +155,9 @@ class BrowserService:
|
|||||||
_set_real_ip(None)
|
_set_real_ip(None)
|
||||||
logger.info("Direct connection")
|
logger.info("Direct connection")
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
# Гарантируем освобождение прокси даже при отмене задачи
|
# Задача отменена — прокси не виноват, освобождаем без штрафа
|
||||||
if proxy:
|
if proxy:
|
||||||
await self.proxy_manager.release_proxy(proxy, success=False)
|
await self.proxy_manager.release_proxy(proxy, success=True)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if proxy_config:
|
if proxy_config:
|
||||||
@@ -167,15 +167,6 @@ class BrowserService:
|
|||||||
humanize=True,
|
humanize=True,
|
||||||
exclude_addons=[DefaultAddons.UBO],
|
exclude_addons=[DefaultAddons.UBO],
|
||||||
proxy=proxy_config,
|
proxy=proxy_config,
|
||||||
firefox_prefs={
|
|
||||||
# Запрещаем WebRTC использовать локальные IP-кандидаты
|
|
||||||
"media.peerconnection.ice.no_host": True,
|
|
||||||
# Только ICE через прокси — блокирует утечку реального IP
|
|
||||||
"media.peerconnection.ice.proxy_only_if_behind_proxy": True,
|
|
||||||
# DNS только через прокси (предотвращает DNS-утечку)
|
|
||||||
"network.dns.disablePrefetch": True,
|
|
||||||
"network.prefetch-next": False,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
if proxy_locale:
|
if proxy_locale:
|
||||||
camoufox_kwargs["locale"] = proxy_locale
|
camoufox_kwargs["locale"] = proxy_locale
|
||||||
@@ -204,11 +195,12 @@ class BrowserService:
|
|||||||
await self.socks5_pool.release(proxy)
|
await self.socks5_pool.release(proxy)
|
||||||
|
|
||||||
if is_proxy_dead:
|
if is_proxy_dead:
|
||||||
logger.warning(f"Visit attempt {attempt + 1} proxy connection failed, retrying with new")
|
logger.warning(f"Visit attempt {attempt + 1} proxy connection failed, retrying with new proxy")
|
||||||
continue
|
continue
|
||||||
elif is_load_error:
|
elif is_load_error:
|
||||||
logger.warning(f"Visit attempt {attempt + 1} page load error (proxy ok), retrying")
|
# Ошибка загрузки — не меняем прокси, просто возвращаем результат
|
||||||
continue
|
# (сайт мог быть временно недоступен, прокси ок)
|
||||||
|
logger.warning(f"Visit attempt {attempt + 1} page load error: {result.error or 'unknown'}")
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -222,7 +214,8 @@ class BrowserService:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Visit error: {e}", exc_info=True)
|
logger.error(f"Visit error: {e}", exc_info=True)
|
||||||
if proxy:
|
if proxy:
|
||||||
await self.proxy_manager.release_proxy(proxy, success=False)
|
# Ошибка кода/браузера — прокси не виноват
|
||||||
|
await self.proxy_manager.release_proxy(proxy, success=True)
|
||||||
if use_socks5:
|
if use_socks5:
|
||||||
await self.socks5_pool.release(proxy)
|
await self.socks5_pool.release(proxy)
|
||||||
return VisitResult(url=url, success=False, error=str(e))
|
return VisitResult(url=url, success=False, error=str(e))
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ async def get_viewer_count(channel: str) -> int | None:
|
|||||||
|
|
||||||
stream = data.get("data", {}).get("user", {}).get("stream")
|
stream = data.get("data", {}).get("user", {}).get("stream")
|
||||||
count = stream.get("viewersCount", 0) if stream else 0
|
count = stream.get("viewersCount", 0) if stream else 0
|
||||||
logger.info(f"Viewers on {channel}: {count}")
|
logger.debug(f"Viewers on {channel}: {count}")
|
||||||
return count
|
return count
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user