Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "manager"]
path = manager
url = https://github.com/wzdnzd/proxy-manager.git
1 change: 1 addition & 0 deletions manager
Submodule manager added at e3d93e
10 changes: 6 additions & 4 deletions subscribe/airport.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,14 +533,15 @@ def parse(
with open(self.sub, "r", encoding="UTF8") as f:
text = f.read()
else:
headers = {"User-Agent": "Clash.Meta; Mihomo"}
client = f"{utils.USER_AGENT}; Clash.Meta; Mihomo; Shadowrocket;"
headers = {"User-Agent": client}
trace = os.environ.get("TRACE_ENABLE", "false").lower() in ["true", "1"]

text = utils.http_get(
url=self.sub,
headers=headers,
retry=retry,
timeout=30,
timeout=120,
trace=trace,
interval=1,
max_size=15 * 1024 * 1024,
Expand Down Expand Up @@ -699,7 +700,7 @@ def parse(
@staticmethod
def check_protocol(link: str) -> bool:
return re.match(
r"^(vmess|trojan|ss|ssr|vless|hysteria|hysteria2|tuic|snell|anytls)://[a-zA-Z0-9:.?+=@%&#_\-/]{10,}",
r"^(vmess|trojan|ss|ssr|vless|hysteria|hysteria2|tuic|snell|anytls|socks5|https?)://[a-zA-Z0-9:.?+=@%&#_\-/]{10,}",
utils.trim(link).replace("\r", ""),
flags=re.I,
)
Expand Down Expand Up @@ -754,7 +755,7 @@ def clean_text(document: str) -> str:
not is_b64encode
and not is_json
and not is_yaml
and all(AirPort.check_protocol(x) for x in text.split("\n") if x)
and all(AirPort.check_protocol(x) for x in text.split("\n") if x and not x.startswith("#"))
):
text = base64.b64encode(text.encode(encoding="UTF8")).decode(encoding="UTF8")

Expand All @@ -777,6 +778,7 @@ def clean_text(document: str) -> str:
f"{artifact}.yaml",
"clash",
True,
True,
ignore,
)
if not success:
Expand Down
22 changes: 21 additions & 1 deletion subscribe/clash.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,20 @@ def verify(item: dict, mihomo: bool = True) -> bool:

elif item["type"] == "vless":
authentication = "uuid"

# see: https://github.com/MetaCubeX/mihomo/blob/Alpha/transport/vless/encryption/factory.go#L12
encryption = utils.trim(item.get("encryption", ""))
if encryption not in ["", "none"]:
parts = encryption.split(".")

# Must be: mlkem768x25519plus.<mode>.<...>.<...> (len >= 4)
if (
len(parts) < 4
or parts[0] != "mlkem768x25519plus"
or parts[1] not in ("native", "xorpub", "random")
):
return False

network = utils.trim(item.get("network", "tcp"))

# mihomo: https://wiki.metacubex.one/config/proxies/vless/#network
Expand Down Expand Up @@ -575,8 +589,14 @@ def verify(item: dict, mihomo: bool = True) -> bool:
short_id = str(short_id)
else:
return False
# if len(short_id) != 8 or not is_hex(short_id) or re.match(r"\d+e\d+", short_id, flags=re.I):
# return False

if len(short_id) != 8 or not is_hex(short_id) or re.match(r"\d+e\d+", short_id, flags=re.I):
try:
sib = bytes.fromhex(short_id)
if len(sib) > 8:
return False
except ValueError:
return False

reality_opts["short-id"] = QuotedStr(short_id)
Expand Down
2 changes: 1 addition & 1 deletion subscribe/crawl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ def check_status(
return False, connectable

try:
headers = {"User-Agent": "clash.meta"}
headers = {"User-Agent": f"{utils.USER_AGENT}; Clash.Meta; Mihomo; Shadowrocket;"}
request = urllib.request.Request(url=url, headers=headers)
response = urllib.request.urlopen(request, timeout=10, context=utils.CTX)
if response.getcode() != 200:
Expand Down
Loading