aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorNathanael Santoso <73165142+nart4hire@users.noreply.github.com>2023-04-04 06:50:29 +0000
committerNathanael Santoso <73165142+nart4hire@users.noreply.github.com>2023-04-04 06:50:29 +0000
commit5ebe3b25044efac959c4d8f208dd17d6f1e5ce8a (patch)
tree6f223d657edc6b9713d2f8eaf81f1186acfc915c /modules
parent22bcc7be428c94e9408f589966c2040187245d81 (diff)
Added guard clause to prevent multiple tunnel creations
Diffstat (limited to 'modules')
-rw-r--r--modules/ngrok.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/ngrok.py b/modules/ngrok.py
index 3df2c06b..90268bf1 100644
--- a/modules/ngrok.py
+++ b/modules/ngrok.py
@@ -1,6 +1,14 @@
from pyngrok import ngrok, conf, exception
def connect(token, port, region):
+ # Guard for existing tunnels
+ existing = ngrok.get_tunnels()
+ if existing:
+ public_url = existing[0].public_url
+ print(f'ngrok connected to localhost:{port}! URL: {public_url}\n'
+ 'You can use this link after the launch is complete.')
+ return
+
account = None
if token is None:
token = 'None'