# File: /Users/bpa/Desktop/ForesixaQuant/start_mobile_tunnel.py
import subprocess
import os

def launch_clean_tunnel():
    binary_path = "/Users/bpa/Desktop/ForesixaQuant/cloudflared"
    config_path = "/Users/bpa/Desktop/ForesixaQuant/qzotic_mobile_config.yml"
    
    # 🎯 FORCE-WRITE THE PRISTINE STRUCTURE AGAIN TO BE ABSOLUTELY SURE
    with open(config_path, "w") as f:
        f.write("tunnel: 34317c32-97ce-4b0a-975b-478d6d4a5a97\n")
        f.write("credentials-file: /Users/bpa/.cloudflared/34317c32-97ce-4b0a-975b-478d6d4a5a97.json\n\n")
        f.write("ingress:\n")
        f.write("  - hostname: ://sotality.com\n")
        f.write("    service: http://127.0.0.1:8765\n")
        f.write("  - service: http_status:404\n")

    print("🚀 Triggering uncompromised, bare-metal tunnel deployment...")
    cmd = [binary_path, "tunnel", "--config", config_path, "run"]
    
    # Run natively without system shell parameter interpretation
    subprocess.run(cmd)

if __name__ == '__main__':
    launch_clean_tunnel()
