Skip to content

Commit 31c92d0

Browse files
authored
Add timeout to cloud challenge deployment (#116)
1 parent cdabe54 commit 31c92d0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ctfcli/utils/deploy.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,21 @@ def cloud(challenge, host, protocol):
143143
service_id = service["id"]
144144
service = s.get(f"/api/v1/services/{service_id}", json=True).json()["data"]
145145

146-
while service["hostname"] is None:
146+
DEPLOY_TIMEOUT = 180
147+
while service["hostname"] is None and DEPLOY_TIMEOUT > 0:
147148
click.secho(
148149
"Waiting for challenge hostname", fg="yellow",
149150
)
150151
service = s.get(f"/api/v1/services/{service_id}", json=True).json()["data"]
152+
DEPLOY_TIMEOUT -= 10
151153
time.sleep(10)
152154

155+
if DEPLOY_TIMEOUT == 0:
156+
click.secho(
157+
"Timeout waiting for challenge to deploy", fg="red",
158+
)
159+
return False, None, None, None
160+
153161
# Expose port if we are using tcp
154162
if protocol == "tcp":
155163
service = s.patch(f"/api/v1/services/{service['id']}", json={"expose": True})

0 commit comments

Comments
 (0)