mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-11-27 06:43:08 +00:00
Bug fixes
1. 当 VMess 的 alterId 为 0 时,AEAD 会自动开启。 2. 更新了 Clash 的 VMess Websocket 参数写法,旧版本的写法(如 ws-path, ws-headers 等)已不被支持。
This commit is contained in:
1 parent
2e75f172e4
commit
dd0a9ff0c2
2 files changed
+39
-29
No files matched your search
+37
-27
@@ -873,8 +873,7 @@ function service() {
|
||||
return "Loon";
|
||||
} else if (UA.indexOf("Stash") !== -1) {
|
||||
return "Clash";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1305,14 +1304,14 @@ var ProxyUtils = (function () {
|
||||
// handle ws headers
|
||||
if (params.obfs === "ws" || params.obfs === "wss") {
|
||||
proxy.network = "ws";
|
||||
proxy["ws-path"] = (params["obfs-path"] || '"/"').match(
|
||||
proxy["ws-opts"].path = (params["obfs-path"] || '"/"').match(
|
||||
/^"(.*)"$/
|
||||
)[1];
|
||||
let obfs_host = params["obfs-header"];
|
||||
if (obfs_host && obfs_host.indexOf("Host") !== -1) {
|
||||
obfs_host = obfs_host.match(/Host:\s*([a-zA-Z0-9-.]*)/)[1];
|
||||
}
|
||||
proxy["ws-headers"] = {
|
||||
proxy["ws-opts"].headers = {
|
||||
Host: obfs_host || proxy.server, // if no host provided, use the same as server
|
||||
};
|
||||
}
|
||||
@@ -1345,10 +1344,10 @@ var ProxyUtils = (function () {
|
||||
// handle obfs
|
||||
if (params.net === "ws") {
|
||||
proxy.network = "ws";
|
||||
proxy["ws-path"] = params.path;
|
||||
proxy["ws-headers"] = {
|
||||
Host: params.host || params.add,
|
||||
};
|
||||
proxy["ws-opts"] = {
|
||||
path: params.path,
|
||||
headers: {Host: params.host || params.add}
|
||||
}
|
||||
if (proxy.tls && params.host) {
|
||||
proxy.sni = params.host;
|
||||
}
|
||||
@@ -1538,9 +1537,11 @@ var ProxyUtils = (function () {
|
||||
// handle ws headers
|
||||
if (params.obfs === "ws" || params.obfs === "wss") {
|
||||
proxy.network = "ws";
|
||||
proxy["ws-path"] = params["obfs-uri"];
|
||||
proxy["ws-headers"] = {
|
||||
Host: params["obfs-host"] || params.server, // if no host provided, use the same as server
|
||||
proxy["ws-opts"] = {
|
||||
path: params["obfs-uri"],
|
||||
headers: {
|
||||
Host: params["obfs-host"] || params.server, // if no host provided, use the same as server
|
||||
}
|
||||
};
|
||||
}
|
||||
return proxy;
|
||||
@@ -1725,9 +1726,11 @@ var ProxyUtils = (function () {
|
||||
break;
|
||||
case "ws":
|
||||
proxy.network = params.transport;
|
||||
proxy["ws-path"] = params.path;
|
||||
proxy["ws-headers"] = {
|
||||
Host: params.host,
|
||||
proxy["ws-opts"] = {
|
||||
path: params.path,
|
||||
headers: {
|
||||
Host: params.host,
|
||||
}
|
||||
};
|
||||
}
|
||||
if (proxy.tls) {
|
||||
@@ -1869,10 +1872,13 @@ var ProxyUtils = (function () {
|
||||
// use websocket
|
||||
if (JSON.parse(params.ws || "false")) {
|
||||
proxy.network = "ws";
|
||||
proxy["ws-path"] = params["ws-path"];
|
||||
proxy["ws-opts"] = {
|
||||
path: params["ws-path"]
|
||||
};
|
||||
|
||||
const res = params["ws-headers"].match(/(,|^|\s)*HOST:\s*(.*?)(,|$)/);
|
||||
const host = res ? res[2] : proxy.server;
|
||||
proxy["ws-headers"] = {
|
||||
proxy["ws-opts"].headers = {
|
||||
Host: host || params.server,
|
||||
};
|
||||
}
|
||||
@@ -2477,15 +2483,15 @@ var ProxyUtils = (function () {
|
||||
if (proxy.tls) {
|
||||
// ws-tls
|
||||
obfs_opts = `,obfs=wss${proxy.sni ? ",obfs-host=" + proxy.sni : ""
|
||||
}${proxy["ws-path"] ? ",obfs-uri=" + proxy["ws-path"] : ""
|
||||
}${proxy["ws-opts"].path ? ",obfs-uri=" + proxy["ws-opts"].path : ""
|
||||
},tls-verification=${proxy["skip-cert-verify"] ? "false" : "true"
|
||||
}`;
|
||||
} else {
|
||||
// ws
|
||||
obfs_opts = `,obfs=ws${proxy["ws-headers"].Host
|
||||
? ",obfs-host=" + proxy["ws-headers"].Host
|
||||
obfs_opts = `,obfs=ws${proxy["ws-opts"].headers.Host
|
||||
? ",obfs-host=" + proxy["ws-opts"].headers.Host
|
||||
: ""
|
||||
}${proxy["ws-path"] ? ",obfs-uri=" + proxy["ws-path"] : ""}`;
|
||||
}${proxy["ws-opts"].path ? ",obfs-uri=" + proxy["ws-opts"].path : ""}`;
|
||||
}
|
||||
} else {
|
||||
// tcp
|
||||
@@ -2498,6 +2504,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"}`;
|
||||
if (proxy.alterId === 0) proxy['vmess-aead'] = true;
|
||||
if (typeof proxy['vmess-aead'] !== "undefined") {
|
||||
result += `,aead=${proxy['vmess-aead']}`;
|
||||
}
|
||||
@@ -2529,7 +2536,7 @@ var ProxyUtils = (function () {
|
||||
function Loon_Producer() {
|
||||
const targetPlatform = "Loon";
|
||||
const produce = (proxy) => {
|
||||
let obfs_opts, tls_opts, udp_opts, tfo_opts;
|
||||
let obfs_opts = "", tls_opts = "", udp_opts = "", tfo_opts = "";
|
||||
if (typeof proxy.udp !== "undefined") {
|
||||
udp_opts = proxy.udp ? ",udp=true" : ",udp=false";
|
||||
}
|
||||
@@ -2559,8 +2566,8 @@ var ProxyUtils = (function () {
|
||||
case "vmess":
|
||||
obfs_opts = "";
|
||||
if (proxy.network === "ws") {
|
||||
const host = proxy["ws-headers"].Host || proxy.server;
|
||||
obfs_opts = `,transport:ws,host:${host},path:${proxy["ws-path"] || "/"
|
||||
const host = proxy["ws-opts"].headers.Host || proxy.server;
|
||||
obfs_opts = `,transport:ws,host:${host},path:${proxy["ws-opts"].path || "/"
|
||||
}`;
|
||||
} else {
|
||||
obfs_opts = `,transport:tcp`;
|
||||
@@ -2571,6 +2578,7 @@ var ProxyUtils = (function () {
|
||||
}
|
||||
let result = `${proxy.name}=vmess,${proxy.server},${proxy.port},${proxy.cipher === "auto" ? "none" : proxy.cipher
|
||||
},"${proxy.uuid}",over-tls:${proxy.tls || "false"}${obfs_opts}`;
|
||||
if (proxy.alterId === 0) proxy['vmess-aead'] = true;
|
||||
if (typeof proxy['vmess-aead'] !== "undefined") {
|
||||
result += `,vmess-aead=${proxy['vmess-aead']}`;
|
||||
}
|
||||
@@ -2625,12 +2633,14 @@ var ProxyUtils = (function () {
|
||||
result = `${proxy.name}=vmess,${proxy.server},${proxy.port
|
||||
},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") {
|
||||
result += `,vmess-aead=${proxy['vmess-aead']}`;
|
||||
}
|
||||
if (proxy.network === "ws") {
|
||||
const path = proxy["ws-path"] || "/";
|
||||
const wsHeaders = Object.entries(proxy["ws-headers"]).map(
|
||||
const path = proxy["ws-opts"].path || "/";
|
||||
const wsHeaders = Object.entries(proxy["ws-opts"].headers).map(
|
||||
([key, value]) => (`${key}:"${value}"`))
|
||||
.join('|');
|
||||
result += `,ws=true${path ? ",ws-path=" + path : ""}${wsHeaders ? ",ws-headers=" + wsHeaders : ""}`;
|
||||
@@ -2746,8 +2756,8 @@ var ProxyUtils = (function () {
|
||||
};
|
||||
// obfs
|
||||
if (proxy.network === "ws") {
|
||||
result.path = proxy["ws-path"] || "/";
|
||||
result.host = proxy["ws-headers"].Host || proxy.server;
|
||||
result.path = proxy["ws-opts"].path || "/";
|
||||
result.host = proxy["ws-opts"].headers.Host || proxy.server;
|
||||
}
|
||||
result = "vmess://" + Base64.safeEncode(JSON.stringify(result));
|
||||
break;
|
||||
|
||||
Vendored
+2
-2
@@ -1,2 +1,2 @@
|
||||
// UPDATED AT: 2022年 3月23日 星期三 17时36分40秒 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月25日 星期五 22时52分36秒 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
|
||||
Reference in new issue
Block a user