Update
This commit is contained in:
@@ -34,6 +34,7 @@ _DEFAULT: dict[str, Any] = {
|
|||||||
"ui": {
|
"ui": {
|
||||||
"minimize_to_tray": True,
|
"minimize_to_tray": True,
|
||||||
"autostart": False,
|
"autostart": False,
|
||||||
|
"auto_connect_on_startup": False,
|
||||||
"auto_reconnect": False,
|
"auto_reconnect": False,
|
||||||
"reconnect_interval": 30,
|
"reconnect_interval": 30,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -280,6 +280,7 @@ class AdminWindow(QDialog):
|
|||||||
|
|
||||||
btn_gen = QPushButton("Générer une nouvelle paire de clés")
|
btn_gen = QPushButton("Générer une nouvelle paire de clés")
|
||||||
btn_gen.setFixedHeight(28)
|
btn_gen.setFixedHeight(28)
|
||||||
|
btn_gen.clicked.connect(self._generate_keys)
|
||||||
self._row(form, "", btn_gen)
|
self._row(form, "", btn_gen)
|
||||||
lay.addWidget(grp)
|
lay.addWidget(grp)
|
||||||
|
|
||||||
@@ -512,6 +513,15 @@ class AdminWindow(QDialog):
|
|||||||
self._chk_autostart.setChecked(bool(self._cfg.get("ui", "autostart")))
|
self._chk_autostart.setChecked(bool(self._cfg.get("ui", "autostart")))
|
||||||
form1.addRow("", self._chk_autostart)
|
form1.addRow("", self._chk_autostart)
|
||||||
|
|
||||||
|
self._chk_auto_connect = QCheckBox(
|
||||||
|
"Se connecter automatiquement au démarrage (profil actif)"
|
||||||
|
)
|
||||||
|
self._chk_auto_connect.setStyleSheet("color: white;")
|
||||||
|
self._chk_auto_connect.setChecked(
|
||||||
|
bool(self._cfg.get("ui", "auto_connect_on_startup"))
|
||||||
|
)
|
||||||
|
form1.addRow("", self._chk_auto_connect)
|
||||||
|
|
||||||
lay.addWidget(grp1)
|
lay.addWidget(grp1)
|
||||||
|
|
||||||
grp_ks = QGroupBox("🔒 Kill Switch (Linux)")
|
grp_ks = QGroupBox("🔒 Kill Switch (Linux)")
|
||||||
@@ -569,6 +579,7 @@ class AdminWindow(QDialog):
|
|||||||
self._cfg.set("ui", "minimize_to_tray", self._chk_tray.isChecked())
|
self._cfg.set("ui", "minimize_to_tray", self._chk_tray.isChecked())
|
||||||
self._cfg.set("ui", "auto_reconnect", self._chk_autorecon.isChecked())
|
self._cfg.set("ui", "auto_reconnect", self._chk_autorecon.isChecked())
|
||||||
self._cfg.set("ui", "reconnect_interval", self._spin_interval.value())
|
self._cfg.set("ui", "reconnect_interval", self._spin_interval.value())
|
||||||
|
self._cfg.set("ui", "auto_connect_on_startup", self._chk_auto_connect.isChecked())
|
||||||
autostart = self._chk_autostart.isChecked()
|
autostart = self._chk_autostart.isChecked()
|
||||||
if autostart != bool(self._cfg.get("ui", "autostart")):
|
if autostart != bool(self._cfg.get("ui", "autostart")):
|
||||||
self._cfg.set_autostart(autostart)
|
self._cfg.set_autostart(autostart)
|
||||||
|
|||||||
+35
-5
@@ -11,9 +11,11 @@ from PyQt6.QtGui import QFont, QCloseEvent, QColor
|
|||||||
from app.core.config import Config
|
from app.core.config import Config
|
||||||
from app.core import wireguard as wg_core
|
from app.core import wireguard as wg_core
|
||||||
from app.core import log as conn_log
|
from app.core import log as conn_log
|
||||||
|
from app.core import history as hist
|
||||||
from app.ui.mfa_dialog import MFADialog
|
from app.ui.mfa_dialog import MFADialog
|
||||||
from app.ui.admin_window import AdminWindow
|
from app.ui.admin_window import AdminWindow
|
||||||
from app.ui.bw_graph import BandwidthGraph
|
from app.ui.bw_graph import BandwidthGraph
|
||||||
|
from app.ui.history_dialog import HistoryDialog
|
||||||
from app.ui import icons
|
from app.ui import icons
|
||||||
|
|
||||||
_DARK = "#1c2833"
|
_DARK = "#1c2833"
|
||||||
@@ -44,6 +46,7 @@ class MainWindow(QMainWindow):
|
|||||||
self._prev_rx: int | None = None
|
self._prev_rx: int | None = None
|
||||||
self._prev_tx: int | None = None
|
self._prev_tx: int | None = None
|
||||||
self._auto_reconnect_active = False
|
self._auto_reconnect_active = False
|
||||||
|
self._session_id: int | None = None
|
||||||
|
|
||||||
self.setWindowTitle("WGSecure")
|
self.setWindowTitle("WGSecure")
|
||||||
self.setFixedSize(430, 680)
|
self.setFixedSize(430, 680)
|
||||||
@@ -80,6 +83,9 @@ class MainWindow(QMainWindow):
|
|||||||
self._reload_log()
|
self._reload_log()
|
||||||
self._reload_profiles()
|
self._reload_profiles()
|
||||||
|
|
||||||
|
if self._cfg.get("ui", "auto_connect_on_startup") and self._cfg.configured:
|
||||||
|
QTimer.singleShot(500, self._on_connect)
|
||||||
|
|
||||||
# ------------------------------------------------------------------ #
|
# ------------------------------------------------------------------ #
|
||||||
# Construction UI
|
# Construction UI
|
||||||
# ------------------------------------------------------------------ #
|
# ------------------------------------------------------------------ #
|
||||||
@@ -246,7 +252,10 @@ class MainWindow(QMainWindow):
|
|||||||
self._btn_connect.clicked.connect(self._on_connect)
|
self._btn_connect.clicked.connect(self._on_connect)
|
||||||
bl.addWidget(self._btn_connect)
|
bl.addWidget(self._btn_connect)
|
||||||
|
|
||||||
btn_admin = QPushButton("⚙️ Panneau Administrateur")
|
secondary_row = QHBoxLayout()
|
||||||
|
secondary_row.setSpacing(6)
|
||||||
|
|
||||||
|
btn_admin = QPushButton("⚙️ Administrateur")
|
||||||
btn_admin.setFixedHeight(30)
|
btn_admin.setFixedHeight(30)
|
||||||
btn_admin.setStyleSheet(
|
btn_admin.setStyleSheet(
|
||||||
"QPushButton { background: #2e4057; color: white; border-radius: 6px;"
|
"QPushButton { background: #2e4057; color: white; border-radius: 6px;"
|
||||||
@@ -254,7 +263,19 @@ class MainWindow(QMainWindow):
|
|||||||
"QPushButton:hover { background: #3d5166; }"
|
"QPushButton:hover { background: #3d5166; }"
|
||||||
)
|
)
|
||||||
btn_admin.clicked.connect(self._open_admin)
|
btn_admin.clicked.connect(self._open_admin)
|
||||||
bl.addWidget(btn_admin)
|
secondary_row.addWidget(btn_admin)
|
||||||
|
|
||||||
|
btn_history = QPushButton("📊 Historique")
|
||||||
|
btn_history.setFixedHeight(30)
|
||||||
|
btn_history.setStyleSheet(
|
||||||
|
"QPushButton { background: #2e4057; color: white; border-radius: 6px;"
|
||||||
|
" font-size: 11px; border: none; }"
|
||||||
|
"QPushButton:hover { background: #3d5166; }"
|
||||||
|
)
|
||||||
|
btn_history.clicked.connect(self._open_history)
|
||||||
|
secondary_row.addWidget(btn_history)
|
||||||
|
|
||||||
|
bl.addLayout(secondary_row)
|
||||||
root.addWidget(btn_area)
|
root.addWidget(btn_area)
|
||||||
|
|
||||||
# ── Helpers UI ───────────────────────────────────────────────────────
|
# ── Helpers UI ───────────────────────────────────────────────────────
|
||||||
@@ -508,6 +529,11 @@ class MainWindow(QMainWindow):
|
|||||||
if connected:
|
if connected:
|
||||||
ok, msg = wg_core.disconnect(self._cfg)
|
ok, msg = wg_core.disconnect(self._cfg)
|
||||||
if ok:
|
if ok:
|
||||||
|
if self._session_id is not None:
|
||||||
|
rx = self._prev_rx or 0
|
||||||
|
tx = self._prev_tx or 0
|
||||||
|
hist.end_session(self._session_id, rx, tx)
|
||||||
|
self._session_id = None
|
||||||
self._add_log("Tunnel WireGuard désactivé", "warning")
|
self._add_log("Tunnel WireGuard désactivé", "warning")
|
||||||
else:
|
else:
|
||||||
self._add_log(f"Erreur déconnexion : {msg}", "error")
|
self._add_log(f"Erreur déconnexion : {msg}", "error")
|
||||||
@@ -543,9 +569,10 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
if ok:
|
if ok:
|
||||||
self._connected_since = QDateTime.currentDateTime()
|
self._connected_since = QDateTime.currentDateTime()
|
||||||
self._add_log(
|
endpoint = self._cfg.wg.get("server_endpoint", "")
|
||||||
f"Connexion établie → {self._cfg.wg.get('server_endpoint','')}", "success"
|
profile = self._cfg.active_profile
|
||||||
)
|
self._session_id = hist.start_session(endpoint, profile)
|
||||||
|
self._add_log(f"Connexion établie → {endpoint}", "success")
|
||||||
QTimer.singleShot(5000, self._update_ping)
|
QTimer.singleShot(5000, self._update_ping)
|
||||||
else:
|
else:
|
||||||
self._add_log(f"Erreur : {msg}", "error")
|
self._add_log(f"Erreur : {msg}", "error")
|
||||||
@@ -553,6 +580,9 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
self._refresh_status()
|
self._refresh_status()
|
||||||
|
|
||||||
|
def _open_history(self):
|
||||||
|
HistoryDialog(self).exec()
|
||||||
|
|
||||||
def _open_admin(self):
|
def _open_admin(self):
|
||||||
if self._cfg.has_admin_password():
|
if self._cfg.has_admin_password():
|
||||||
pw, ok = QInputDialog.getText(
|
pw, ok = QInputDialog.getText(
|
||||||
|
|||||||
Reference in New Issue
Block a user