Update app.py
Browse files
app.py
CHANGED
@@ -34,21 +34,34 @@ def extract_and_transform_proxies(input_text):
|
|
34 |
name = proxy.get('name', '').strip()
|
35 |
server = proxy.get('server', '').strip()
|
36 |
port = str(proxy.get('port', '')).strip()
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
-
transformed =
|
42 |
transformed_proxies.append(transformed)
|
|
|
43 |
elif proxy.get('type') == 'trojan':
|
44 |
name = proxy.get('name', '').strip()
|
45 |
server = proxy.get('server', '').strip()
|
46 |
port = str(proxy.get('port', '')).strip()
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
-
transformed =
|
52 |
transformed_proxies.append(transformed)
|
53 |
|
54 |
return "\n".join(transformed_proxies) if transformed_proxies else "未找到有效的SS或Trojan代理配置"
|
|
|
34 |
name = proxy.get('name', '').strip()
|
35 |
server = proxy.get('server', '').strip()
|
36 |
port = str(proxy.get('port', '')).strip()
|
37 |
+
|
38 |
+
ss_parts = [f"{name} = ss, {server}, {port}"]
|
39 |
+
|
40 |
+
if 'cipher' in proxy:
|
41 |
+
ss_parts.append(f"encrypt-method={proxy['cipher'].strip()}")
|
42 |
+
if 'password' in proxy:
|
43 |
+
ss_parts.append(f"password={proxy['password'].strip()}")
|
44 |
+
if 'udp' in proxy:
|
45 |
+
ss_parts.append(f"udp-relay={'true' if proxy['udp'] in [True, 'true', 'True'] else 'false'}")
|
46 |
|
47 |
+
transformed = ", ".join(ss_parts)
|
48 |
transformed_proxies.append(transformed)
|
49 |
+
|
50 |
elif proxy.get('type') == 'trojan':
|
51 |
name = proxy.get('name', '').strip()
|
52 |
server = proxy.get('server', '').strip()
|
53 |
port = str(proxy.get('port', '')).strip()
|
54 |
+
|
55 |
+
trojan_parts = [f"{name} = trojan, {server}, {port}"]
|
56 |
+
|
57 |
+
if 'password' in proxy:
|
58 |
+
trojan_parts.append(f"password={proxy['password'].strip()}")
|
59 |
+
if 'sni' in proxy:
|
60 |
+
trojan_parts.append(f"sni={proxy['sni'].strip()}")
|
61 |
+
if 'skip-cert-verify' in proxy:
|
62 |
+
trojan_parts.append(f"skip-cert-verify={str(proxy['skip-cert-verify']).lower()}")
|
63 |
|
64 |
+
transformed = ", ".join(trojan_parts)
|
65 |
transformed_proxies.append(transformed)
|
66 |
|
67 |
return "\n".join(transformed_proxies) if transformed_proxies else "未找到有效的SS或Trojan代理配置"
|