Добавление PWA

This commit is contained in:
Petro1990 2025-11-24 23:24:27 +03:00
parent c217b83ad8
commit acf9360ad7
2 changed files with 3 additions and 27 deletions

View File

@ -1,12 +1,5 @@
#!/bin/sh
# Проверка наличия openssl
if ! command -v openssl &> /dev/null; then
echo "openssl not found. Please install it first."
# opkg update && opkg install openssl-utils (example for OpenWrt)
exit 1
fi
# Определяем директорию, в которой находится скрипт
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)

View File

@ -12,7 +12,6 @@ import time
import shutil
import glob
import json
import ssl
from datetime import datetime
# --- НАСТРОЙКИ ---
@ -1028,23 +1027,7 @@ class H(http.server.SimpleHTTPRequestHandler):
try:
# Создаем самоподписанный сертификат "на лету"
certfile = '/tmp/mihomo_cert.pem'
keyfile = '/tmp/mihomo_key.pem'
if not os.path.exists(certfile):
subprocess.call('openssl req -new -x509 -keyout {k} -out {c} -days 365 -nodes -subj "/C=US/ST=CA/L=./O=./CN=localhost"'.format(k=keyfile, c=certfile), shell=True, stderr=subprocess.DEVNULL)
server_address = ('', PORT)
httpd = http.server.HTTPServer(server_address, H)
httpd.socket = ssl.wrap_socket(httpd.socket,
server_side=True,
certfile=certfile,
keyfile=keyfile,
ssl_version=ssl.PROTOCOL_TLS)
print(f"Server running on https://localhost:{PORT}")
httpd.serve_forever()
except Exception as e:
print(f"Failed to start HTTPS server: {e}")
print("Fallback to HTTP...")
socketserver.TCPServer.allow_reuse_address = True
socketserver.TCPServer(("", PORT), H).serve_forever()
socketserver.TCPServer(("", PORT), H).serve_forever()
except Exception as e:
print(e)