diff --git a/main.py b/main.py index a7ad29682..ea282ffc4 100644 --- a/main.py +++ b/main.py @@ -221,7 +221,7 @@ def get_content_from_url(url, n=6): print('处理: \033[31m' + url + '\033[0m') # print('Đang tải link đăng ký: \033[31m' + url + '\033[0m') prefixes = ["vmess://", "vless://", "ss://", "ssr://", "trojan://", "tuic://", "hysteria://", "hysteria2://", - "hy2://", "wg://", "http2://", "socks://", "socks5://"] + "hy2://", "wg://", "wireguard://", "http2://", "socks://", "socks5://"] if any(url.startswith(prefix) for prefix in prefixes): response_text = tool.noblankLine(url) return response_text diff --git a/parsers/wg.py b/parsers/wg.py index bbf1b7b50..18bf61344 100644 --- a/parsers/wg.py +++ b/parsers/wg.py @@ -10,15 +10,15 @@ def parse(data): node = { 'tag': unquote(server_info.fragment) or tool.genName()+'_wireguard', 'type': 'wireguard', - 'server': re.sub(r"\[|\]", "", server_info.netloc.rsplit(":", 1)[0]), - 'server_port': int(server_info.netloc.rsplit(":", 1)[1]), - 'private_key': netquery.get('privateKey'), - 'peer_public_key': netquery.get('publicKey') + 'server': re.sub(r"\[|\]", "", server_info.netloc.rsplit("@", 1)[-1].rsplit(":", 1)[0]), + 'server_port': int(server_info.netloc.rsplit("@", 1)[-1].rsplit(":", 1)[1]), + 'private_key': netquery.get('privateKey') or unquote(server_info.netloc.rsplit("@", 1)[0]), + 'peer_public_key': netquery.get('publicKey') or netquery.get('publickey') } if netquery.get('reserved'): reserved_value = netquery.get('reserved') node['reserved'] = [int(val) for val in reserved_value.split(",")] if ',' in reserved_value else reserved_value - ip_value = netquery.get('ip') + ip_value = netquery.get('ip') or netquery.get('address') if ',' in ip_value: ipv4_value, ipv6_value = ip_value.split(",", 1) ipv4_value = ipv4_value + "/32" if '/' not in ipv4_value else ipv4_value diff --git a/tool.py b/tool.py index b968b24d8..506a263c1 100644 --- a/tool.py +++ b/tool.py @@ -211,6 +211,9 @@ def get_protocol(s): if m.group(1) == 'hy2': s = re.sub(r'^(.+?)://', 'hysteria2://', s) m = re.search(r'^(.+?)://', s) + if m.group(1) == 'wireguard': + s = re.sub(r'^(.+?)://', 'wg://', s) + m = re.search(r'^(.+?)://', s) if m.group(1) == 'http2': s = re.sub(r'^(.+?)://', 'http://', s) m = re.search(r'^(.+?)://', s)