Scope Xray TUN reconnect notices

Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Loren Eteval
2026-08-12 12:20:16 +08:00
parent 4ef33e2297
commit bb5efde1c0
2 changed files with 20 additions and 3 deletions
@@ -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)
+18 -2
View File
@@ -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