Spaces:
Sleeping
Sleeping
File size: 6,316 Bytes
3041f43 7d5f6e8 3041f43 7d5f6e8 437b07f 0b60fb2 3041f43 7d5f6e8 437b07f 7d5f6e8 437b07f 7d5f6e8 437b07f 7d5f6e8 437b07f 7d5f6e8 437b07f 7d5f6e8 437b07f 7d5f6e8 437b07f 7d5f6e8 437b07f 7d5f6e8 437b07f 7d5f6e8 437b07f 7d5f6e8 437b07f 7d5f6e8 437b07f 7d5f6e8 437b07f 3041f43 437b07f 3041f43 6c089d5 0b60fb2 3041f43 7d5f6e8 dfd9494 7d5f6e8 437b07f 7d5f6e8 3041f43 437b07f 7d5f6e8 3041f43 7d5f6e8 |
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 |
#!/usr/bin/env python3
"""
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 # Suppress log messages
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() |