Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,6 @@ import re
|
|
7 |
app = Flask(__name__)
|
8 |
|
9 |
def parse_node_input(node_input):
|
10 |
-
# 使用正则表达式提取 proxies 部分
|
11 |
proxies_match = re.search(r'proxies:\s*\n([\s\S]*?)(?:\n\w+:|$)', node_input)
|
12 |
if not proxies_match:
|
13 |
return []
|
@@ -27,7 +26,6 @@ def parse_node_input(node_input):
|
|
27 |
else:
|
28 |
node_dict[key] = value.strip("'\"")
|
29 |
|
30 |
-
# 处理 ws-opts
|
31 |
ws_opts_match = re.search(r'ws-opts:\s*({[^}]+})', node)
|
32 |
if ws_opts_match:
|
33 |
ws_opts = ws_opts_match.group(1)
|
@@ -99,7 +97,9 @@ def convert_to_trojan(node):
|
|
99 |
|
100 |
def convert_to_ss(node):
|
101 |
try:
|
102 |
-
|
|
|
|
|
103 |
return ss_link
|
104 |
except KeyError as e:
|
105 |
return f"Error in Shadowsocks conversion: Missing {e} key"
|
|
|
7 |
app = Flask(__name__)
|
8 |
|
9 |
def parse_node_input(node_input):
|
|
|
10 |
proxies_match = re.search(r'proxies:\s*\n([\s\S]*?)(?:\n\w+:|$)', node_input)
|
11 |
if not proxies_match:
|
12 |
return []
|
|
|
26 |
else:
|
27 |
node_dict[key] = value.strip("'\"")
|
28 |
|
|
|
29 |
ws_opts_match = re.search(r'ws-opts:\s*({[^}]+})', node)
|
30 |
if ws_opts_match:
|
31 |
ws_opts = ws_opts_match.group(1)
|
|
|
97 |
|
98 |
def convert_to_ss(node):
|
99 |
try:
|
100 |
+
ss_config = f"{node['cipher']}:{node['password']}"
|
101 |
+
encoded_config = base64.b64encode(ss_config.encode()).decode()
|
102 |
+
ss_link = f"ss://{encoded_config}@{node['server']}:{node['port']}#{node['name']}"
|
103 |
return ss_link
|
104 |
except KeyError as e:
|
105 |
return f"Error in Shadowsocks conversion: Missing {e} key"
|