#!/usr/bin/env python3 # -*- coding: utf-8 -*- from Utils.Common import urlEncode def vless(info: dict, name: str) -> str: """ https://github.com/XTLS/Xray-core/discussions/716 FORMAT: protocol://$(uuid)@remote-host:remote-port?#$(descriptive-text) """ link = 'vless://' link += info['id'] + '@' # add link += info['server'] + ':' # add link += str(info['port']) + '?' # add # stream settings streamInfo = info['stream'] stremType = streamInfo['type'] flow = streamInfo.get('flow', None) headerType = streamInfo.get('obfs', 'none') host = streamInfo['secure'].get('host', None) path = streamInfo['secure'].get('path', None) alpn = streamInfo['secure'].get('alpn', None) sni = streamInfo['secure'].get('sni', None) security = streamInfo['secure'].get('type', None) link += 'type=' + stremType + '&' # add link += 'flow=' + flow + '&' if flow else '' # add link += 'headerType=' + headerType + '&' if headerType != None else 'none' # add link += 'security=' + security + '&' if security else '' # add link += 'alpn=' + alpn + '&' if alpn else '' # add link += 'sni=' + sni + '&' if sni else '' # add link += 'host=' + host + '&' if host else '' # add link += 'path=' + path + '&' if path else '' # add link += '#' + urlEncode(name) # add return link