|
@@ -22,17 +22,26 @@ def broadcast_to_cluster(action, domain):
|
|
|
headers = {"X-API-Key": node['api_key'], "Content-Type": "application/json"}
|
|
headers = {"X-API-Key": node['api_key'], "Content-Type": "application/json"}
|
|
|
payload = {"domain": domain, "masters": masters}
|
|
payload = {"domain": domain, "masters": masters}
|
|
|
|
|
|
|
|
|
|
+ # BUG FIX: Ασφαλής Opener για να μην κόβεται από Proxies / SSL
|
|
|
|
|
+ proxy_handler = urllib.request.ProxyHandler({})
|
|
|
|
|
+ https_handler = urllib.request.HTTPSHandler(context=config.ssl_ctx)
|
|
|
|
|
+ opener = urllib.request.build_opener(proxy_handler, https_handler)
|
|
|
|
|
+
|
|
|
if action == 'add_slave':
|
|
if action == 'add_slave':
|
|
|
req = urllib.request.Request(url, data=json.dumps(payload).encode('utf-8'), headers=headers, method='POST')
|
|
req = urllib.request.Request(url, data=json.dumps(payload).encode('utf-8'), headers=headers, method='POST')
|
|
|
elif action == 'delete_zone':
|
|
elif action == 'delete_zone':
|
|
|
req = urllib.request.Request(f"{url}/{domain}", headers=headers, method='DELETE')
|
|
req = urllib.request.Request(f"{url}/{domain}", headers=headers, method='DELETE')
|
|
|
|
|
|
|
|
- urllib.request.urlopen(req, timeout=5, context=config.ssl_ctx)
|
|
|
|
|
|
|
+ opener.open(req, timeout=10)
|
|
|
|
|
+ print(f"Cluster Sync OK: {node['name']} ({action} {domain})")
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
print(f"Cluster Sync FAIL: {node['name']} -> {e}")
|
|
print(f"Cluster Sync FAIL: {node['name']} -> {e}")
|
|
|
|
|
|
|
|
import threading
|
|
import threading
|
|
|
threading.Thread(target=task, daemon=True).start()
|
|
threading.Thread(target=task, daemon=True).start()
|
|
|
|
|
+
|
|
|
|
|
+ import threading
|
|
|
|
|
+ threading.Thread(target=task, daemon=True).start()
|
|
|
|
|
|
|
|
def broadcast_adblock_to_cluster(action):
|
|
def broadcast_adblock_to_cluster(action):
|
|
|
def task():
|
|
def task():
|