Fixes tfo issues

This commit is contained in:
Peng-YM committed 2022-03-29 15:30:18 +08:00
1 parent 0443a947d4
commit 16a1ec5641
2 files changed
+8 -13

No files matched your search

+6 -11
View File
@@ -2475,7 +2475,7 @@ var ProxyUtils = (function () {
? ",ssr-protocol-param=" + proxy["protocol-param"]
: ""
}${proxy.obfs ? ",obfs=" + proxy.obfs : ""}${proxy["obfs-param"] ? ",obfs-host=" + proxy["obfs-param"] : ""
}${proxy.tfo ? ",fast-open=true" : ",fast-open=false"}${proxy.udp ? ",udp-relay=true" : ",udp-relay=false"
},fast-open=${proxy.tfo || false}${proxy.udp ? ",udp-relay=true" : ",udp-relay=false"
},tag=${proxy.name}`;
case "vmess":
obfs_opts = "";
@@ -2503,8 +2503,7 @@ var ProxyUtils = (function () {
}
}
let result = `vmess=${proxy.server}:${proxy.port},method=${proxy.cipher === "auto" ? "none" : proxy.cipher
},password=${proxy.uuid}${obfs_opts}${proxy.tfo ? ",fast-open=true" : ",fast-open=false"
}${proxy.udp ? ",udp-relay=true" : ",udp-relay=false"}`;
},password=${proxy.uuid}${obfs_opts},fast-open=${proxy.tfo || false}${proxy.udp ? ",udp-relay=true" : ",udp-relay=false"}`;
if (proxy.alterId === 0) proxy['vmess-aead'] = true;
if (typeof proxy['vmess-aead'] !== "undefined") {
result += `,aead=${proxy['vmess-aead']}`;
@@ -2515,7 +2514,7 @@ var ProxyUtils = (function () {
return `trojan=${proxy.server}:${proxy.port},password=${proxy.password
}${proxy.sni ? ",tls-host=" + proxy.sni : ""
},over-tls=true,tls-verification=${proxy["skip-cert-verify"] ? "false" : "true"
}${proxy.tfo ? ",fast-open=true" : ",fast-open=false"}${proxy.udp ? ",udp-relay=true" : ",udp-relay=false"
},fast-open=${proxy.tfo||false}${proxy.udp ? ",udp-relay=true" : ",udp-relay=false"
},tag=${proxy.name}`;
case "http":
tls_opts = "";
@@ -2524,8 +2523,7 @@ var ProxyUtils = (function () {
}${proxy.sni ? ",tls-host=" + proxy.sni : ""}`;
}
return `http=${proxy.server}:${proxy.port},username=${proxy.username
},password=${proxy.password}${tls_opts}${proxy.tfo ? ",fast-open=true" : ",fast-open=false"
},tag=${proxy.name}`;
},password=${proxy.password}${tls_opts},fast-open=${proxy.tfo||false},tag=${proxy.name}`;
}
throw new Error(
`Platform ${targetPlatform} does not support proxy type: ${proxy.type}`
@@ -2541,9 +2539,7 @@ var ProxyUtils = (function () {
if (typeof proxy.udp !== "undefined") {
udp_opts = proxy.udp ? ",udp=true" : ",udp=false";
}
if (typeof proxy.tfo !== "undefined") {
tfo_opts = proxy.tfo ? ",fast-open=true" : ",fast-open=false";
}
tfo_opts = `,fast-open=${proxy.tfo||false}`;
switch (proxy.type) {
case "ss":
@@ -2632,8 +2628,7 @@ var ProxyUtils = (function () {
case "vmess":
tls_opts = "";
result = `${proxy.name}=vmess,${proxy.server},${proxy.port
},username=${proxy.uuid},tls=${proxy.tls || "false"},tfo=${proxy.tfo || "false"
}`;
},username=${proxy.uuid},tls=${proxy.tls || "false"},tfo=${proxy.tfo || "false"}`;
if (proxy.alterId === 0) proxy['vmess-aead'] = true;
if (typeof proxy['vmess-aead'] !== "undefined") {
+2 -2
View File
@@ -1,2 +1,2 @@
// UPDATED AT: 2022年 3月26日 星期六 21时47分53秒 CST
const $=API("sub-store"),Base64=new Base64Code;function service(){console.log("\n┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅\n 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 © 𝑷𝒆𝒏𝒈-𝒀𝑴\n┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅\n");const e=express(),t="settings",n="subs",r="collections",s="rules",o="builtin",i="artifacts",a="Auto Generated Sub-Store Backup",c="Sub-Store",l="Sub-Store Artifacts Repository";async function p({filename:e,content:n}){const{gistToken:r}=$.read(t);return r?new Gist({token:r,key:l}).upload({filename:e,content:n}):Promise.reject("未设置Gist Token!")}function u(e){const t=Object.keys(e);let n="";for(let r of t)if(/USER-AGENT/i.test(r)){n=e[r];break}return-1!==n.indexOf("Quantumult%20X")?"QX":-1!==n.indexOf("Surge")?"Surge":-1!==n.indexOf("Decar")||-1!==n.indexOf("Loon")?"Loon":-1!==n.indexOf("Stash")?"Clash":null}async function f(e,t=!0,n){let r=n;void 0!==n&&null!=n&&0!=n.trim().length||(r="Quantumult%20X");const s=HTTP({headers:{"User-Agent":r}}),o="#"+Base64.safeEncode(e),i=$.read(o),a=`#TIME-${Base64.safeEncode(e)}`,c=(new Date).getTime()-$.read(a)>36e5;if(t&&i&&!c)return $.log(`Use cached for resource: ${e}`),i;let l="";try{l=(await s.get(e)).body}catch(e){throw new Error(e)}finally{$.write(l,o),$.write((new Date).getTime(),a)}if(0===l.replace(/\s/g,"").length)throw new Error("订阅内容为空!");return l}async function d({type:e,item:t,platform:r,useCache:s,noProcessor:o}={platform:"JSON",useCache:!1,noProcessor:!1}){if("subscription"===e){const e=t,n=await f(e.url,s,e.ua);let i=ProxyUtils.parse(n);o||(i=await ProxyUtils.process(i,e.process||[]));const a={};return i.forEach(e=>{a[e.name]&&$.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』","⚠️ 订阅包含重复节点!","请仔细检测配置!",{"media-url":"https://cdn3.iconfinder.com/data/icons/seo-outline-1/512/25_code_program_programming_develop_bug_search_developer-512.png"})}),ProxyUtils.produce(i,r)}if("collection"===e){const e=$.read(n),i=t,a=i.subscriptions;let c=[];for(let t=0;t<a.length;t++){const n=e[a[t]];$.info(`正在处理子订阅:${n.name},进度--${100*((t+1)/a.length).toFixed(1)}% `);try{const e=await f(n.url,s,n.ua);let t=ProxyUtils.parse(e);o||(t=await ProxyUtils.process(t,n.process||[])),c=c.concat(t)}catch(e){$.error(`处理组合订阅中的子订阅: ${n.name}时出现错误:${e}! 该订阅已被跳过。`)}}if(o||(c=await ProxyUtils.process(c,i.process||[])),0===c.length)throw new Error("组合订阅中不含有效节点!");const l={};return c.forEach(e=>{l[e.name]&&$.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』","⚠️ 订阅包含重复节点!","请仔细检测配置!",{"media-url":"https://cdn3.iconfinder.com/data/icons/seo-outline-1/512/25_code_program_programming_develop_bug_search_developer-512.png"})}),ProxyUtils.produce(c,r)}if("rule"===e){const e=t;let n=[];for(let t=0;t<e.urls.length;t++){const r=e.urls[t];$.info(`正在处理URL:${r},进度--${100*((t+1)/e.urls.length).toFixed(1)}% `);try{const{body:e}=await $.http.get(r),t=RuleUtils.parse(e);n=n.concat(t)}catch(e){$.error(`处理分流订阅中的URL: ${r}时出现错误:${e}! 该订阅已被跳过。`)}}return n=await RuleUtils.process(n,[{type:"Remove Duplicate Filter"}]),RuleUtils.produce(n,r)}}$.read(n)||$.write({},n),$.read(r)||$.write({},r),$.read(t)||$.write({},t),$.read(s)||$.write({},s),$.read(i)||$.write({},i),$.write({rules:getBuiltInRules()},o),e.get("/download/collection/:name",async function(e,t){const{name:n}=e.params,{cache:s}=e.query||"false",{raw:o}=e.query||"false",i=e.query.target||u(e.headers)||"JSON",a=void 0===s?"JSON"===i||"URI"===i:s,c=$.read(r)[n];if($.info(`正在下载组合订阅:${n}`),c)try{const e=await d({type:"collection",item:c,platform:i,useCache:a,noProcessor:o});"JSON"===i?t.set("Content-Type","application/json;charset=utf-8").send(e):t.send(e)}catch(e){$.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』 下载组合订阅失败",`❌ 下载组合订阅错误:${n}!`,`🤔 原因:${e}`),t.status(500).json({status:"failed",message:e})}else $.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』 下载组合订阅失败",`❌ 未找到组合订阅:${n}!`),t.status(404).json({status:"failed"})}),e.get("/download/:name",async function(e,t){const{name:r}=e.params,{cache:s}=e.query,{raw:o}=e.query||"false",i=e.query.target||u(e.headers)||"JSON",a=void 0===s?"JSON"===i||"URI"===i:s;$.info(`正在下载订阅:${r}`);const c=$.read(n)[r];if(c)try{const n=await d({type:"subscription",item:c,platform:i,useCache:a,noProcessor:o});if(-1!==["QX","Surge","Loon"].indexOf(u(e.headers))){const{headers:e}=await $.http.get({url:c.url,headers:{"User-Agent":"Quantumult/1.0.13 (iPhone10,3; iOS 14.0)"}}),n=Object.keys(e).filter(e=>/SUBSCRIPTION-USERINFO/i.test(e)Line truncated
// UPDATED AT: 2022年 3月29日 星期二 15时28分48秒 CST
const $=API("sub-store"),Base64=new Base64Code;function service(){console.log("\n┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅\n 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 © 𝑷𝒆𝒏𝒈-𝒀𝑴\n┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅\n");const e=express(),t="settings",n="subs",r="collections",s="rules",o="builtin",i="artifacts",a="Auto Generated Sub-Store Backup",c="Sub-Store",l="Sub-Store Artifacts Repository";async function p({filename:e,content:n}){const{gistToken:r}=$.read(t);return r?new Gist({token:r,key:l}).upload({filename:e,content:n}):Promise.reject("未设置Gist Token!")}function u(e){const t=Object.keys(e);let n="";for(let r of t)if(/USER-AGENT/i.test(r)){n=e[r];break}return-1!==n.indexOf("Quantumult%20X")?"QX":-1!==n.indexOf("Surge")?"Surge":-1!==n.indexOf("Decar")||-1!==n.indexOf("Loon")?"Loon":-1!==n.indexOf("Stash")?"Clash":null}async function f(e,t=!0,n){let r=n;void 0!==n&&null!=n&&0!=n.trim().length||(r="Quantumult%20X");const s=HTTP({headers:{"User-Agent":r}}),o="#"+Base64.safeEncode(e),i=$.read(o),a=`#TIME-${Base64.safeEncode(e)}`,c=(new Date).getTime()-$.read(a)>36e5;if(t&&i&&!c)return $.log(`Use cached for resource: ${e}`),i;let l="";try{l=(await s.get(e)).body}catch(e){throw new Error(e)}finally{$.write(l,o),$.write((new Date).getTime(),a)}if(0===l.replace(/\s/g,"").length)throw new Error("订阅内容为空!");return l}async function d({type:e,item:t,platform:r,useCache:s,noProcessor:o}={platform:"JSON",useCache:!1,noProcessor:!1}){if("subscription"===e){const e=t,n=await f(e.url,s,e.ua);let i=ProxyUtils.parse(n);o||(i=await ProxyUtils.process(i,e.process||[]));const a={};return i.forEach(e=>{a[e.name]&&$.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』","⚠️ 订阅包含重复节点!","请仔细检测配置!",{"media-url":"https://cdn3.iconfinder.com/data/icons/seo-outline-1/512/25_code_program_programming_develop_bug_search_developer-512.png"})}),ProxyUtils.produce(i,r)}if("collection"===e){const e=$.read(n),i=t,a=i.subscriptions;let c=[];for(let t=0;t<a.length;t++){const n=e[a[t]];$.info(`正在处理子订阅:${n.name},进度--${100*((t+1)/a.length).toFixed(1)}% `);try{const e=await f(n.url,s,n.ua);let t=ProxyUtils.parse(e);o||(t=await ProxyUtils.process(t,n.process||[])),c=c.concat(t)}catch(e){$.error(`处理组合订阅中的子订阅: ${n.name}时出现错误:${e}! 该订阅已被跳过。`)}}if(o||(c=await ProxyUtils.process(c,i.process||[])),0===c.length)throw new Error("组合订阅中不含有效节点!");const l={};return c.forEach(e=>{l[e.name]&&$.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』","⚠️ 订阅包含重复节点!","请仔细检测配置!",{"media-url":"https://cdn3.iconfinder.com/data/icons/seo-outline-1/512/25_code_program_programming_develop_bug_search_developer-512.png"})}),ProxyUtils.produce(c,r)}if("rule"===e){const e=t;let n=[];for(let t=0;t<e.urls.length;t++){const r=e.urls[t];$.info(`正在处理URL:${r},进度--${100*((t+1)/e.urls.length).toFixed(1)}% `);try{const{body:e}=await $.http.get(r),t=RuleUtils.parse(e);n=n.concat(t)}catch(e){$.error(`处理分流订阅中的URL: ${r}时出现错误:${e}! 该订阅已被跳过。`)}}return n=await RuleUtils.process(n,[{type:"Remove Duplicate Filter"}]),RuleUtils.produce(n,r)}}$.read(n)||$.write({},n),$.read(r)||$.write({},r),$.read(t)||$.write({},t),$.read(s)||$.write({},s),$.read(i)||$.write({},i),$.write({rules:getBuiltInRules()},o),e.get("/download/collection/:name",async function(e,t){const{name:n}=e.params,{cache:s}=e.query||"false",{raw:o}=e.query||"false",i=e.query.target||u(e.headers)||"JSON",a=void 0===s?"JSON"===i||"URI"===i:s,c=$.read(r)[n];if($.info(`正在下载组合订阅:${n}`),c)try{const e=await d({type:"collection",item:c,platform:i,useCache:a,noProcessor:o});"JSON"===i?t.set("Content-Type","application/json;charset=utf-8").send(e):t.send(e)}catch(e){$.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』 下载组合订阅失败",`❌ 下载组合订阅错误:${n}!`,`🤔 原因:${e}`),t.status(500).json({status:"failed",message:e})}else $.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』 下载组合订阅失败",`❌ 未找到组合订阅:${n}!`),t.status(404).json({status:"failed"})}),e.get("/download/:name",async function(e,t){const{name:r}=e.params,{cache:s}=e.query,{raw:o}=e.query||"false",i=e.query.target||u(e.headers)||"JSON",a=void 0===s?"JSON"===i||"URI"===i:s;$.info(`正在下载订阅:${r}`);const c=$.read(n)[r];if(c)try{const n=await d({type:"subscription",item:c,platform:i,useCache:a,noProcessor:o});if(-1!==["QX","Surge","Loon"].indexOf(u(e.headers))){const{headers:e}=await $.http.get({url:c.url,headers:{"User-Agent":"Quantumult/1.0.13 (iPhone10,3; iOS 14.0)"}}),n=Object.keys(e).filter(e=>/SUBSCRIPTION-USERINFO/i.test(e)Line truncated