mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-11 09:34:37 +00:00
allow ssl with remote tunnel
This commit is contained in:
parent
27b9358baf
commit
b100bcb9e6
1 changed files with 10 additions and 5 deletions
15
koboldcpp.py
15
koboldcpp.py
|
@ -4655,6 +4655,7 @@ def setuptunnel(global_memory, has_sd):
|
||||||
import re
|
import re
|
||||||
global sslvalid
|
global sslvalid
|
||||||
httpsaffix = ("https" if sslvalid else "http")
|
httpsaffix = ("https" if sslvalid else "http")
|
||||||
|
ssladd = (" --no-tls-verify" if sslvalid else "")
|
||||||
def run_tunnel():
|
def run_tunnel():
|
||||||
tunnelproc = None
|
tunnelproc = None
|
||||||
tunneloutput = ""
|
tunneloutput = ""
|
||||||
|
@ -4662,16 +4663,16 @@ def setuptunnel(global_memory, has_sd):
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
print("Starting Cloudflare Tunnel for Windows, please wait...", flush=True)
|
print("Starting Cloudflare Tunnel for Windows, please wait...", flush=True)
|
||||||
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)
|
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)
|
||||||
elif sys.platform=="darwin":
|
elif sys.platform=="darwin":
|
||||||
print("Starting Cloudflare Tunnel for MacOS, please wait...", flush=True)
|
print("Starting Cloudflare Tunnel for MacOS, please wait...", flush=True)
|
||||||
tunnelproc = subprocess.Popen(f"./cloudflared tunnel --url {httpsaffix}://localhost:{args.port}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
|
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)
|
||||||
elif sys.platform == "linux" and platform.machine().lower() == "aarch64":
|
elif sys.platform == "linux" and platform.machine().lower() == "aarch64":
|
||||||
print("Starting Cloudflare Tunnel for ARM64 Linux, please wait...", flush=True)
|
print("Starting Cloudflare Tunnel for ARM64 Linux, please wait...", flush=True)
|
||||||
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)
|
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)
|
||||||
else:
|
else:
|
||||||
print("Starting Cloudflare Tunnel for Linux, please wait...", flush=True)
|
print("Starting Cloudflare Tunnel for Linux, please wait...", flush=True)
|
||||||
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)
|
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)
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
def tunnel_reader():
|
def tunnel_reader():
|
||||||
nonlocal tunnelproc,tunneloutput,tunnelrawlog
|
nonlocal tunnelproc,tunneloutput,tunnelrawlog
|
||||||
|
@ -4929,7 +4930,7 @@ def analyze_gguf_model_wrapper(filename=""):
|
||||||
dumpthread.start()
|
dumpthread.start()
|
||||||
|
|
||||||
def main(launch_args):
|
def main(launch_args):
|
||||||
global args, showdebug, kcpp_instance, exitcounter, using_gui_launcher
|
global args, showdebug, kcpp_instance, exitcounter, using_gui_launcher, sslvalid
|
||||||
args = launch_args #note: these are NOT shared with the child processes!
|
args = launch_args #note: these are NOT shared with the child processes!
|
||||||
|
|
||||||
if (args.version) and len(sys.argv) <= 2:
|
if (args.version) and len(sys.argv) <= 2:
|
||||||
|
@ -5000,6 +5001,10 @@ def main(launch_args):
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
|
if args.ssl: #need to duplicate here for the tunnel
|
||||||
|
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]):
|
||||||
|
sslvalid = True
|
||||||
|
|
||||||
# manager command queue
|
# manager command queue
|
||||||
with multiprocessing.Manager() as mp_manager:
|
with multiprocessing.Manager() as mp_manager:
|
||||||
global_memory = mp_manager.dict({"tunnel_url": "", "restart_target":"", "input_to_exit":False})
|
global_memory = mp_manager.dict({"tunnel_url": "", "restart_target":"", "input_to_exit":False})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue