Taf2023 commited on
Commit
c77de17
·
verified ·
1 Parent(s): 3a75610

Update Gradio app with multiple files

Browse files
Files changed (2) hide show
  1. app.py +40 -50
  2. utils.py +3 -9
app.py CHANGED
@@ -20,9 +20,7 @@ def start_proxy_server():
20
  status_html = f"""
21
  <div class="status-indicator status-running">
22
  <h4>🟢 สถานะ: ทำงานอยู่</h4>
23
- <p>Proxy Server กำลังทำงานที่ {proxy_manager.proxy_server.host}:{
24
- client_port
25
- }</p>
26
  </div>
27
  """
28
  return status_html, "✅ เริ่มต้น Proxy Server สำเร็จ"
@@ -55,9 +53,7 @@ def restart_proxy_server():
55
  status_html = f"""
56
  <div class="status-indicator status-running">
57
  <h4>🟢 สถานะ: ทำงานอยู่</h4>
58
- <p>Proxy Server รีสตาร์ทสำเร็จ ทำงานที่ {
59
- proxy_manager.proxy_server.host
60
- }:{proxy_manager.proxy_server.port}</p>
61
  </div>
62
  """
63
  return status_html, "🔄 รีสตาร์ท Proxy Server สำเร็จ"
@@ -76,9 +72,7 @@ def get_server_status():
76
  status_html = f"""
77
  <div class="status-indicator status-running">
78
  <h4>🟢 สถานะ: ทำงานอยู่</h4>
79
- <p>Proxy Server กำลังทำงานที่ {
80
- proxy_manager.proxy_server.host
81
- }:{proxy_manager.proxy_server.port}</p>
82
  </div>
83
  """
84
  else:
@@ -93,9 +87,7 @@ proxy_manager.proxy_server.host
93
  def get_current_proxy_url():
94
  """ดึง URL proxy ปัจจุบัน"""
95
  if proxy_manager.is_running():
96
- return f"socks5://localhost:{
97
- PROXY_PORT
98
- }"
99
  return "ไม่ได้เชื่อมต่อ"
100
 
101
  def get_server_info():
@@ -132,53 +124,53 @@ def setup_interface():
132
  css = """
133
  .main-container {
134
  max-width: 1200px;
135
- margin: auto;
136
- padding: 20px;
137
- }
138
  .status-indicator {
139
  padding: 10px;
140
- border-radius: 5px;
141
- margin: 5px 0;
142
- }
143
  .status-running {
144
  background-color: #d4edda;
145
- color: #155724;
146
- border: 1px solid #c3e6cb;
147
- }
148
  .status-stopped {
149
  background-color: #f8d7da;
150
- color: #721c24;
151
- border: 1px solid #f5c6cb;
152
- }
153
  .info-box {
154
  background-color: #e9ecef;
155
- padding: 15px;
156
- border-radius: 5px;
157
- margin: 10px 0;
158
- border-left: 4px solid #007bff;
159
- }
160
  .stats-grid {
161
  display: grid;
162
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
163
- gap: 15px;
164
- margin: 20px 0;
165
- }
166
  .stat-card {
167
  background: white;
168
- padding: 15px;
169
- border-radius: 8px;
170
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
171
- border: 1px solid #dee2e6;
172
- }
173
  .stat-number {
174
  font-size: 24px;
175
- font-weight: bold;
176
- color: #007bff;
177
- }
178
  .stat-label {
179
  color: #6c757d;
180
- font-size: 14px;
181
- }
182
  """
183
 
184
  with gr.Blocks(css=css, title="SOCKS5 Proxy Dashboard", theme=gr.themes.Soft()) as demo:
@@ -292,9 +284,7 @@ if __name__ == "__main__":
292
  print("กำลังเริ่มต้น SOCKS5 Proxy Server...")
293
  success = proxy_manager.start_server()
294
  if success:
295
- print(f"✅ SOCKS5 Proxy Server เริ่มต้นสำเร็จที่ {
296
- proxy_manager.proxy_server.host
297
- }:{proxy_manager.proxy_server.port}")
298
  else:
299
  print("❌ ไม่สามารถเริ่มต้น SOCKS5 Proxy Server ได้ - กรุณาตรวจสอบ log")
300
 
@@ -303,8 +293,8 @@ proxy_manager.proxy_server.host
303
  server_name="0.0.0.0",
304
  server_port=8080,
305
  show_api=False,
306
- share=True, # สร้าง public link
307
- ssr_mode=False, # ปิด SSR mode
308
- inbrowser=False, # ไม่เปิด browser อัตโนมัติ
309
- debug=False # ปิด debug mode
310
  )
 
20
  status_html = f"""
21
  <div class="status-indicator status-running">
22
  <h4>🟢 สถานะ: ทำงานอยู่</h4>
23
+ <p>Proxy Server กำลังทำงานที่ {proxy_manager.proxy_server.host}:{proxy_manager.proxy_server.port}</p>
 
 
24
  </div>
25
  """
26
  return status_html, "✅ เริ่มต้น Proxy Server สำเร็จ"
 
