Spaces:
Sleeping
Sleeping
likhonsheikh
commited on
Commit
·
dfd9494
1
Parent(s):
f464ee5
Test with zero dependencies - pure Python HTTP server
Browse files- app.py +99 -33
- app_static.py +120 -0
- requirements.txt +1 -2
- requirements_static.txt +1 -0
app.py
CHANGED
|
@@ -1,22 +1,91 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
-
|
| 4 |
-
|
| 5 |
"""
|
| 6 |
|
| 7 |
-
import
|
|
|
|
|
|
|
|
|
|
| 8 |
from datetime import datetime
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
client
|
| 17 |
dev tun
|
| 18 |
-
proto {protocol}
|
| 19 |
-
remote {
|
| 20 |
resolv-retry infinite
|
| 21 |
nobind
|
| 22 |
persist-key
|
|
@@ -25,30 +94,27 @@ remote-cert-tls server
|
|
| 25 |
cipher AES-256-GCM
|
| 26 |
auth SHA256
|
| 27 |
verb 3
|
| 28 |
-
"""
|
| 29 |
-
return config
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
gr.Button("Generate Config").click(
|
| 45 |
-
create_config,
|
| 46 |
-
inputs=[client_name, server_host, port, protocol],
|
| 47 |
-
outputs=[config_output]
|
| 48 |
-
)
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
| 51 |
|
| 52 |
if __name__ == "__main__":
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
+
Ultra-minimal static web server for OpenVPN config
|
| 4 |
+
No external dependencies except built-in Python modules
|
| 5 |
"""
|
| 6 |
|
| 7 |
+
import http.server
|
| 8 |
+
import socketserver
|
| 9 |
+
import json
|
| 10 |
+
from urllib.parse import parse_qs, urlparse
|
| 11 |
from datetime import datetime
|
| 12 |
|
| 13 |
+
class OpenVPNConfigHandler(http.server.SimpleHTTPRequestHandler):
|
| 14 |
+
def do_GET(self):
|
| 15 |
+
if self.path == '/':
|
| 16 |
+
self.send_response(200)
|
| 17 |
+
self.send_header('Content-type', 'text/html')
|
| 18 |
+
self.end_headers()
|
| 19 |
+
html_content = """<!DOCTYPE html>
|
| 20 |
+
<html>
|
| 21 |
+
<head>
|
| 22 |
+
<title>OpenVPN Configuration Manager</title>
|
| 23 |
+
<style>
|
| 24 |
+
body { font-family: Arial, sans-serif; margin: 40px; background: #f5f5f5; }
|
| 25 |
+
.container { max-width: 800px; margin: 0 auto; background: white; padding: 30px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
|
| 26 |
+
h1 { color: #2563eb; text-align: center; }
|
| 27 |
+
.form-group { margin: 20px 0; }
|
| 28 |
+
label { display: block; margin-bottom: 5px; font-weight: bold; }
|
| 29 |
+
input, select { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 5px; }
|
| 30 |
+
button { background: #2563eb; color: white; padding: 12px 24px; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; }
|
| 31 |
+
button:hover { background: #1d4ed8; }
|
| 32 |
+
.output { margin-top: 20px; }
|
| 33 |
+
textarea { width: 100%; height: 300px; font-family: monospace; border: 1px solid #ddd; border-radius: 5px; padding: 10px; }
|
| 34 |
+
</style>
|
| 35 |
+
</head>
|
| 36 |
+
<body>
|
| 37 |
+
<div class="container">
|
| 38 |
+
<h1>🔒 OpenVPN Configuration Generator</h1>
|
| 39 |
+
<form id="configForm">
|
| 40 |
+
<div class="form-group">
|
| 41 |
+
<label for="clientName">Client Name:</label>
|
| 42 |
+
<input type="text" id="clientName" name="clientName" value="client1" required>
|
| 43 |
+
</div>
|
| 44 |
+
<div class="form-group">
|
| 45 |
+
<label for="serverHost">Server Host:</label>
|
| 46 |
+
<input type="text" id="serverHost" name="serverHost" value="vpn.example.com" required>
|
| 47 |
+
</div>
|
| 48 |
+
<div class="form-group">
|
| 49 |
+
<label for="serverPort">Server Port:</label>
|
| 50 |
+
<input type="number" id="serverPort" name="serverPort" value="1194" required>
|
| 51 |
+
</div>
|
| 52 |
+
<div class="form-group">
|
| 53 |
+
<label for="protocol">Protocol:</label>
|
| 54 |
+
<select id="protocol" name="protocol">
|
| 55 |
+
<option value="udp">UDP</option>
|
| 56 |
+
<option value="tcp">TCP</option>
|
| 57 |
+
</select>
|
| 58 |
+
</div>
|
| 59 |
+
<button type="submit">Generate Configuration</button>
|
| 60 |
+
</form>
|
| 61 |
+
<div class="output">
|
| 62 |
+
<label for="configOutput">Generated Configuration:</label>
|
| 63 |
+
<textarea id="configOutput" readonly></textarea>
|
| 64 |
+
</div>
|
| 65 |
+
</div>
|
| 66 |
+
<script>
|
| 67 |
+
document.getElementById('configForm').addEventListener('submit', function(e) {
|
| 68 |
+
e.preventDefault();
|
| 69 |
+
const formData = new FormData(this);
|
| 70 |
+
const config = generateConfig(
|
| 71 |
+
formData.get('clientName'),
|
| 72 |
+
formData.get('serverHost'),
|
| 73 |
+
formData.get('serverPort'),
|
| 74 |
+
formData.get('protocol')
|
| 75 |
+
);
|
| 76 |
+
document.getElementById('configOutput').value = config;
|
| 77 |
+
});
|
| 78 |
+
|
| 79 |
+
function generateConfig(clientName, serverHost, serverPort, protocol) {
|
| 80 |
+
const now = new Date().toLocaleString();
|
| 81 |
+
return `# OpenVPN Client Configuration
|
| 82 |
+
# Generated: ${now}
|
| 83 |
+
# Client: ${clientName}
|
| 84 |
|
| 85 |
client
|
| 86 |
dev tun
|
| 87 |
+
proto ${protocol}
|
| 88 |
+
remote ${serverHost} ${serverPort}
|
| 89 |
resolv-retry infinite
|
| 90 |
nobind
|
| 91 |
persist-key
|
|
|
|
| 94 |
cipher AES-256-GCM
|
| 95 |
auth SHA256
|
| 96 |
verb 3
|
|
|
|
|
|
|
| 97 |
|
| 98 |
+
# Security Notes:
|
| 99 |
+
# - Use strong ciphers (AES-256-GCM)
|
| 100 |
+
# - Enable certificate verification
|
| 101 |
+
# - Keep certificates secure
|
| 102 |
+
# - Update regularly`;
|
| 103 |
+
}
|
| 104 |
+
</script>
|
| 105 |
+
</body>
|
| 106 |
+
</html>"""
|
| 107 |
+
self.wfile.write(html_content.encode())
|
| 108 |
+
else:
|
| 109 |
+
super().do_GET()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
+
def log_message(self, format, *args):
|
| 112 |
+
# Suppress log messages to keep output clean
|
| 113 |
+
pass
|
| 114 |
|
| 115 |
if __name__ == "__main__":
|
| 116 |
+
PORT = 7860
|
| 117 |
+
with socketserver.TCPServer(("", PORT), OpenVPNConfigHandler) as httpd:
|
| 118 |
+
print(f"OpenVPN Configuration Manager running on port {PORT}")
|
| 119 |
+
print("Access at: http://localhost:7860")
|
| 120 |
+
httpd.serve_forever()
|
app_static.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Ultra-minimal static web server for OpenVPN config
|
| 4 |
+
No external dependencies except built-in Python modules
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import http.server
|
| 8 |
+
import socketserver
|
| 9 |
+
import json
|
| 10 |
+
from urllib.parse import parse_qs, urlparse
|
| 11 |
+
from datetime import datetime
|
| 12 |
+
|
| 13 |
+
class OpenVPNConfigHandler(http.server.SimpleHTTPRequestHandler):
|
| 14 |
+
def do_GET(self):
|
| 15 |
+
if self.path == '/':
|
| 16 |
+
self.send_response(200)
|
| 17 |
+
self.send_header('Content-type', 'text/html')
|
| 18 |
+
self.end_headers()
|
| 19 |
+
html_content = """<!DOCTYPE html>
|
| 20 |
+
<html>
|
| 21 |
+
<head>
|
| 22 |
+
<title>OpenVPN Configuration Manager</title>
|
| 23 |
+
<style>
|
| 24 |
+
body { font-family: Arial, sans-serif; margin: 40px; background: #f5f5f5; }
|
| 25 |
+
.container { max-width: 800px; margin: 0 auto; background: white; padding: 30px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
|
| 26 |
+
h1 { color: #2563eb; text-align: center; }
|
| 27 |
+
.form-group { margin: 20px 0; }
|
| 28 |
+
label { display: block; margin-bottom: 5px; font-weight: bold; }
|
| 29 |
+
input, select { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 5px; }
|
| 30 |
+
button { background: #2563eb; color: white; padding: 12px 24px; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; }
|
| 31 |
+
button:hover { background: #1d4ed8; }
|
| 32 |
+
.output { margin-top: 20px; }
|
| 33 |
+
textarea { width: 100%; height: 300px; font-family: monospace; border: 1px solid #ddd; border-radius: 5px; padding: 10px; }
|
| 34 |
+
</style>
|
| 35 |
+
</head>
|
| 36 |
+
<body>
|
| 37 |
+
<div class="container">
|
| 38 |
+
<h1>🔒 OpenVPN Configuration Generator</h1>
|
| 39 |
+
<form id="configForm">
|
| 40 |
+
<div class="form-group">
|
| 41 |
+
<label for="clientName">Client Name:</label>
|
| 42 |
+
<input type="text" id="clientName" name="clientName" value="client1" required>
|
| 43 |
+
</div>
|
| 44 |
+
<div class="form-group">
|
| 45 |
+
<label for="serverHost">Server Host:</label>
|
| 46 |
+
<input type="text" id="serverHost" name="serverHost" value="vpn.example.com" required>
|
| 47 |
+
</div>
|
| 48 |
+
<div class="form-group">
|
| 49 |
+
<label for="serverPort">Server Port:</label>
|
| 50 |
+
<input type="number" id="serverPort" name="serverPort" value="1194" required>
|
| 51 |
+
</div>
|
| 52 |
+
<div class="form-group">
|
| 53 |
+
<label for="protocol">Protocol:</label>
|
| 54 |
+
<select id="protocol" name="protocol">
|
| 55 |
+
<option value="udp">UDP</option>
|
| 56 |
+
<option value="tcp">TCP</option>
|
| 57 |
+
</select>
|
| 58 |
+
</div>
|
| 59 |
+
<button type="submit">Generate Configuration</button>
|
| 60 |
+
</form>
|
| 61 |
+
<div class="output">
|
| 62 |
+
<label for="configOutput">Generated Configuration:</label>
|
| 63 |
+
<textarea id="configOutput" readonly></textarea>
|
| 64 |
+
</div>
|
| 65 |
+
</div>
|
| 66 |
+
<script>
|
| 67 |
+
document.getElementById('configForm').addEventListener('submit', function(e) {
|
| 68 |
+
e.preventDefault();
|
| 69 |
+
const formData = new FormData(this);
|
| 70 |
+
const config = generateConfig(
|
| 71 |
+
formData.get('clientName'),
|
| 72 |
+
formData.get('serverHost'),
|
| 73 |
+
formData.get('serverPort'),
|
| 74 |
+
formData.get('protocol')
|
| 75 |
+
);
|
| 76 |
+
document.getElementById('configOutput').value = config;
|
| 77 |
+
});
|
| 78 |
+
|
| 79 |
+
function generateConfig(clientName, serverHost, serverPort, protocol) {
|
| 80 |
+
const now = new Date().toLocaleString();
|
| 81 |
+
return `# OpenVPN Client Configuration
|
| 82 |
+
# Generated: ${now}
|
| 83 |
+
# Client: ${clientName}
|
| 84 |
+
|
| 85 |
+
client
|
| 86 |
+
dev tun
|
| 87 |
+
proto ${protocol}
|
| 88 |
+
remote ${serverHost} ${serverPort}
|
| 89 |
+
resolv-retry infinite
|
| 90 |
+
nobind
|
| 91 |
+
persist-key
|
| 92 |
+
persist-tun
|
| 93 |
+
remote-cert-tls server
|
| 94 |
+
cipher AES-256-GCM
|
| 95 |
+
auth SHA256
|
| 96 |
+
verb 3
|
| 97 |
+
|
| 98 |
+
# Security Notes:
|
| 99 |
+
# - Use strong ciphers (AES-256-GCM)
|
| 100 |
+
# - Enable certificate verification
|
| 101 |
+
# - Keep certificates secure
|
| 102 |
+
# - Update regularly`;
|
| 103 |
+
}
|
| 104 |
+
</script>
|
| 105 |
+
</body>
|
| 106 |
+
</html>"""
|
| 107 |
+
self.wfile.write(html_content.encode())
|
| 108 |
+
else:
|
| 109 |
+
super().do_GET()
|
| 110 |
+
|
| 111 |
+
def log_message(self, format, *args):
|
| 112 |
+
# Suppress log messages to keep output clean
|
| 113 |
+
pass
|
| 114 |
+
|
| 115 |
+
if __name__ == "__main__":
|
| 116 |
+
PORT = 7860
|
| 117 |
+
with socketserver.TCPServer(("", PORT), OpenVPNConfigHandler) as httpd:
|
| 118 |
+
print(f"OpenVPN Configuration Manager running on port {PORT}")
|
| 119 |
+
print("Access at: http://localhost:7860")
|
| 120 |
+
httpd.serve_forever()
|
requirements.txt
CHANGED
|
@@ -1,2 +1 @@
|
|
| 1 |
-
|
| 2 |
-
huggingface_hub==0.16.0
|
|
|
|
| 1 |
+
# No external dependencies - using only built-in Python modules
|
|
|
requirements_static.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
# No external dependencies - using only built-in Python modules
|