unitlab 2.3.39__py3-none-any.whl → 2.3.40__py3-none-any.whl

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.
@@ -56,24 +56,7 @@ class PersistentTunnel:
56
56
  self.jupyter_process = None
57
57
  self.tunnel_process = None
58
58
 
59
- def get_zone_id(self):
60
- """Get Zone ID for unitlab-ai.com"""
61
- print("🔍 Getting Zone ID for {}...".format(self.domain))
62
-
63
- url = "https://api.cloudflare.com/client/v4/zones"
64
- headers = self._get_headers()
65
- params = {"name": self.domain}
66
-
67
- response = requests.get(url, headers=headers, params=params)
68
- if response.status_code == 200:
69
- data = response.json()
70
- if data["result"]:
71
- self.cf_zone_id = data["result"][0]["id"]
72
- print("✅ Zone ID: {}".format(self.cf_zone_id))
73
- return self.cf_zone_id
74
-
75
- print("❌ Could not get Zone ID")
76
- return None
59
+
77
60
 
78
61
  def _get_headers(self):
79
62
  """Get API headers for Global API Key"""
@@ -142,9 +125,7 @@ class PersistentTunnel:
142
125
 
143
126
  print("🔧 Creating DNS records...")
144
127
 
145
- # Get zone ID if we don't have it
146
- if self.cf_zone_id == "NEED_ZONE_ID_FOR_1SCAN_UZ":
147
- self.get_zone_id()
128
+ # self.get_zone_id()
148
129
 
149
130
  url = "https://api.cloudflare.com/client/v4/zones/{}/dns_records".format(self.cf_zone_id)
150
131
  headers = self._get_headers()
@@ -168,7 +149,32 @@ class PersistentTunnel:
168
149
  print("❌ Failed to create main DNS: {}".format(response.text[:200]))
169
150
  return False
170
151
 
171
- # Create SSH subdomain record (s{deviceid}.unitlab-ai.com)
152
+ # First, check if SSH DNS record exists and delete it
153
+ print("🔍 Checking for existing SSH DNS record: {}.{}".format(self.ssh_subdomain, self.domain))
154
+ list_url = "{}?name={}.{}".format(url, self.ssh_subdomain, self.domain)
155
+ list_response = requests.get(list_url, headers=headers)
156
+
157
+ if list_response.status_code == 200:
158
+ records = list_response.json().get("result", [])
159
+ print("Found {} existing DNS records".format(len(records)))
160
+ print('this is new version')
161
+ for record in records:
162
+ if record["name"] == "{}.{}".format(self.ssh_subdomain, self.domain):
163
+ record_id = record["id"]
164
+ print("🗑️ Deleting old SSH DNS record: {}".format(record_id))
165
+ delete_url = "{}/{}".format(url, record_id)
166
+ delete_response = requests.delete(delete_url, headers=headers)
167
+ if delete_response.status_code in [200, 204]:
168
+ print("✅ Deleted old SSH DNS record")
169
+ else:
170
+ print("⚠️ Could not delete old SSH DNS record: {}".format(delete_response.text[:200]))
171
+ else:
172
+ print("⚠️ Could not list DNS records: {}".format(list_response.text[:200]))
173
+
174
+ # Wait a moment for DNS deletion to propagate
175
+ time.sleep(2)
176
+
177
+ # Create new SSH subdomain record pointing to new tunnel
172
178
  ssh_data = {
173
179
  "type": "CNAME",
174
180
  "name": self.ssh_subdomain,
@@ -177,31 +183,22 @@ class PersistentTunnel:
177
183
  "ttl": 1
178
184
  }
179
185
 
186
+ print("📝 Creating SSH DNS record: {} -> {}".format(self.ssh_subdomain, self.tunnel_id))
180
187
  ssh_response = requests.post(url, headers=headers, json=ssh_data)
181
188
 
182
189
  if ssh_response.status_code in [200, 201]:
183
190
  print("✅ SSH DNS record created: {}.{}".format(self.ssh_subdomain, self.domain))
184
- elif "already exists" in ssh_response.text:
185
- print("⚠️ SSH DNS record already exists, deleting and recreating...")
186
- # Delete the old record and create new one
187
- list_url = "{}?name={}.{}".format(url, self.ssh_subdomain, self.domain)
188
- list_response = requests.get(list_url, headers=headers)
189
- if list_response.status_code == 200:
190
- records = list_response.json().get("result", [])
191
- if records:
192
- record_id = records[0]["id"]
193
- delete_url = "{}/{}".format(url, record_id)
194
- requests.delete(delete_url, headers=headers)
195
- print("Deleted old SSH DNS record")
196
- # Try again
197
- ssh_response = requests.post(url, headers=headers, json=ssh_data)
198
- if ssh_response.status_code in [200, 201]:
199
- print("✅ SSH DNS record recreated: {}.{}".format(self.ssh_subdomain, self.domain))
200
- else:
201
- print("❌ Failed to recreate SSH DNS: {}".format(ssh_response.text[:200]))
191
+ print(" Points to: {}.cfargotunnel.com".format(self.tunnel_id))
202
192
  else:
