Add option for named cloudflare tunnels (#3364)

This commit is contained in:
Friedemann Lipphardt 2023-08-09 03:20:27 +02:00 committed by GitHub
parent 4ba30f6765
commit 901b028d55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 18 additions and 15 deletions

View file

@ -86,12 +86,12 @@ def build_parameters(body, chat=False):
return generate_params
def try_start_cloudflared(port: int, max_attempts: int = 3, on_start: Optional[Callable[[str], None]] = None):
def try_start_cloudflared(port: int, tunnel_id: str, max_attempts: int = 3, on_start: Optional[Callable[[str], None]] = None):
Thread(target=_start_cloudflared, args=[
port, max_attempts, on_start], daemon=True).start()
port, tunnel_id, max_attempts, on_start], daemon=True).start()
def _start_cloudflared(port: int, max_attempts: int = 3, on_start: Optional[Callable[[str], None]] = None):
def _start_cloudflared(port: int, tunnel_id: str, max_attempts: int = 3, on_start: Optional[Callable[[str], None]] = None):
try:
from flask_cloudflared import _run_cloudflared
except ImportError:
@ -101,7 +101,7 @@ def _start_cloudflared(port: int, max_attempts: int = 3, on_start: Optional[Call
for _ in range(max_attempts):
try:
public_url = _run_cloudflared(port, port + 1)
public_url = _run_cloudflared(port, port + 1, tunnel_id=tunnel_id)
if on_start:
on_start(public_url)