diff --git a/main.py b/main.py index 6212941..c6b65a3 100644 --- a/main.py +++ b/main.py @@ -21,10 +21,34 @@ sys.path.insert(0, BUNDLE_DIR) from PyQt6.QtWidgets import QApplication, QInputDialog, QMessageBox, QLineEdit +import hashlib +import platform +import socket +import uuid + LICENSE_API = "https://vision.copydev.fr/api/license.php" LICENSE_FILE = os.path.join(BASE_DIR, ".license") +def _get_machine_id(): + """Generer un identifiant unique pour cette machine.""" + raw = "" + try: + raw += platform.node() + raw += str(uuid.getnode()) # MAC address + except Exception: + raw += "unknown" + return hashlib.sha256(raw.encode()).hexdigest()[:32] + + +def _get_hostname(): + """Recuperer le nom NetBIOS / hostname.""" + try: + return platform.node() or socket.gethostname() + except Exception: + return "inconnu" + + def _load_license_cache(): """Charger le cache de licence local.""" if not os.path.exists(LICENSE_FILE): @@ -48,7 +72,9 @@ def _save_license_cache(data): def _check_license_online(key): """Verifier la licence aupres du serveur Vision.""" try: - url = f"{LICENSE_API}?key={urllib.parse.quote(key)}" + mid = _get_machine_id() + hname = _get_hostname() + url = f"{LICENSE_API}?key={urllib.parse.quote(key)}&machine_id={urllib.parse.quote(mid)}&hostname={urllib.parse.quote(hname)}" req = urllib.request.Request(url, headers={"User-Agent": "CopydevImposingTool/1.0"}) with urllib.request.urlopen(req, timeout=10) as resp: data = json.loads(resp.read().decode())