Session-Caching, Domain-/Gruppen-Skripte; KeePass-DB aus Repo entfernen

- inwx_common.py: Login mit Session-Cache, KP_PW-Option
- inwx_list/add: Domain als Argument, gemeinsamer Helfer
- inwx_domains(_owner).py: Domains alphabetisch, NS, Gruppen via citeq-TXT (DNS)
- hosting.kdbx aus Tracking genommen und in .gitignore

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-19 15:57:10 +02:00
parent d8e051d4b3
commit e31bdeb59d
8 changed files with 556 additions and 114 deletions
+30 -64
View File
@@ -1,78 +1,44 @@
#!/usr/bin/env python3
import sys
import os
import subprocess
import sys
# Import-Fix für Linux/Mac
try:
from INWX.Domrobot import ApiClient
except ImportError:
from inwx.Domrobot import ApiClient
from inwx_common import get_client, call_api
# --- 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"
# Login/Session-Handling steckt in inwx_common.py.
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:
# Domain als Argument einlesen
if len(sys.argv) < 2:
script = os.path.basename(sys.argv[0])
print(f"Verwendung: {script} <domain>")
print(f"Beispiel: {script} ma151.de")
sys.exit(1)
# ApiClient mit der korrekten URL (Library fügt /xmlrpc/ an)
api = ApiClient(api_url=API_URL)
domain = sys.argv[1]
# Holt einen einsatzbereiten Client (nutzt ggf. die zwischengespeicherte Session)
api = get_client()
print(f"Rufe Records für {domain} ab...")
try:
res = call_api(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}")
# Kein logout() -> die Session bleibt gültig und kann wiederverwendet werden.
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()