Skip to content

Commit b100bcb

Browse files
committed
allow ssl with remote tunnel
1 parent 27b9358 commit b100bcb

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

koboldcpp.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -4655,23 +4655,24 @@ def setuptunnel(global_memory, has_sd):
46554655
import re
46564656
global sslvalid
46574657
httpsaffix = ("https" if sslvalid else "http")
4658+
ssladd = (" --no-tls-verify" if sslvalid else "")
46584659
def run_tunnel():
46594660
tunnelproc = None
46604661
tunneloutput = ""
46614662
tunnelrawlog = ""
46624663
time.sleep(0.2)
46634664
if os.name == 'nt':
46644665
print("Starting Cloudflare Tunnel for Windows, please wait...", flush=True)
4665-
tunnelproc = subprocess.Popen(f"cloudflared.exe tunnel --url {httpsaffix}://localhost:{args.port}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
4666+
tunnelproc = subprocess.Popen(f"cloudflared.exe tunnel --url {httpsaffix}://localhost:{args.port}{ssladd}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
46664667
elif sys.platform=="darwin":
46674668
print("Starting Cloudflare Tunnel for MacOS, please wait...", flush=True)
4668-
tunnelproc = subprocess.Popen(f"./cloudflared tunnel --url {httpsaffix}://localhost:{args.port}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
4669+
tunnelproc = subprocess.Popen(f"./cloudflared tunnel --url {httpsaffix}://localhost:{args.port}{ssladd}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
46694670
elif sys.platform == "linux" and platform.machine().lower() == "aarch64":
46704671
print("Starting Cloudflare Tunnel for ARM64 Linux, please wait...", flush=True)
4671-
tunnelproc = subprocess.Popen(f"./cloudflared-linux-arm64 tunnel --url {httpsaffix}://localhost:{args.port}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
4672+
tunnelproc = subprocess.Popen(f"./cloudflared-linux-arm64 tunnel --url {httpsaffix}://localhost:{args.port}{ssladd}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
46724673
else:
46734674
print("Starting Cloudflare Tunnel for Linux, please wait...", flush=True)
4674-
tunnelproc = subprocess.Popen(f"./cloudflared-linux-amd64 tunnel --url {httpsaffix}://localhost:{args.port}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
4675+
tunnelproc = subprocess.Popen(f"./cloudflared-linux-amd64 tunnel --url {httpsaffix}://localhost:{args.port}{ssladd}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
46754676
time.sleep(10)
46764677
def tunnel_reader():
46774678
nonlocal tunnelproc,tunneloutput,tunnelrawlog
@@ -4929,7 +4930,7 @@ def analyze_gguf_model_wrapper(filename=""):
49294930
dumpthread.start()
49304931

49314932
def main(launch_args):
4932-
global args, showdebug, kcpp_instance, exitcounter, using_gui_launcher
4933+
global args, showdebug, kcpp_instance, exitcounter, using_gui_launcher, sslvalid
49334934
args = launch_args #note: these are NOT shared with the child processes!
49344935

49354936
if (args.version) and len(sys.argv) <= 2:
@@ -5000,6 +5001,10 @@ def main(launch_args):
50005001
time.sleep(3)
50015002
sys.exit(2)
50025003

5004+
if args.ssl: #need to duplicate here for the tunnel
5005+
if len(args.ssl)==2 and isinstance(args.ssl[0], str) and os.path.exists(args.ssl[0]) and isinstance(args.ssl[1], str) and os.path.exists(args.ssl[1]):
5006+
sslvalid = True
5007+
50035008
# manager command queue
50045009
with multiprocessing.Manager() as mp_manager:
50055010
global_memory = mp_manager.dict({"tunnel_url": "", "restart_target":"", "input_to_exit":False})

0 commit comments

Comments
 (0)