203
- print("❌ Could not create SSH DNS: {}".format(ssh_response.text[:200]))
204
- # SSH is optional, so we continue even if SSH DNS fails
193
+ print("❌ Failed to create SSH DNS: Status {} - {}".format(ssh_response.status_code, ssh_response.text))
194
+ # Try to parse error
195
+ try:
196
+ error_data = ssh_response.json()
197
+ if "errors" in error_data:
198
+ for error in error_data["errors"]:
199
+ print(" Error: {}".format(error.get("message", error)))
200
+ except:
201
+ pass
205
202
 
206
203
  return True
207
204
 
@@ -243,6 +240,7 @@ class PersistentTunnel:
243
240
 
244
241
  policy_response = requests.post(policy_url, headers=headers, json=policy_data)
245
242
 
243
+
246
244
  if policy_response.status_code in [200, 201]:
247
245
  print("✅ Bypass policy created - SSH is publicly accessible")
248
246
  return True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unitlab
3
- Version: 2.3.39
3
+ Version: 2.3.40
4
4
  Home-page: https://github.com/teamunitlab/unitlab-sdk
5
5
  Author: Unitlab Inc.
6
6
  Author-email: team@unitlab.ai
@@ -3,11 +3,11 @@ unitlab/__main__.py,sha256=6Hs2PV7EYc5Tid4g4OtcLXhqVHiNYTGzSBdoOnW2HXA,29
3
3
  unitlab/client.py,sha256=wqREtDuYc5ixeloPEGm0hp1sdUtB59sB1bIJjBcO1y0,25983
4
4
  unitlab/exceptions.py,sha256=68Tr6LreEzjQ3Vns8HAaWdtewtkNUJOvPazbf6NSnXU,950
5
5
  unitlab/main.py,sha256=RbuCUaExvOEoA33T9O0hnr94R-L70RXyMjQshxRWR-o,4421
6
- unitlab/persistent_tunnel.py,sha256=CcZYD3fBN6WP_PzvBIomTMakfsR4GtlsfBarUWflBi0,22366
6
+ unitlab/persistent_tunnel.py,sha256=NkXoTK3yn2mVN3hHoUqSQI-8ph_yfBU_YgEFumynyvo,22313
7
7
  unitlab/utils.py,sha256=9gPRu-d6pbhSoVdll1GXe4eoz_uFYOSbYArFDQdlUZs,1922
8
- unitlab-2.3.39.dist-info/licenses/LICENSE.md,sha256=Gn7RRvByorAcAaM-WbyUpsgi5ED1-bKFFshbWfYYz2Y,1069
9
- unitlab-2.3.39.dist-info/METADATA,sha256=3Y0CIEPDzVkfL3dcfpbND4dy3QWzNZo00Ir45YBKDmk,1046
10
- unitlab-2.3.39.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
- unitlab-2.3.39.dist-info/entry_points.txt,sha256=ig-PjKEqSCj3UTdyANgEi4tsAU84DyXdaOJ02NHX4bY,45
12
- unitlab-2.3.39.dist-info/top_level.txt,sha256=Al4ZlTYE3fTJK2o6YLCDMH5_DjuQkffRBMxgmWbKaqQ,8
13
- unitlab-2.3.39.dist-info/RECORD,,
8
+ unitlab-2.3.40.dist-info/licenses/LICENSE.md,sha256=Gn7RRvByorAcAaM-WbyUpsgi5ED1-bKFFshbWfYYz2Y,1069
9
+ unitlab-2.3.40.dist-info/METADATA,sha256=Wy1EHazXknuZ_jJYBjcKB_iXOvP3X4Rtt0MEUeeSKwc,1046
10
+ unitlab-2.3.40.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
+ unitlab-2.3.40.dist-info/entry_points.txt,sha256=ig-PjKEqSCj3UTdyANgEi4tsAU84DyXdaOJ02NHX4bY,45
12
+ unitlab-2.3.40.dist-info/top_level.txt,sha256=Al4ZlTYE3fTJK2o6YLCDMH5_DjuQkffRBMxgmWbKaqQ,8
13
+ unitlab-2.3.40.dist-info/RECORD,,