Spaces:
Running
Running
rogerxavier
commited on
Update server/decoder.py
Browse files- server/decoder.py +5 -4
server/decoder.py
CHANGED
@@ -45,12 +45,13 @@ class ListDecoder(BaseDecoder):
|
|
45 |
)
|
46 |
|
47 |
if "trojan" in config_str and "0.0.0.0" not in config_str and '美国' not in nameinfo and '443' not in config_str:
|
|
|
|
|
|
|
48 |
if "allowInsecure" in config_str:
|
49 |
-
|
50 |
-
yield _encoded_config_str.replace('allowInsecure=0', 'allowInsecure=1').replace('type=tcp==', '')+"#"+nameinfo
|
51 |
else:
|
52 |
-
|
53 |
-
yield _encoded_config_str.replace('type=tcp==', '')+"&allowInsecure=1"+"#"+nameinfo
|
54 |
|
55 |
if ("vmess" in config_str):
|
56 |
vmess_decoded_data = b64decode(_config_str).decode('utf-8')
|
|
|
45 |
)
|
46 |
|
47 |
if "trojan" in config_str and "0.0.0.0" not in config_str and '美国' not in nameinfo and '443' not in config_str:
|
48 |
+
# 使用正则表达式去除 type=... 参数,包括#前的部分
|
49 |
+
# 这里我们匹配 &type= 后面跟着任意字符直到下一个 & 或 # 或字符串结束 ,去除type=tcp== 或者type=tcp= 这类影响链接的多余部分
|
50 |
+
_encoded_config_str_without_type = re.sub(r'([&?]type=[^&#]*)', '',_encoded_config_str)
|
51 |
if "allowInsecure" in config_str:
|
52 |
+
yield _encoded_config_str_without_type.replace('allowInsecure=0', 'allowInsecure=1')+"#"+nameinfo
|
|
|
53 |
else:
|
54 |
+
yield _encoded_config_str_without_type+"&allowInsecure=1"+"#"+nameinfo
|
|
|
55 |
|
56 |
if ("vmess" in config_str):
|
57 |
vmess_decoded_data = b64decode(_config_str).decode('utf-8')
|