def Surge3(request): """ Args: request (flask.Request): HTTP request object. Return: A Surge3Pro-support configuration Do: Get 2 parameters: url & filename url: the url of the remote file filename: the file name of the configuration will be returned, default(no filename parameter in request) to Config.conf Function ExpandPolicyPath will be excuted only when 'Proxy Group' illegal format be exist Illegal format: a 'Proxy Group' only allow one policy when there is a policy-path """ url = request.args.get('url') filename = request.args.get("filename", "Config.conf") interval = request.args.get("interval", "86400") strict = request.args.get("strict", "false") content = requests.get(url).text result = "#!MANAGED-CONFIG https://api.OKAB3.com/surge3?url=" + url + \ "&filename="+filename+"&interval="+interval+"&strict=" + \ strict + " interval="+interval+" strict="+strict+"\n" x = Content2XML(content) x = ExpandPolicyPath(x) x = GetProxyGroupType(x) result += ToSurge3(x) response = make_response(result) response.headers["Content-Disposition"] = "attachment; filename="+filename return response
def Clash(request): url = request.args.get('url') filename = request.args.get("filename", "Config.yml") snippet = request.args.get("snippet") url_text = requests.get(url).content.decode() x = Content2XML(url_text) x = ExpandPolicyPath(x) x = ExpandRuleSet(x) x = TopologicalSort(x) result = ToClash(x, snippet) response = make_response(result) response.headers["Content-Disposition"] = "attachment; filename="+filename return response