unitlab 2.3.17__tar.gz → 2.3.18__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {unitlab-2.3.17/src/unitlab.egg-info → unitlab-2.3.18}/PKG-INFO +1 -1
- {unitlab-2.3.17 → unitlab-2.3.18}/setup.py +1 -1
- {unitlab-2.3.17 → unitlab-2.3.18}/src/unitlab/cloudflare_api_tunnel.py +44 -6
- {unitlab-2.3.17 → unitlab-2.3.18/src/unitlab.egg-info}/PKG-INFO +1 -1
- {unitlab-2.3.17 → unitlab-2.3.18}/LICENSE.md +0 -0
- {unitlab-2.3.17 → unitlab-2.3.18}/README.md +0 -0
- {unitlab-2.3.17 → unitlab-2.3.18}/setup.cfg +0 -0
- {unitlab-2.3.17 → unitlab-2.3.18}/src/unitlab/__init__.py +0 -0
- {unitlab-2.3.17 → unitlab-2.3.18}/src/unitlab/__main__.py +0 -0
- {unitlab-2.3.17 → unitlab-2.3.18}/src/unitlab/binary_manager.py +0 -0
- {unitlab-2.3.17 → unitlab-2.3.18}/src/unitlab/client.py +0 -0
- {unitlab-2.3.17 → unitlab-2.3.18}/src/unitlab/exceptions.py +0 -0
- {unitlab-2.3.17 → unitlab-2.3.18}/src/unitlab/main.py +0 -0
- {unitlab-2.3.17 → unitlab-2.3.18}/src/unitlab/tunnel_config.py +0 -0
- {unitlab-2.3.17 → unitlab-2.3.18}/src/unitlab/tunnel_service_token.py +0 -0
- {unitlab-2.3.17 → unitlab-2.3.18}/src/unitlab/utils.py +0 -0
- {unitlab-2.3.17 → unitlab-2.3.18}/src/unitlab.egg-info/SOURCES.txt +0 -0
- {unitlab-2.3.17 → unitlab-2.3.18}/src/unitlab.egg-info/dependency_links.txt +0 -0
- {unitlab-2.3.17 → unitlab-2.3.18}/src/unitlab.egg-info/entry_points.txt +0 -0
- {unitlab-2.3.17 → unitlab-2.3.18}/src/unitlab.egg-info/requires.txt +0 -0
- {unitlab-2.3.17 → unitlab-2.3.18}/src/unitlab.egg-info/top_level.txt +0 -0
@@ -206,7 +206,7 @@ class CloudflareAPITunnel:
|
|
206
206
|
print(" Assuming routes are configured in dashboard.")
|
207
207
|
return True
|
208
208
|
|
209
|
-
def create_device_tunnel(self):
|
209
|
+
def create_device_tunnel(self, retry_on_fail=True):
|
210
210
|
"""
|
211
211
|
Create a unique tunnel for this device if it doesn't exist
|
212
212
|
"""
|
@@ -372,11 +372,27 @@ class CloudflareAPITunnel:
|
|
372
372
|
self.create_dns_records()
|
373
373
|
self.update_tunnel_config()
|
374
374
|
|
375
|
+
# Check if we need to recreate the tunnel
|
376
|
+
if device_tunnel and device_tunnel.get('needs_recreation'):
|
377
|
+
print("🔄 Recreating tunnel due to access issues...")
|
378
|
+
# Delete the old tunnel
|
379
|
+
tunnel_id = device_tunnel['id']
|
380
|
+
delete_url = f"{self.api_base}/accounts/{self.account_id}/tunnels/{tunnel_id}"
|
381
|
+
delete_response = requests.delete(delete_url, headers=self.headers)
|
382
|
+
if delete_response.status_code in [200, 204, 404]:
|
383
|
+
print(f" ✅ Deleted old tunnel")
|
384
|
+
# Try creating a new one with a timestamp suffix
|
385
|
+
import time
|
386
|
+
self.clean_device_id = f"{self.device_id.replace(' ', '').replace('-', '').replace('.', '').replace('_', '')[:24]}-{int(time.time())}"
|
387
|
+
device_tunnel = self.create_device_tunnel(retry_on_fail=False)
|
388
|
+
if device_tunnel:
|
389
|
+
print(f" ✅ Created new tunnel")
|
390
|
+
|
375
391
|
if not device_tunnel:
|
376
392
|
print("❌ Could not create/find device tunnel")
|
377
393
|
# Fallback to shared tunnel if API fails
|
378
394
|
print("⚠️ Falling back to shared tunnel...")
|
379
|
-
service_token = "
|
395
|
+
service_token = "eyJhIjoiYzkxMTkyYWUyMGE1ZDQzZjY1ZTA4NzU1MGQ4ZGM4OWIiLCJ0IjoiMDc3N2ZjMTAtNDljNC00NzJkLTg2NjEtZjYwZDgwZDYxODRkIiwicyI6Ik9XRTNaak5tTVdVdE1tWTRaUzAwTmpoakLTazBmalF0WXpjek1tSm1ZVGt4WlRRMCJ9"
|
380
396
|
cmd = [
|
381
397
|
cloudflared_path,
|
382
398
|
"tunnel",
|
@@ -402,12 +418,22 @@ class CloudflareAPITunnel:
|
|
402
418
|
self._save_tunnel_credentials(device_tunnel)
|
403
419
|
# Continue to use credentials below
|
404
420
|
else:
|
405
|
-
print("⚠️ No stored credentials,
|
421
|
+
print("⚠️ No stored credentials, requesting tunnel token...")
|
406
422
|
# Get token for this tunnel
|
407
423
|
token_url = f"{self.api_base}/accounts/{self.account_id}/tunnels/{tunnel_id}/token"
|
424
|
+
print(f" Token URL: {token_url}")
|
425
|
+
|
408
426
|
token_response = requests.get(token_url, headers=self.headers)
|
427
|
+
print(f" Token response status: {token_response.status_code}")
|
428
|
+
|
409
429
|
if token_response.status_code == 200:
|
410
|
-
|
430
|
+
result = token_response.json()
|
431
|
+
if 'result' in result:
|
432
|
+
token = result['result']
|
433
|
+
print(f" ✅ Got tunnel token")
|
434
|
+
else:
|
435
|
+
print(f" ❌ No token in response: {result}")
|
436
|
+
return None
|
411
437
|
|
412
438
|
# Check if config file exists with ingress rules
|
413
439
|
if config_file.exists():
|
@@ -432,8 +458,20 @@ class CloudflareAPITunnel:
|
|
432
458
|
"--token", token
|
433
459
|
]
|
434
460
|
else:
|
435
|
-
print("❌ Could not get tunnel token")
|
436
|
-
|
461
|
+
print(f"❌ Could not get tunnel token: {token_response.status_code}")
|
462
|
+
if token_response.text:
|
463
|
+
print(f" Error: {token_response.text}")
|
464
|
+
|
465
|
+
# If 404, tunnel doesn't exist or we don't have access
|
466
|
+
if token_response.status_code == 404:
|
467
|
+
print(f"🔄 Tunnel not accessible (404), will try to recreate...")
|
468
|
+
# Mark for recreation
|
469
|
+
device_tunnel['needs_recreation'] = True
|
470
|
+
return None
|
471
|
+
else:
|
472
|
+
print(f" ℹ️ Token endpoint returned {token_response.status_code}")
|
473
|
+
print(f" This might mean the tunnel needs to be recreated manually")
|
474
|
+
return None
|
437
475
|
|
438
476
|
# Only use credentials if we haven't already set cmd with token
|
439
477
|
if cmd is None and creds_file.exists():
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|