mirror of
https://github.com/LorenEteval/Furious.git
synced 2026-09-30 10:58:09 +03:00
Scope Xray TUN reconnect notices
Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
@@ -30,6 +30,7 @@ import copy
|
||||
import functools
|
||||
import logging
|
||||
|
||||
from .Plugin import isXrayConnectionActive
|
||||
from .TUN import getXrayTUNSettings, saveXrayTUNSettings
|
||||
|
||||
__all__ = ['GuiXrayTUNSettings']
|
||||
@@ -245,7 +246,7 @@ class GuiXrayTUNSettings(GuiEditorWidgetQDialog):
|
||||
return
|
||||
|
||||
saveXrayTUNSettings(self._settings)
|
||||
if SystemRuntime.isTUNMode():
|
||||
if SystemRuntime.isTUNMode() and isXrayConnectionActive():
|
||||
showMBoxNewChangesNextTime()
|
||||
|
||||
@functools.lru_cache(None)
|
||||
|
||||
@@ -44,7 +44,7 @@ from .TUN import (
|
||||
setXrayTUNEnabled,
|
||||
)
|
||||
|
||||
__all__ = ['XrayPlugin']
|
||||
__all__ = ['XrayPlugin', 'isXrayConnectionActive']
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -96,6 +96,22 @@ _TRANSLATABLE_ACTION_TEXT = [
|
||||
]
|
||||
|
||||
|
||||
def isXrayConnectionActive() -> bool:
|
||||
"""Return whether the connected core process belongs to Xray-core."""
|
||||
try:
|
||||
connectAction = APP().systemTray.ConnectAction
|
||||
if not connectAction.isConnected():
|
||||
return False
|
||||
|
||||
return any(
|
||||
isinstance(process, XrayCore)
|
||||
for process in connectAction.coreManager.processesPool
|
||||
)
|
||||
except Exception:
|
||||
# Plugin actions can be created before the tray is fully initialized.
|
||||
return False
|
||||
|
||||
|
||||
class XrayPlugin(FuriousPlugin):
|
||||
"""Provide official Xray-core support."""
|
||||
|
||||
@@ -219,7 +235,7 @@ class XrayPlugin(FuriousPlugin):
|
||||
"""Persist the native Xray TUN action state."""
|
||||
setXrayTUNEnabled(useXrayTUNAction.isChecked())
|
||||
|
||||
if SystemRuntime.isTUNMode():
|
||||
if SystemRuntime.isTUNMode() and isXrayConnectionActive():
|
||||
showMBoxNewChangesNextTime()
|
||||
|
||||
useXrayTUNAction.callback = updateUseXrayTUN
|
||||
|
||||
Reference in New Issue
Block a user