#!/usr/bin/env python3 import sys import os import subprocess # Import-Fix für Linux/Mac try: from INWX.Domrobot import ApiClient except ImportError: from inwx.Domrobot import ApiClient # --- KONFIGURATION --- API_URL = 'https://api.domrobot.com' BASE_DIR = os.path.dirname(os.path.abspath(__file__)) KP_DB_PATH = os.path.join(BASE_DIR, "hosting.kdbx") KP_ENTRY_NAME = "inwx" DOMAIN = "ma151.de" def get_creds(): """Holt die echten Daten (inkl. Passwort) aus KeePassXC.""" try: # -s sorgt dafür, dass das Passwort nicht als 'PROTECTED' ausgegeben wird cmd = ["keepassxc-cli", "show", "-s", KP_DB_PATH, KP_ENTRY_NAME] output = subprocess.check_output(cmd, text=True) creds = {} for line in output.splitlines(): if ":" in line: k, v = line.split(":", 1) creds[k.strip().lower()] = v.strip() user = creds.get("username") or creds.get("benutzername") or creds.get("user") password = creds.get("password") or creds.get("passwort") return user, password except Exception as e: print(f"❌ KeePass-Fehler: {e}") return None, None def main(): user, password = get_creds() if not user or not password: sys.exit(1) # ApiClient mit der korrekten URL (Library fügt /xmlrpc/ an) api = ApiClient(api_url=API_URL) print(f"Versuche Login für: {user}") # Login login_res = api.login(user, password) if login_res['code'] == 1000: print("✅ Login erfolgreich!") print(f"Rufe Records für {DOMAIN} ab...") try: # Deine Library-Version nutzt laut DEBUG 'call_api' res = api.call_api('nameserver.info', {'domain': DOMAIN}) if res['code'] == 1000: records = res['resData']['record'] print(f"\n{'TYP':<8} {'NAME':<35} {'WERT'}") print("-" * 75) for rec in records: print(f"{rec['type']:<8} {rec['name']:<35} {rec['content']}") else: print(f"❌ API Fehler: {res['msg']} (Code: {res['code']})") except Exception as e: print(f"❌ Fehler beim Abruf mit call_api: {e}") api.logout() else: print(f"❌ Login fehlgeschlagen: {login_res['msg']} (Code: {login_res['code']})") if __name__ == "__main__": main()