|
|
|
|
|
""" |
|
|
Ultra-minimal OpenVPN Config Manager |
|
|
No external dependencies - Python built-in only |
|
|
""" |
|
|
|
|
|
from http.server import HTTPServer, BaseHTTPRequestHandler |
|
|
import json |
|
|
from urllib.parse import parse_qs, urlparse |
|
|
from datetime import datetime |
|
|
|
|
|
class OpenVPNHandler(BaseHTTPRequestHandler): |
|
|
def do_GET(self): |
|
|
if self.path == '/': |
|
|
self.send_response(200) |
|
|
self.send_header('Content-type', 'text/html') |
|
|
self.end_headers() |
|
|
|
|
|
html = '''<!DOCTYPE html> |
|
|
<html> |
|
|
<head> |
|
|
<title>OpenVPN Configuration Manager</title> |
|
|
<style> |
|
|
body { font-family: Arial, sans-serif; margin: 40px; background: #f5f5f5; } |
|
|
.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); } |
|
|
h1 { color: #2563eb; text-align: center; } |
|
|
.form-group { margin: 20px 0; } |
|
|
label { display: block; margin-bottom: 5px; font-weight: bold; } |
|
|
input, select { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 5px; } |
|
|
button { background: #2563eb; color: white; padding: 12px 24px; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; } |
|
|
button:hover { background: #1d4ed8; } |
|
|
.tabs { display: flex; margin-bottom: 20px; } |
|
|
.tab { padding: 10px 20px; background: #e5e7eb; border: none; cursor: pointer; } |
|
|
.tab.active { background: #2563eb; color: white; } |
|
|
.tab-content { display: none; } |
|
|
.tab-content.active { display: block; } |
|
|
.config-output { width: 100%; height: 200px; font-family: monospace; padding: 10px; border: 1px solid #ddd; border-radius: 5px; } |
|
|
</style> |
|
|
</head> |
|
|
<body> |
|
|
<div class="container"> |
|
|
<h1>🔒 OpenVPN Configuration Manager</h1> |
|
|
|
|
|
<div class="tabs"> |
|
|
<button class="tab active" onclick="showTab('client')">Client Config</button> |
|
|
<button class="tab" onclick="showTab('server')">Server Config</button> |
|
|
<button class="tab" onclick="showTab('guide')">Deployment Guide</button> |
|
|
</div> |
|
|
|
|
|
<div id="client" class="tab-content active"> |
|
|
<h3>Generate Client Configuration</h3> |
|
|
<div class="form-group"> |
|
|
<label>Client Name:</label> |
|
|
<input type="text" id="clientName" value="client1"> |
|
|
</div> |
|
|
<div class="form-group"> |
|
|
<label>Server Host:</label> |
|
|
<input type="text" id="serverHost" value="vpn.example.com"> |
|
|
</div> |
|
|
<div class="form-group"> |
|
|
<label>Port:</label> |
|
|
<input type="number" id="serverPort" value="1194"> |
|
|
</div> |
|
|
<div class="form-group"> |
|
|
<label>Protocol:</label> |
|
|
<select id="protocol"> |
|
|
<option value="udp">UDP</option> |
|
|
<option value="tcp">TCP</option> |
|
|
</select> |
|
|
</div> |
|
|
<button onclick="generateConfig()">Generate Configuration</button> |
|
|
<div class="form-group"> |
|
|
<label>Generated Configuration:</label> |
|
|
<textarea id="clientConfig" class="config-output" readonly></textarea> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<div id="server" class="tab-content"> |
|
|
<h3>Server Configuration</h3> |
|
|
<textarea class="config-output" readonly>server 10.8.0.0 255.255.255.0 |
|
|
port 1194 |
|
|
proto udp |
|
|
dev tun |
|
|
ca ca.crt |
|
|
cert server.crt |
|
|
key server.key |
|
|
dh dh.pem |
|
|
user nobody |
|
|
group nogroup |
|
|
persist-key |
|
|
persist-tun |
|
|
push "redirect-gateway def1 bypass-dhcp" |
|
|
push "dhcp-option DNS 8.8.8.8" |
|
|
keepalive 10 120 |
|
|
cipher AES-256-GCM |
|
|
auth SHA256 |
|
|
verb 3 |
|
|
mute 20</textarea> |
|
|
</div> |
|
|
|
|
|
<div id="guide" class="tab-content"> |
|
|
<h3>Deployment Guide</h3> |
|
|
<div style="padding: 10px; background: #f9f9f9; border-radius: 5px;"> |
|
|
<h4>Server Setup:</h4> |
|
|
<pre>1. Install OpenVPN: sudo apt install openvpn |
|
|
2. Copy server config to /etc/openvpn/server.conf |
|
|
3. Generate certificates using easy-rsa |
|
|
4. Start OpenVPN: sudo systemctl start openvpn@server</pre> |
|
|
|
|
|
<h4>Client Setup:</h4> |
|
|
<pre>1. Generate client config using this tool |
|
|
2. Save as .ovpn file |
|
|
3. Import to OpenVPN client |
|
|
4. Connect to server</pre> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<script> |
|
|
function showTab(tabName) { |
|
|
// Hide all tab contents |
|
|
document.querySelectorAll('.tab-content').forEach(content => { |
|
|
content.classList.remove('active'); |
|
|
}); |
|
|
// Remove active class from all tabs |
|
|
document.querySelectorAll('.tab').forEach(tab => { |
|
|
tab.classList.remove('active'); |
|
|
}); |
|
|
// Show selected tab |
|
|
document.getElementById(tabName).classList.add('active'); |
|
|
event.target.classList.add('active'); |
|
|
} |
|
|
|
|
|
function generateConfig() { |
|
|
const clientName = document.getElementById('clientName').value; |
|
|
const serverHost = document.getElementById('serverHost').value; |
|
|
const serverPort = document.getElementById('serverPort').value; |
|
|
const protocol = document.getElementById('protocol').value; |
|
|
const now = new Date().toLocaleString(); |
|
|
|
|
|
const config = `# OpenVPN Client Configuration |
|
|
# Generated: ${now} |
|
|
# Client: ${clientName} |
|
|
|
|
|
client |
|
|
dev tun |
|
|
proto ${protocol} |
|
|
remote ${serverHost} ${serverPort} |
|
|
resolv-retry infinite |
|
|
nobind |
|
|
persist-key |
|
|
persist-tun |
|
|
remote-cert-tls server |
|
|
cipher AES-256-GCM |
|
|
auth SHA256 |
|
|
verb 3 |
|
|
|
|
|
# Security notes: |
|
|
# - Use strong ciphers (AES-256-GCM) |
|
|
# - Enable certificate verification |
|
|
# - Keep certificates secure`; |
|
|
|
|
|
document.getElementById('clientConfig').value = config; |
|
|
} |
|
|
</script> |
|
|
</body> |
|
|
</html>''' |
|
|
|
|
|
self.wfile.write(html.encode()) |
|
|
|
|
|
def log_message(self, format, *args): |
|
|
pass |
|
|
|
|
|
def run_server(): |
|
|
port = 7860 |
|
|
server = HTTPServer(('0.0.0.0', port), OpenVPNHandler) |
|
|
print(f"Server running on port {port}") |
|
|
server.serve_forever() |
|
|
|
|
|
if __name__ == "__main__": |
|
|
run_server() |