53
  status_html = f"""
54
  <div class="status-indicator status-running">
55
  <h4>🟢 สถานะ: ทำงานอยู่</h4>
56
+ <p>Proxy Server รีสตาร์ทสำเร็จ ทำงานที่ {proxy_manager.proxy_server.host}:{proxy_manager.proxy_server.port}</p>
 
 
57
  </div>
58
  """
59
  return status_html, "🔄 รีสตาร์ท Proxy Server สำเร็จ"
 
72
  status_html = f"""
73
  <div class="status-indicator status-running">
74
  <h4>🟢 สถานะ: ทำงานอยู่</h4>
75
+ <p>Proxy Server กำลังทำงานที่ {proxy_manager.proxy_server.host}:{proxy_manager.proxy_server.port}</p>
 
 
76
  </div>
77
  """
78
  else:
 
87
  def get_current_proxy_url():
88
  """ดึง URL proxy ปัจจุบัน"""
89
  if proxy_manager.is_running():
90
+ return f"socks5://localhost:{PROXY_PORT}"
 
 
91
  return "ไม่ได้เชื่อมต่อ"
92
 
93
  def get_server_info():
 
124
  css = """
125
  .main-container {
126
  max-width: 1200px;
127
+ margin: auto;
128
+ padding: 20px;
129
+ }
130
  .status-indicator {
131
  padding: 10px;
132
+ border-radius: 5px;
133
+ margin: 5px 0;
134
+ }
135
  .status-running {
136
  background-color: #d4edda;
137
+ color: #155724;
138
+ border: 1px solid #c3e6cb;
139
+ }
140
  .status-stopped {
141
  background-color: #f8d7da;
142
+ color: #721c24;
143
+ border: 1px solid #f5c6cb;
144
+ }
145
  .info-box {
146
  background-color: #e9ecef;
147
+ padding: 15px;
148
+ border-radius: 5px;
149
+ margin: 10px 0;
150
+ border-left: 4px solid #007bff;
151
+ }
152
  .stats-grid {
153
  display: grid;
154
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
155
+ gap: 15px;
156
+ margin: 20px 0;
157
+ }
158
  .stat-card {
159
  background: white;
160
+ padding: 15px;
161
+ border-radius: 8px;
162
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
163
+ border: 1px solid #dee2e6;
164
+ }
165
  .stat-number {
166
  font-size: 24px;
167
+ font-weight: bold;
168
+ color: #007bff;
169
+ }
170
  .stat-label {
171
  color: #6c757d;
172
+ font-size: 14px;
173
+ }
174
  """
175
 
176
  with gr.Blocks(css=css, title="SOCKS5 Proxy Dashboard", theme=gr.themes.Soft()) as demo:
 
284
  print("กำลังเริ่มต้น SOCKS5 Proxy Server...")
285
  success = proxy_manager.start_server()
286
  if success:
287
+ print(f"✅ SOCKS5 Proxy Server เริ่มต้นสำเร็จที่ {proxy_manager.proxy_server.host}:{proxy_manager.proxy_server.port}")
 
 
288
  else:
289
  print("❌ ไม่สามารถเริ่มต้น SOCKS5 Proxy Server ได้ - กรุณาตรวจสอบ log")
290
 
 
293
  server_name="0.0.0.0",
294
  server_port=8080,
295
  show_api=False,
296
+ share=True,
297
+ ssr_mode=False,
298
+ inbrowser=False,
299
+ debug=False
300
  )
utils.py CHANGED
@@ -38,18 +38,14 @@ class SOCKS5ProxyServer:
38
  self.running = True
39
  self.start_time = datetime.now()
40
 
41
- logging.info(f"SOCKS5 Proxy Server เริ่มต้นที่ {
42
- self.host
43
- }:{self.port}")
44
 
45
  # เริ่ม thread สำหรับ accept connections
46
  threading.Thread(target=self._accept_connections, daemon=True).start()
47
 
48
  return True
49
  except Exception as e:
50
- logging.error(f"เริ่มต้น proxy server ผิดพลาด: {
51
- e
52
- }")
53
  return False
54
 
55
  def stop(self):
@@ -71,9 +67,7 @@ e
71
 
72
  # บันทึกการเชื่อมต่อ
73
  with self._lock:
74
- self.connections[f"{
75
- client_ip
76
- }:{client_port}"] = ConnectionInfo(
77
  ip=client_ip,
78
  port=client_port,
79
  start_time=datetime.now()
 
38
  self.running = True
39
  self.start_time = datetime.now()
40
 
41
+ logging.info(f"SOCKS5 Proxy Server เริ่มต้นที่ {self.host}:{self.port}")
 
 
42
 
43
  # เริ่ม thread สำหรับ accept connections
44
  threading.Thread(target=self._accept_connections, daemon=True).start()
45
 
46
  return True
47
  except Exception as e:
48
+ logging.error(f"เริ่มต้น proxy server ผิดพลาด: {e}")
 
 
49
  return False
50
 
51
  def stop(self):
 
67
 
68
  # บันทึกการเชื่อมต่อ
69
  with self._lock:
70
+ self.connections[f"{client_ip}:{client_port}"] = ConnectionInfo(
 
 
71
  ip=client_ip,
72
  port=client_port,
73
  start_time=datetime.now()