File size: 1,527 Bytes
0b60fb2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Minimal OpenVPN Configuration Manager
Single file application with minimal dependencies
"""

import gradio as gr
from datetime import datetime

def create_config(client_name, server_host, port, protocol):
    """Generate OpenVPN configuration"""
    config = f"""# OpenVPN Client Configuration
# Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
# Client: {client_name}

client
dev tun
proto {protocol}
remote {server_host} {port}
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
cipher AES-256-GCM
auth SHA256
verb 3
"""
    return config

def main():
    with gr.Blocks(title="OpenVPN Config Generator") as app:
        gr.Markdown("# πŸ”’ OpenVPN Configuration Generator")
        
        with gr.Row():
            with gr.Column():
                client_name = gr.Textbox(value="client1", label="Client Name")
                server_host = gr.Textbox(value="vpn.example.com", label="Server Host") 
                port = gr.Number(value=1194, label="Port")
                protocol = gr.Radio(["udp", "tcp"], value="udp", label="Protocol")
            
            config_output = gr.Textbox(label="Configuration File", lines=20)
        
        gr.Button("Generate Config").click(
            create_config,
            inputs=[client_name, server_host, port, protocol],
            outputs=[config_output]
        )
    
    return app

if __name__ == "__main__":
    demo = main()
    demo.launch(server_name="0.0.0.0", server_port=7860, show_error=True)