sfun commited on
Commit
9dacd3a
1 Parent(s): 463028b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -24,12 +24,7 @@ async def extract_and_transform_proxies(input_text):
24
  elif isinstance(data, list):
25
  proxies_list = data
26
  else:
27
- proxies_match = re.search(r'proxies:\s*\n((?:[-\s]*{.*\n?)*)', input_text, re.MULTILINE)
28
- if proxies_match:
29
- proxies_text = proxies_match.group(1)
30
- proxies_list = yaml.safe_load(proxies_text)
31
- else:
32
- return "未找到有效的代理配置"
33
  except yaml.YAMLError:
34
  return "YAML解析错误"
35
 
@@ -51,7 +46,7 @@ async def extract_and_transform_proxies(input_text):
51
  if 'password' in proxy:
52
  ss_parts.append(f"password={proxy['password'].strip()}")
53
  if 'udp' in proxy:
54
- ss_parts.append(f"udp-relay={'true' if proxy['udp'] in [True, 'true', 'True'] else 'false'}")
55
 
56
  transformed = ", ".join(ss_parts)
57
  transformed_proxies.append(transformed)
@@ -70,13 +65,14 @@ async def extract_and_transform_proxies(input_text):
70
  if 'skip-cert-verify' in proxy:
71
  trojan_parts.append(f"skip-cert-verify={str(proxy['skip-cert-verify']).lower()}")
72
  if 'udp' in proxy:
73
- trojan_parts.append(f"udp={'true' if proxy['udp'] in [True, 'true', 'True'] else 'false'}")
74
 
75
  transformed = ", ".join(trojan_parts)
76
  transformed_proxies.append(transformed)
77
 
78
  return "\n".join(transformed_proxies) if transformed_proxies else "未找到有效的SS或Trojan代理配置"
79
 
 
80
  async def log_request(request, response, cache_status):
81
  timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
82
  client_ip = request.remote
 
24
  elif isinstance(data, list):
25
  proxies_list = data
26
  else:
27
+ return "未找到有效的代理配置"
 
 
 
 
 
28
  except yaml.YAMLError:
29
  return "YAML解析错误"
30
 
 
46
  if 'password' in proxy:
47
  ss_parts.append(f"password={proxy['password'].strip()}")
48
  if 'udp' in proxy:
49
+ ss_parts.append(f"udp-relay={'true' if proxy['udp'] else 'false'}")
50
 
51
  transformed = ", ".join(ss_parts)
52
  transformed_proxies.append(transformed)
 
65
  if 'skip-cert-verify' in proxy:
66
  trojan_parts.append(f"skip-cert-verify={str(proxy['skip-cert-verify']).lower()}")
67
  if 'udp' in proxy:
68
+ trojan_parts.append(f"udp={'true' if proxy['udp'] else 'false'}")
69
 
70
  transformed = ", ".join(trojan_parts)
71
  transformed_proxies.append(transformed)
72
 
73
  return "\n".join(transformed_proxies) if transformed_proxies else "未找到有效的SS或Trojan代理配置"
74
 
75
+
76
  async def log_request(request, response, cache_status):
77
  timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
78
  client_ip = request.remote