Update app.py
Browse files
app.py
CHANGED
@@ -68,7 +68,7 @@ async def extract_and_transform_proxies(input_text):
|
|
68 |
transformed_proxies = []
|
69 |
|
70 |
for proxy in proxies_list:
|
71 |
-
if proxy.get('type') in ['ss', 'trojan']:
|
72 |
name = proxy.get('name', '').strip()
|
73 |
server = proxy.get('server', '').strip()
|
74 |
port = str(proxy.get('port', '')).strip()
|
@@ -80,7 +80,7 @@ async def extract_and_transform_proxies(input_text):
|
|
80 |
parts.append(f"encrypt-method={proxy['cipher'].strip()}")
|
81 |
if 'password' in proxy:
|
82 |
parts.append(f"password={proxy['password'].strip()}")
|
83 |
-
elif proxy['type']
|
84 |
if 'password' in proxy:
|
85 |
parts.append(f"password={proxy['password'].strip()}")
|
86 |
if 'sni' in proxy:
|
@@ -175,19 +175,17 @@ async def logging_middleware(request, handler):
|
|
175 |
response = await handler(request)
|
176 |
end_time = datetime.datetime.now()
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
log_message = f"{timestamp} - {client_ip} - \"GET /?url={target_url}{'&nocache' if no_cache else ''}\" - Status: {status_code} - Proxies: {proxy_count} - Cache: {cache_hit} - CacheTime: {cache_time} - NoCache: {'Yes' if no_cache else 'No'}"
|
190 |
-
print(log_message, flush=True)
|
191 |
|
192 |
return response
|
193 |
except Exception as e:
|
|
|
68 |
transformed_proxies = []
|
69 |
|
70 |
for proxy in proxies_list:
|
71 |
+
if proxy.get('type') in ['ss', 'trojan', 'hysteria2']:
|
72 |
name = proxy.get('name', '').strip()
|
73 |
server = proxy.get('server', '').strip()
|
74 |
port = str(proxy.get('port', '')).strip()
|
|
|
80 |
parts.append(f"encrypt-method={proxy['cipher'].strip()}")
|
81 |
if 'password' in proxy:
|
82 |
parts.append(f"password={proxy['password'].strip()}")
|
83 |
+
elif proxy['type'] in ['trojan', 'hysteria2']:
|
84 |
if 'password' in proxy:
|
85 |
parts.append(f"password={proxy['password'].strip()}")
|
86 |
if 'sni' in proxy:
|
|
|
175 |
response = await handler(request)
|
176 |
end_time = datetime.datetime.now()
|
177 |
|
178 |
+
timestamp = end_time.strftime('%Y-%m-%d %H:%M:%S')
|
179 |
+
client_ip = get_client_ip(request)
|
180 |
+
target_url = request.query.get('url', '-')
|
181 |
+
no_cache = 'nocache' in request.query
|
182 |
+
status_code = response.status
|
183 |
+
proxy_count = response.headers.get('X-Proxy-Count', '0')
|
184 |
+
cache_hit = "Hit" if response.headers.get('X-Cache-Hit') == 'True' else "Miss"
|
185 |
+
cache_time = response.headers.get('X-Cache-Time', '-')
|
186 |
+
|
187 |
+
log_message = f"{timestamp} - {client_ip} - \"GET /?url={target_url}{'&nocache' if no_cache else ''}\" - Status: {status_code} - Proxies: {proxy_count} - Cache: {cache_hit} - CacheTime: {cache_time} - NoCache: {'Yes' if no_cache else 'No'}"
|
188 |
+
print(log_message, flush=True)
|
|
|
|
|
189 |
|
190 |
return response
|
191 |
except Exception as e:
|