-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhyperbweb-https
More file actions
executable file
Β·198 lines (171 loc) Β· 6.3 KB
/
hyperbweb-https
File metadata and controls
executable file
Β·198 lines (171 loc) Β· 6.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#!/data/data/com.termux/files/usr/bin/bash
# HyperBWeb HTTPS - Secure AR Music Web Launcher
# Creates HTTPS server for WebXR compatibility
echo "π HyperBWeb HTTPS - Secure AR Music Launcher"
echo "=============================================="
# Default values
PORT=8443
FILE="ar-music-immersion.html"
DIRECTORY="/data/data/com.termux/files/home/3dsynth/rokidmaxwmdapi"
CERT_DIR="$DIRECTORY/ssl"
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-p|--port)
PORT="$2"
shift 2
;;
-f|--file)
FILE="$2"
shift 2
;;
-d|--directory)
DIRECTORY="$2"
shift 2
;;
-h|--help)
echo "HyperBWeb HTTPS - Secure AR Music Launcher"
echo ""
echo "Usage: hyperbweb-https [OPTIONS]"
echo ""
echo "Options:"
echo " -p, --port PORT Port number (default: 8443)"
echo " -f, --file FILE HTML file to serve (default: ar-music-immersion.html)"
echo " -d, --directory DIR Directory to serve from"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " hyperbweb-https # Start with defaults"
echo " hyperbweb-https -p 9443 # Use port 9443"
echo ""
echo "Note: Creates self-signed SSL certificate automatically"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use -h for help"
exit 1
;;
esac
done
# Check if directory exists
if [ ! -d "$DIRECTORY" ]; then
echo "β Error: Directory $DIRECTORY does not exist"
exit 1
fi
# Check if file exists
if [ ! -f "$DIRECTORY/$FILE" ]; then
echo "β Error: File $DIRECTORY/$FILE does not exist"
echo "Available files:"
ls "$DIRECTORY"/*.html 2>/dev/null || echo "No HTML files found"
exit 1
fi
# Create SSL directory
mkdir -p "$CERT_DIR"
# Generate self-signed certificate if it doesn't exist
if [ ! -f "$CERT_DIR/server.crt" ] || [ ! -f "$CERT_DIR/server.key" ]; then
echo "π Generating self-signed SSL certificate..."
openssl req -x509 -newkey rsa:4096 -keyout "$CERT_DIR/server.key" -out "$CERT_DIR/server.crt" \
-days 365 -nodes -subj "/C=US/ST=State/L=City/O=Organization/CN=localhost" \
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1,IP:10.172.80.105" 2>/dev/null
if [ $? -eq 0 ]; then
echo "β
SSL certificate generated successfully"
else
echo "β Failed to generate SSL certificate"
exit 1
fi
else
echo "β
Using existing SSL certificate"
fi
# Get local IP address
LOCAL_IP=$(ip route get 1.1.1.1 | grep -oP 'src \K\S+' 2>/dev/null || echo "localhost")
echo "π Serving directory: $DIRECTORY"
echo "π Main file: $FILE"
echo "π HTTPS Port: $PORT"
echo "π Local URL: https://localhost:$PORT/$FILE"
echo "π Network URL: https://$LOCAL_IP:$PORT/$FILE"
echo ""
echo "π΅ AR Music Immersion Features:"
echo " β’ Secure HTTPS for WebXR compatibility"
echo " β’ Self-signed certificate (accept in browser)"
echo " β’ Full AR mode support"
echo " β’ Hand gesture controls"
echo " β’ 5 immersive visualizations"
echo ""
echo "π± Instructions:"
echo " 1. Open the HTTPS URL in Chrome"
echo " 2. Accept the self-signed certificate warning"
echo " 3. Click 'Enter AR Mode'"
echo " 4. Put on Rokid Max2 glasses"
echo ""
echo "π€² Gesture Controls:"
echo " β’ Wave up/down β Volume"
echo " β’ Pinch & twist β Filter"
echo " β’ Point forward β Switch viz"
echo " β’ Air tap β Drums"
echo ""
echo "β‘ Starting HTTPS server..."
echo " Press Ctrl+C to stop"
echo ""
# Change to the directory
cd "$DIRECTORY" || exit 1
# Function to handle cleanup
cleanup() {
echo ""
echo "π Stopping HTTPS server..."
echo "β¨ Thanks for using AR Music Immersion!"
exit 0
}
# Set up signal handlers
trap cleanup SIGINT SIGTERM
# Check if port is available
if netstat -tuln 2>/dev/null | grep -q ":$PORT "; then
echo "β οΈ Warning: Port $PORT appears to be in use"
echo " Trying to start anyway..."
fi
# Start the HTTPS server
echo "π HTTPS Server is running!"
echo " Browse to: https://localhost:$PORT/$FILE"
echo " β οΈ Accept certificate warning when prompted"
echo ""
# Enhanced Python HTTPS server with CORS headers for WebXR
python3 -c "
import http.server
import socketserver
import ssl
import os
from functools import partial
class CORSHTTPSRequestHandler(http.server.SimpleHTTPRequestHandler):
def end_headers(self):
# WebXR security headers
self.send_header('Cross-Origin-Embedder-Policy', 'require-corp')
self.send_header('Cross-Origin-Opener-Policy', 'same-origin')
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
self.send_header('Access-Control-Allow-Headers', '*')
# WebXR permissions
self.send_header('Permissions-Policy', 'camera=*, microphone=*, xr-spatial-tracking=*')
self.send_header('Feature-Policy', 'camera *; microphone *; xr-spatial-tracking *')
# Security headers
self.send_header('Strict-Transport-Security', 'max-age=31536000; includeSubDomains')
self.send_header('X-Content-Type-Options', 'nosniff')
self.send_header('X-Frame-Options', 'SAMEORIGIN')
super().end_headers()
def do_OPTIONS(self):
self.send_response(200)
self.end_headers()
def log_message(self, format, *args):
# Custom logging with HTTPS indicator
print(f'π {self.address_string()} - {format % args}')
# Create HTTPS server
Handler = partial(CORSHTTPSRequestHandler)
httpd = socketserver.TCPServer(('', $PORT), Handler)
# Wrap with SSL
context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
context.load_cert_chain('ssl/server.crt', 'ssl/server.key')
httpd.socket = context.wrap_socket(httpd.socket, server_side=True)
print(f'π HTTPS AR Music server ready at https://localhost:$PORT/$FILE')
print('β οΈ You will need to accept the self-signed certificate warning')
print('π΅ WebXR AR mode should now work properly!')
httpd.serve_forever()
"