#!/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']['type'] stremType = streamInfo['type'] flow = streamInfo.get('flow', None) headerType = streamInfo.get('obfs', 'none') host = streamInfo.get('host', None) path = streamInfo.get('path', None) security = streamInfo.get('secure', None) alpn = streamInfo.get('alpn', None) sni = streamInfo.get('sni', None) link += 'type=' + stremType + '&' # add link += 'flow=' + flow + '&' if flow else '' # add link += 'headerType=' + headerType + '&' # 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 print(link) return link