Добавление PWA
This commit is contained in:
parent
c217b83ad8
commit
acf9360ad7
|
|
@ -1,12 +1,5 @@
|
||||||
#!/bin/sh
|
#!/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)
|
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ import time
|
||||||
import shutil
|
import shutil
|
||||||
import glob
|
import glob
|
||||||
import json
|
import json
|
||||||
import ssl
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
# --- НАСТРОЙКИ ---
|
# --- НАСТРОЙКИ ---
|
||||||
|
|
@ -1028,23 +1027,7 @@ class H(http.server.SimpleHTTPRequestHandler):
|
||||||
|
|
||||||
|
|
||||||
try:
|
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.allow_reuse_address = True
|
||||||
socketserver.TCPServer(("", PORT), H).serve_forever()
|
socketserver.TCPServer(("", PORT), H).serve_forever()
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
Loading…
Reference in New Issue