diff --git a/Decoder/VLESS.py b/Decoder/VLESS.py new file mode 100644 index 0000000..0e8ec56 --- /dev/null +++ b/Decoder/VLESS.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +from Utils.Logger import logger +from Decoder.V2ray import v2ray +from Utils.Common import checkScheme, splitTag + +def vless(url: str) -> dict: + """ + https://github.com/XTLS/Xray-core/discussions/716 + + FORMAT: aka Decoder.V2ray + """ + config = { + 'type': 'vless' + } + logger.debug('VLESS url decode -> %s' % url) + url, config['name'] = splitTag(checkScheme(url, 'vless', 'VLESS')) + config['info'] = v2ray(url, isXtls = True) + logger.debug('VLESS url release -> %s' % config) + return config diff --git a/Decoder/VMess.py b/Decoder/VMess.py index fdbaa4c..fbc45ea 100644 --- a/Decoder/VMess.py +++ b/Decoder/VMess.py @@ -3,11 +3,11 @@ import json from Utils.Logger import logger +from Decoder.V2ray import v2ray from Utils.Exception import decodeException from Utils.Common import b64Decode, checkScheme -from Utils.Common import hostFormat, splitTag, splitEdParam, splitParam +from Utils.Common import splitTag, splitEdParam -from Decoder.V2ray import v2ray def v2rayN(url: str) -> dict: """ @@ -26,7 +26,7 @@ def v2rayN(url: str) -> dict: 'type': 'vmess', 'name': url['ps'] if 'ps' in url else '', # ps -> remark 'info': { - 'server': hostFormat(url['add']), + 'server': url['add'], 'port': url['port'], 'id': url['id'], 'aid': url['aid'] if 'aid' in url else 0, # default alter id -> 0 diff --git a/Decoder/__init__.py b/Decoder/__init__.py index 8830c23..38d09aa 100644 --- a/Decoder/__init__.py +++ b/Decoder/__init__.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +from Decoder.VLESS import vless from Decoder.ShadowsocksR import ssr from Decoder.VMess import vmess, v2rayN from Decoder.Shadowsocks import ss, sip002 diff --git a/test.py b/test.py index e70ca0d..fa34af7 100755 --- a/test.py +++ b/test.py @@ -23,7 +23,10 @@ from Filter import Filter # ret = Decoder.v2rayN('vmess://ew0KICAidiI6ICIyIiwNCiAgInBzIjogIummmea4rzLnur8iLA0KICAiYWRkIjogIjExOS4yOC44OC4yMzAiLA0KICAicG9ydCI6ICI0NDMiLA0KICAiaWQiOiAiODRhOGU2ZDItMWFkMy00NjEyLTgzNjItYTdjMjNlOWU5MzEyIiwNCiAgImFpZCI6ICIwIiwNCiAgInNjeSI6ICJhdXRvIiwNCiAgIm5ldCI6ICJ3cyIsDQogICJ0eXBlIjogIm5vbmUiLA0KICAiaG9zdCI6ICJ0ZXN0LnNjdXRyb2JvdC5jb20iLA0KICAicGF0aCI6ICIvdm1lc3M/ZGVtbz10cnVlJmVkPTIwNDgmdGVzdD1vayIsDQogICJ0bHMiOiAidGxzIiwNCiAgInNuaSI6ICJoay5zY3V0cm9ib3QuY29tIiwNCiAgImFscG4iOiAiIg0KfQ==') # ret = Decoder.vmess('vmess://901ce214-9369-d1e2-9584-da5a7ff0547d@pqxsiziyovtsqljrhq.q7543.top:38337/?type=tcp&encryption=auto&headerType=http&host=xhf4xq7d5cb4gsyjpmmydwoi.sina.cn&path=%2F#v1%7C%E9%A6%99%E6%B8%AF01%7CMPTCP%7C%E2%98%85%E2%98%85%E2%98%85%20%282%29') -ret = Decoder.vmess('vmess://5f50d808-8281-45d9-a0c2-69e039099da7@119.28.88.230:443/?type=ws&encryption=auto&host=hk.scutrobot.com&path=%2Fvmess%3Fed%3D2048&security=tls&sni=hk.scutrobot.com#%E9%A6%99%E6%B8%AF2%E7%BA%BF') +# ret = Decoder.vmess('vmess://5f50d808-8281-45d9-a0c2-69e039099da7@119.28.88.230:443/?type=ws&encryption=auto&host=hk.scutrobot.com&path=%2Fvmess%3Fed%3D2048&security=tls&sni=hk.scutrobot.com#%E9%A6%99%E6%B8%AF2%E7%BA%BF') + +ret = Decoder.vless('vless://f7a6a4c7-63a5-479e-818a-0555431e0219@119.28.88.230:443?encryption=none&flow=xtls-rprx-direct&security=xtls&sni=hk.scutrobot.com&type=tcp&headerType=none&host=hk.scutrobot.com#XTLS-%E9%A6%99%E6%B8%AFB') + # ret['info']['server'] = '[%s]' % ret['info']['server'] ret['info'] = Filter(ret['type'], ret['info'])