first commit
This commit is contained in:
66
03_create_sg_link11.py
Executable file
66
03_create_sg_link11.py
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/bin/python
|
||||
from env import *
|
||||
import requests
|
||||
import json
|
||||
|
||||
# === Konfiguration ===
|
||||
CONFIG_ID = "prod"
|
||||
|
||||
# Proxy Templates – nur einen aktiv lassen
|
||||
PROXY_TEMPLATE = "f4bf25a205a5"
|
||||
# PROXY_TEMPLATE = "andere_template_id"
|
||||
|
||||
# === Header für alle Requests ===
|
||||
HEADERS = {
|
||||
"Authorization": f"Bearer {API_TOKEN}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
|
||||
def sanitize_entry_id(domain):
|
||||
"""Erstellt eine gültige entry_id ohne Punkte, wie von der API gefordert."""
|
||||
return domain.replace(".", "-")
|
||||
|
||||
|
||||
def create_server_group(domain, security_policy):
|
||||
entry_id = sanitize_entry_id(domain)
|
||||
url = f"https://jtlwaap.app.reblaze.io/api/v4.3/conf/{CONFIG_ID}/server-groups/{entry_id}"
|
||||
|
||||
payload = {
|
||||
"id": entry_id,
|
||||
"challenge_cookie_domain": "$host",
|
||||
"description": f"Automatisch erstellt fuer {domain}",
|
||||
"mobile_application_group": "",
|
||||
"name": domain,
|
||||
"proxy_template": PROXY_TEMPLATE,
|
||||
"routing_profile": "__default__",
|
||||
"security_policy": security_policy,
|
||||
"server_names": [
|
||||
domain,
|
||||
"www."+domain
|
||||
],
|
||||
"ssl_certificate": "placeholder",
|
||||
"client_certificate": "",
|
||||
"client_certificate_mode": "off",
|
||||
}
|
||||
# print(payload)
|
||||
print(f"\n📦 Erstelle Gruppe für {domain} → ID: {entry_id}")
|
||||
response = requests.post(url, headers=HEADERS, data=json.dumps(payload))
|
||||
|
||||
if response.status_code == 201:
|
||||
print(f"[✓] Server-Gruppe '{entry_id}' erfolgreich erstellt.")
|
||||
elif response.status_code == 409:
|
||||
print(f"[i] Gruppe '{entry_id}' existiert bereits.")
|
||||
else:
|
||||
print(f"[✗] Fehler bei {domain} ({entry_id}): {response.status_code} → {response.text}")
|
||||
|
||||
def main():
|
||||
# === CSV-Datei einlesen ===
|
||||
with open("serverliste_link11.csv", "r") as file:
|
||||
for line in file:
|
||||
domain = line.strip()
|
||||
if domain:
|
||||
create_server_group(domain, 'secpol-shop009-jtl-hosting-de')
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user