likhonsheikh commited on
Commit
0b60fb2
Β·
1 Parent(s): 6c089d5

Ultra-minimal version - single dependency to isolate issue

Browse files
Files changed (4) hide show
  1. app.py +27 -76
  2. app_minimal.py +54 -0
  3. requirements.txt +1 -2
  4. requirements_minimal.txt +1 -0
app.py CHANGED
@@ -1,103 +1,54 @@
1
  #!/usr/bin/env python3
2
  """
3
- Simple OpenVPN Configuration Manager for Hugging Face Spaces
4
- Minimal working version to test build
5
  """
6
 
7
  import gradio as gr
 
8
 
9
- def create_openvpn_config(client_name, server_host, server_port, protocol):
10
- """Generate a basic OpenVPN configuration file"""
11
-
12
- config_content = f"""# OpenVPN Client Configuration
13
- # Generated by OpenVPN Configuration Manager
14
- # Date: {__import__('datetime').datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
15
 
16
  client
17
  dev tun
18
  proto {protocol}
19
- remote {server_host} {server_port}
20
  resolv-retry infinite
21
  nobind
22
  persist-key
23
  persist-tun
24
  remote-cert-tls server
25
  cipher AES-256-GCM
 
26
  verb 3
27
  """
28
-
29
- return config_content
30
-
31
- def generate_ca_script():
32
- """Generate CA certificate script"""
33
- return """#!/bin/bash
34
- # Certificate Authority Setup Script
35
- # Run this script on your OpenVPN server
36
-
37
- # Generate CA private key
38
- openssl genrsa -out ca.key 4096
39
-
40
- # Generate CA certificate
41
- openssl req -new -x509 -days 3650 -key ca.key -out ca.crt -subj "/C=US/ST=State/L=City/O=Organization/CN=CA"
42
-
43
- echo "CA certificate and key generated successfully!"
44
- """
45
 
46
  def main():
47
- """Main Gradio interface"""
48
-
49
- with gr.Blocks(title="OpenVPN Configuration Manager") as demo:
50
- gr.Markdown("# πŸ”’ OpenVPN Configuration Manager")
51
- gr.Markdown("Generate OpenVPN configuration files and certificates")
52
-
53
- with gr.Tab("Generate Client Config"):
54
- with gr.Row():
55
- client_name = gr.Textbox(label="Client Name", value="client1")
56
- server_host = gr.Textbox(label="Server Host", value="your-server.com")
57
- server_port = gr.Textbox(label="Server Port", value="1194")
58
- protocol = gr.Dropdown(["udp", "tcp"], value="udp", label="Protocol")
59
-
60
- generate_btn = gr.Button("Generate Configuration")
61
- config_output = gr.Textbox(label="Configuration", lines=20, interactive=False)
62
-
63
- generate_btn.click(
64
- fn=create_openvpn_config,
65
- inputs=[client_name, server_host, server_port, protocol],
66
- outputs=[config_output]
67
- )
68
 
69
- with gr.Tab("Certificate Scripts"):
70
- ca_script_btn = gr.Button("Generate CA Script")
71
- ca_script_output = gr.Textbox(label="CA Setup Script", lines=15, interactive=False)
 
 
 
72
 
73
- ca_script_btn.click(
74
- fn=generate_ca_script,
75
- inputs=[],
76
- outputs=[ca_script_output]
77
- )
78
 
79
- with gr.Tab("Deployment Guide"):
80
- gr.Markdown("""
81
- ## Deployment Instructions
82
-
83
- 1. **Server Setup:**
84
- - Install OpenVPN on your server
85
- - Generate CA certificates using the script above
86
- - Configure firewall to allow VPN traffic
87
-
88
- 2. **Client Configuration:**
89
- - Download the generated .ovpn file
90
- - Import it into your OpenVPN client
91
- - Connect to your server
92
-
93
- 3. **Security Notes:**
94
- - Always use strong ciphers (AES-256-GCM)
95
- - Enable certificate verification
96
- - Keep your certificates secure
97
- """)
98
 
99
- return demo
100
 
101
  if __name__ == "__main__":
102
  demo = main()
103
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
1
  #!/usr/bin/env python3
2
  """
3
+ Minimal OpenVPN Configuration Manager
4
+ Single file application with minimal dependencies
5
  """
6
 
7
  import gradio as gr
8
+ from datetime import datetime
9
 
10
+ def create_config(client_name, server_host, port, protocol):
11
+ """Generate OpenVPN configuration"""
12
+ config = f"""# OpenVPN Client Configuration
13
+ # Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
14
+ # Client: {client_name}
 
15
 
16
  client
17
  dev tun
18
  proto {protocol}
19
+ remote {server_host} {port}
20
  resolv-retry infinite
21
  nobind
22
  persist-key
23
  persist-tun
24
  remote-cert-tls server
25
  cipher AES-256-GCM
26
+ auth SHA256
27
  verb 3
28
  """
29
+ return config
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  def main():
32
+ with gr.Blocks(title="OpenVPN Config Generator") as app:
33
+ gr.Markdown("# πŸ”’ OpenVPN Configuration Generator")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
+ with gr.Row():
36
+ with gr.Column():
37
+ client_name = gr.Textbox(value="client1", label="Client Name")
38
+ server_host = gr.Textbox(value="vpn.example.com", label="Server Host")
39
+ port = gr.Number(value=1194, label="Port")
40
+ protocol = gr.Radio(["udp", "tcp"], value="udp", label="Protocol")
41
 
42
+ config_output = gr.Textbox(label="Configuration File", lines=20)
 
 
 
 
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
+ return app
51
 
52
  if __name__ == "__main__":
53
  demo = main()
54
+ demo.launch(server_name="0.0.0.0", server_port=7860, show_error=True)
app_minimal.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Minimal OpenVPN Configuration Manager
4
+ Single file application with minimal dependencies
5
+ """
6
+
7
+ import gradio as gr
8
+ from datetime import datetime
9
+
10
+ def create_config(client_name, server_host, port, protocol):
11
+ """Generate OpenVPN configuration"""
12
+ config = f"""# OpenVPN Client Configuration
13
+ # Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
14
+ # Client: {client_name}
15
+
16
+ client
17
+ dev tun
18
+ proto {protocol}
19
+ remote {server_host} {port}
20
+ resolv-retry infinite
21
+ nobind
22
+ persist-key
23
+ persist-tun
24
+ remote-cert-tls server
25
+ cipher AES-256-GCM
26
+ auth SHA256
27
+ verb 3
28
+ """
29
+ return config
30
+
31
+ def main():
32
+ with gr.Blocks(title="OpenVPN Config Generator") as app:
33
+ gr.Markdown("# πŸ”’ OpenVPN Configuration Generator")
34
+
35
+ with gr.Row():
36
+ with gr.Column():
37
+ client_name = gr.Textbox(value="client1", label="Client Name")
38
+ server_host = gr.Textbox(value="vpn.example.com", label="Server Host")
39
+ port = gr.Number(value=1194, label="Port")
40
+ protocol = gr.Radio(["udp", "tcp"], value="udp", label="Protocol")
41
+
42
+ config_output = gr.Textbox(label="Configuration File", lines=20)
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
+ return app
51
+
52
+ if __name__ == "__main__":
53
+ demo = main()
54
+ demo.launch(server_name="0.0.0.0", server_port=7860, show_error=True)
requirements.txt CHANGED
@@ -1,2 +1 @@
1
- gradio==4.15.0
2
- huggingface_hub==0.16.0
 
1
+ gradio==4.15.0
 
requirements_minimal.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio==4.15.0