Skip to content

Commit

Permalink
feat: custom bore url
Browse files Browse the repository at this point in the history
  • Loading branch information
Bing-su committed May 5, 2023
1 parent bed377f commit b41aaa3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ You can get a token [here](https://jprq.io/auth).

add `--bore` to commandline options.

add `--bore_url "URL"` for custom bore url. url without 'http://' and (optional) port. example: myboreserver.com or myboreserver.com:12345

-----
### Discord webhook

Expand Down
6 changes: 6 additions & 0 deletions preload.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ def preload(parser: argparse.ArgumentParser):
help="use bore, alternative to gradio --share",
)

parser.add_argument(
"--bore_url",
type=str,
help="custom bore url. url without 'http://' and (optional) port. example: myboreserver.com or myboreserver.com:12345",
)

parser.add_argument(
"--tunnel-webhook", type=str, help="discord webhook to send tunnel url to"
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "sd-webui-tunnels"
version = "23.4.2"
version = "23.5.0"
description = "Tunneling extension for automatic1111 sd-webui"
authors = [
{name = "dowon", email = "ks2515@naver.com"},
Expand Down
19 changes: 18 additions & 1 deletion scripts/tntn_tunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
from discord_webhook import send_to_discord
from modules.shared import cmd_opts


def bore_url(s: str):
if ":" in s:
host, port = s.split(":")
port = int(port)
else:
host = s
port = None
return host, port


port = cmd_opts.port if cmd_opts.port else 7860

if cmd_opts.jprq:
Expand All @@ -19,7 +30,13 @@ def jprq_callback(*args, **kwargs):
script_callbacks.on_app_started(jprq_callback)

if cmd_opts.bore:
bore_urls = bore(port)
host, bore_port = bore_url(cmd_opts.bore_url) if cmd_opts.bore_url else (None, None)
kwargs = {}
if host is not None:
kwargs["bore_url"] = host
if bore_port is not None:
kwargs["bore_port"] = bore_port
bore_urls = bore(port, **kwargs)

if cmd_opts.tunnel_webhook:
send_to_discord(bore_urls.tunnel, cmd_opts.tunnel_webhook)

0 comments on commit b41aaa3

Please sign in to comment.