#!/usr/bin/env python3 """Self-signed https server on :443 serving the client well-known with the LiveKit focus for the local calls stack (see scripts/dev-homeserver.sh calls).""" import http.server, os, ssl, json BODY = json.dumps({"m.homeserver": {"base_url": "http://localhost:8008"}, "org.matrix.msc4143.rtc_foci": [{"type": "livekit", "livekit_service_url": "http://127.0.0.1:8070"}]}).encode() class H(http.server.BaseHTTPRequestHandler): def do_GET(self): if self.path.startswith('/.well-known/matrix/client'): self.send_response(200); self.send_header('Content-Type','application/json'); self.send_header('Access-Control-Allow-Origin','*'); self.send_header('Content-Length',str(len(BODY))); self.end_headers(); self.wfile.write(BODY) else: self.send_response(404); self.end_headers() def log_message(self,*a): pass srv = http.server.ThreadingHTTPServer(('127.0.0.1', 443), H) ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER); ctx.load_cert_chain(os.environ.get('CERT', 'wk.crt'), os.environ.get('KEY', 'wk.key')); srv.socket = ctx.wrap_socket(srv.socket, server_side=True) srv.serve_forever()