unitlab 2.3.40__tar.gz → 2.3.41__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.40/src/unitlab.egg-info → unitlab-2.3.41}/PKG-INFO +1 -1
- {unitlab-2.3.40 → unitlab-2.3.41}/setup.py +1 -1
- {unitlab-2.3.40 → unitlab-2.3.41}/src/unitlab/persistent_tunnel.py +23 -16
- {unitlab-2.3.40 → unitlab-2.3.41/src/unitlab.egg-info}/PKG-INFO +1 -1
- {unitlab-2.3.40 → unitlab-2.3.41}/LICENSE.md +0 -0
- {unitlab-2.3.40 → unitlab-2.3.41}/README.md +0 -0
- {unitlab-2.3.40 → unitlab-2.3.41}/setup.cfg +0 -0
- {unitlab-2.3.40 → unitlab-2.3.41}/src/unitlab/__init__.py +0 -0
- {unitlab-2.3.40 → unitlab-2.3.41}/src/unitlab/__main__.py +0 -0
- {unitlab-2.3.40 → unitlab-2.3.41}/src/unitlab/client.py +0 -0
- {unitlab-2.3.40 → unitlab-2.3.41}/src/unitlab/exceptions.py +0 -0
- {unitlab-2.3.40 → unitlab-2.3.41}/src/unitlab/main.py +0 -0
- {unitlab-2.3.40 → unitlab-2.3.41}/src/unitlab/utils.py +0 -0
- {unitlab-2.3.40 → unitlab-2.3.41}/src/unitlab.egg-info/SOURCES.txt +0 -0
- {unitlab-2.3.40 → unitlab-2.3.41}/src/unitlab.egg-info/dependency_links.txt +0 -0
- {unitlab-2.3.40 → unitlab-2.3.41}/src/unitlab.egg-info/entry_points.txt +0 -0
- {unitlab-2.3.40 → unitlab-2.3.41}/src/unitlab.egg-info/requires.txt +0 -0
- {unitlab-2.3.40 → unitlab-2.3.41}/src/unitlab.egg-info/top_level.txt +0 -0
@@ -14,7 +14,7 @@ from fastapi import FastAPI
|
|
14
14
|
import uvicorn
|
15
15
|
import threading
|
16
16
|
import psutil
|
17
|
-
|
17
|
+
import secrets
|
18
18
|
|
19
19
|
api = FastAPI()
|
20
20
|
|
@@ -67,23 +67,23 @@ class PersistentTunnel:
|
|
67
67
|
"Content-Type": "application/json"
|
68
68
|
}
|
69
69
|
|
70
|
-
def get_or_create_tunnel(self):
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
70
|
+
# def get_or_create_tunnel(self):
|
71
|
+
# """Always create a new tunnel with unique name to avoid conflicts"""
|
72
|
+
# # Generate unique tunnel name to avoid conflicts
|
73
|
+
# import uuid
|
74
|
+
# unique_suffix = str(uuid.uuid4())[:8]
|
75
|
+
# self.tunnel_name = "agent-{}-{}".format(self.device_id, unique_suffix)
|
76
|
+
# print("🔧 Creating tunnel: {}...".format(self.tunnel_name))
|
77
|
+
|
78
|
+
# # Always create new tunnel
|
79
|
+
# return self.create_new_tunnel()
|
80
|
+
|
81
|
+
|
81
82
|
def create_new_tunnel(self):
|
82
|
-
"""Create a
|
83
|
+
"""Create a new tunnel via Cloudflare API"""
|
83
84
|
print("🔧 Creating new tunnel: {}...".format(self.tunnel_name))
|
84
85
|
|
85
86
|
# Generate random tunnel secret (32 bytes)
|
86
|
-
import secrets
|
87
87
|
tunnel_secret = base64.b64encode(secrets.token_bytes(32)).decode()
|
88
88
|
|
89
89
|
url = "https://api.cloudflare.com/client/v4/accounts/{}/cfd_tunnel".format(self.cf_account_id)
|
@@ -107,12 +107,13 @@ class PersistentTunnel:
|
|
107
107
|
"TunnelID": self.tunnel_id
|
108
108
|
}
|
109
109
|
|
110
|
-
# Save credentials to file
|
110
|
+
# Save credentials to file
|
111
111
|
cred_file = "/tmp/tunnel-{}.json".format(self.tunnel_name)
|
112
112
|
with open(cred_file, 'w') as f:
|
113
113
|
json.dump(self.tunnel_credentials, f)
|
114
114
|
|
115
115
|
print("✅ Tunnel created: {}".format(self.tunnel_id))
|
116
|
+
print("✅ Credentials saved to: {}".format(cred_file))
|
116
117
|
return cred_file
|
117
118
|
else:
|
118
119
|
print("❌ Failed to create tunnel: {}".format(response.text))
|
@@ -440,7 +441,7 @@ class PersistentTunnel:
|
|
440
441
|
# API credentials are hardcoded, so we're ready to go
|
441
442
|
|
442
443
|
# 1. Get existing or create new tunnel via API
|
443
|
-
cred_file = self.
|
444
|
+
cred_file = self.create_new_tunnel()
|
444
445
|
|
445
446
|
|
446
447
|
# 2. Create DNS record
|
@@ -490,6 +491,12 @@ class PersistentTunnel:
|
|
490
491
|
self.jupyter_process.terminate()
|
491
492
|
if self.tunnel_process:
|
492
493
|
self.tunnel_process.terminate()
|
494
|
+
try:
|
495
|
+
self.tunnel_process.wait(timeout=5)
|
496
|
+
except subprocess.TimeoutExpired:
|
497
|
+
self.tunnel_process.kill()
|
498
|
+
self.tunnel_process.wait()
|
499
|
+
print("✅ Tunnel stopped")
|
493
500
|
|
494
501
|
# # Optionally delete tunnel when stopping
|
495
502
|
# if self.tunnel_id:
|
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
|