Integração Pangolin Proxy

This commit is contained in:
2025-12-06 21:11:34 -03:00
parent dc7c446254
commit 5291d8ccae
2008 changed files with 1062 additions and 477 deletions

View File

@@ -115,9 +115,11 @@ def main():
logging.info(f"Machine ID: {machine_id}")
last_checksum = None
was_error = False # Track if we had an error in the previous cycle
while True:
try:
logging.debug("Starting sync cycle...")
headers = {
'Authorization': f'Bearer {serial_key}',
'X-Machine-ID': machine_id
@@ -126,6 +128,11 @@ def main():
response = requests.get(f"{api_url}/api/v1/domains", headers=headers, timeout=10)
if response.status_code == 200:
# Log reconnection if we had an error before
if was_error:
logging.info("Connection restored. Sync resumed successfully.")
was_error = False
try:
data = response.json()
current_checksum = data.get('checksum')
@@ -151,13 +158,22 @@ def main():
elif response.status_code == 401:
logging.error("Unauthorized: Invalid Serial Key.")
was_error = True
elif response.status_code == 403:
logging.error("Forbidden: Serial Key bound to another machine.")
try:
error_data = response.json()
error_msg = error_data.get('error', 'Access denied')
except:
error_msg = response.text[:100]
logging.warning(f"Access denied (403): {error_msg}. Will retry in 60 seconds...")
was_error = True
else:
logging.warning(f"API Error: {response.status_code} - {response.text}")
was_error = True
except Exception as e:
logging.error(f"Connection Error: {e}")
was_error = True
# Wait for 60 seconds before next check
time.sleep(60)