aboutsummaryrefslogtreecommitdiffstats
path: root/modules/ngrok.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-04-29 19:13:40 +0000
committerGitHub <noreply@github.com>2023-04-29 19:13:40 +0000
commit15c4e78b44e14d70b82dcb5b563251fed7be0766 (patch)
tree6f1acaae50a49544a08384b52739df3e2d803a10 /modules/ngrok.py
parent3e5b3c79e49ec3a10174c250815dabce6efdddca (diff)
parent2e78e65a22bfa6b116ae18d12fdcb85ec8acd727 (diff)
downloadstable-diffusion-webui-gfx803-15c4e78b44e14d70b82dcb5b563251fed7be0766.tar.gz
stable-diffusion-webui-gfx803-15c4e78b44e14d70b82dcb5b563251fed7be0766.tar.bz2
stable-diffusion-webui-gfx803-15c4e78b44e14d70b82dcb5b563251fed7be0766.zip
Merge branch 'dev' into feature/restore-progress
Diffstat (limited to 'modules/ngrok.py')
-rw-r--r--modules/ngrok.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/ngrok.py b/modules/ngrok.py
index 3df2c06b..1ad7989b 100644
--- a/modules/ngrok.py
+++ b/modules/ngrok.py
@@ -13,6 +13,18 @@ def connect(token, port, region):
config = conf.PyngrokConfig(
auth_token=token, region=region
)
+
+ # Guard for existing tunnels
+ existing = ngrok.get_tunnels(pyngrok_config=config)
+ if existing:
+ for established in existing:
+ # Extra configuration in the case that the user is also using ngrok for other tunnels
+ if established.config['addr'][-4:] == str(port):
+ public_url = existing[0].public_url
+ print(f'ngrok has already been connected to localhost:{port}! URL: {public_url}\n'
+ 'You can use this link after the launch is complete.')
+ return
+
try:
if account is None:
public_url = ngrok.connect(port, pyngrok_config=config, bind_tls=True).public_url