mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-11-27 23:13:43 +00:00
Fixed V2RayN SNI issue
This commit is contained in:
1 parent
17d514c6da
commit
32595ee27e
11 files changed
+42
-6
No files matched your search
+19
-5
@@ -930,10 +930,6 @@ function URI_VMess() {
|
||||
tfo: JSON.parse(params["fast-open"] || "false"),
|
||||
};
|
||||
|
||||
if (proxy.tls) {
|
||||
proxy.sni = params["obfs-host"] || proxy.server;
|
||||
proxy.scert = !JSON.parse(params["tls-verification"] || "true");
|
||||
}
|
||||
// handle ws headers
|
||||
if (params.obfs === "ws" || params.obfs === "wss") {
|
||||
proxy.network = "ws";
|
||||
@@ -943,6 +939,16 @@ function URI_VMess() {
|
||||
};
|
||||
}
|
||||
|
||||
// handle scert
|
||||
if (proxy.tls && params['"tls-verification"'] === 'false') {
|
||||
proxy.scert = true;
|
||||
}
|
||||
|
||||
// handle sni
|
||||
if (proxy.tls && params["obfs-host"]) {
|
||||
proxy.sni = params["obfs-host"];
|
||||
}
|
||||
|
||||
return proxy;
|
||||
} else {
|
||||
// V2rayN URI format
|
||||
@@ -965,6 +971,13 @@ function URI_VMess() {
|
||||
proxy["ws-headers"] = {
|
||||
Host: params.host || params.add,
|
||||
};
|
||||
if (proxy.tls && params.host) {
|
||||
proxy.sni = params.host;
|
||||
}
|
||||
}
|
||||
// handle scert
|
||||
if (params.verify_cert === false) {
|
||||
proxy.scert = true;
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
@@ -1706,7 +1719,8 @@ function Surge_Producer() {
|
||||
}`;
|
||||
}
|
||||
if (proxy.tls) {
|
||||
config += `,skip-cert-verify=${proxy.scert},sni=${proxy.sni}`;
|
||||
config += `${typeof proxy.scert !== 'undefined' ? ",skip-cert-verify=" + proxy.scert : ""}`
|
||||
config += proxy.sni ? `,sni=${proxy.sni}` : "";
|
||||
}
|
||||
return config;
|
||||
case "trojan":
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
const $=API("sub-store"),$app=express();$.http=HTTP({headers:{"User-Agent":"Quantumult%20X"}});const SUBS_KEY="subs",COLLECTIONS_KEY="collections",AVAILABLE_FILTERS={"Keyword Filter":KeywordFilter,"Useless Filter":UselessFilter,"Region Filter":RegionFilter,"Regex Filter":RegexFilter,"Type Filter":TypeFilter,"Script Filter":ScriptFilter},AVAILABLE_OPERATORS={"Set Property Operator":SetPropertyOperator,"Flag Operator":FlagOperator,"Sort Operator":SortOperator,"Keyword Sort Operator":KeywordSortOperator,"Keyword Rename Operator":KeywordRenameOperator,"Keyword Delete Operator":KeywordDeleteOperator,"Regex Rename Operator":RegexRenameOperator,"Regex Delete Operator":RegexDeleteOperator,"Script Operator":ScriptOperator};async function IP_API(e,t){const s=decodeURIComponent(e.params.server),r=await $.http.get(`http://ip-api.com/json/${s}?lang=zh-CN`).then(e=>JSON.parse(e.body));t.json(r)}async function downloadResource(e){let t=await $.http.get(e).then(e=>e.body).catch(t=>{res.status(500).json({status:"failed",message:`Cannot refresh remote resource: ${e}\n Reason: ${t}`})});const s=t.indexOf("proxies:");if(-1!==s){const e=t.lastIndexOf("}")+1;t=t.substring(s,e)}return t}async function refreshResource(e,t){const s=new Base64Code,{url:r}=e.body,n=await downloadResource(r);$.write(n,`#${s.safeEncode(r)}`),t.json({status:"success"})}async function downloadSub(e,t){const{name:s}=e.params,r=e.query.target||getPlatformFromHeaders(e.headers),n=$.read(SUBS_KEY);if(n[s]){const e=n[s];try{const s=await parseSub(e,r);t.send(s)}catch(e){t.status(500).json({status:"failed",message:e})}}else t.status(404).json({status:"failed",message:`订阅${s}不存在!`})}async function parseSub(e,t){let s;const r=(new Base64Code).safeEncode(e.url);if("Raw"===t||"URI"===t){const t=$.read(`#${r}`);t?(await $.wait(10),s=t):(s=await downloadResource(e.url),$.write(s,`#${r}`))}else s=await downloadResource(e.url),$.write(s,`#${e.url}`);$.info("======================================================================="),$.info(`Processing subscription: ${e.name}, target platform ==> ${t}.`),$.info("Initializing parsers...");const n=ProxyParser(t);n.addParsers([Clash_All,URI_SS,URI_SSR,URI_VMess,URI_Trojan,QX_SS,QX_SSR,QX_VMess,QX_Trojan,QX_Http,Loon_SS,Loon_SSR,Loon_VMess,Loon_Trojan,Loon_Http,Surge_SS,Surge_VMess,Surge_Trojan,Surge_Http]),$.info("Parsers initialized.");let o=n.parse(s);for(const t of e.process||[]){let e;if(-1!==t.type.indexOf("Script")){const{mode:s,content:r}=t.args;e="link"===s?await $.http.get(r).then(e=>e.body).catch(e=>{throw new Error(`Error when downloading remote script: ${t.args.content}.\n Reason: ${e}`)}):r}if(-1!==t.type.indexOf("Filter")){const s=AVAILABLE_FILTERS[t.type];if(s){$.info(`Applying filter "${t.type}" with arguments:\n >>> ${JSON.stringify(t.args)||"None"}`);try{o=-1!==t.type.indexOf("Script")?processFilter(s(e),o):processFilter(s(t.args),o)}catch(e){$.error(`Failed to apply filter "${t.type}"!\n REASON: ${e}`)}}}else if(-1!==t.type.indexOf("Operator")){const s=AVAILABLE_OPERATORS[t.type];if(s){$.info(`Applying operator "${t.type}" with arguments: \n >>> ${JSON.stringify(t.args)||"None"}`);try{o=-1!==t.type.indexOf("Script")?processOperator(s(e),o):processOperator(s(t.args),o)}catch(e){t.type}}}}return n.addProducers([QX_Producer,Loon_Producer,Surge_Producer,Raw_Producer,URI_Producer]),n.produce(o)}function getFlowHeaders(e,t){const s=Object.keys(e).filter(e=>/SUBSCRIPTION-USERINFO/i.test(e))[0];if(s){const t=e[s],r=Number(t.match(/upload=(\d+)/)[1]),n=Number(t.match(/download=(\d+)/)[1]),o=Number(t.match(/total=(\d+)/)[1]),a=(t.match(/expire=(\d+)/)||[])[1];return{key:"Subscription-Userinfo",value:`${r?"upload="+r+";":""}${n?"download="+n+";":""}${o?"total="+o+";":""}${a?"expire="+a+";":""}`}}{let e,s;for(const r of t)-1!==r.name.indexOf("剩余流量")&&(e=r.name),-1!==r.name.indexOf("过期时间")&&(s=r.name);return{key:"Raw-Subscription-Userinfo",value:`${e?"remains="+e+";":""}${s?"expire="+s+";":""}`}}}async function getSub(e,t){const{name:s}=e.params,r=$.read(SUBS_KEY)[s];r?t.json({status:"success",data:r}):t.status(404).json({status:"failed",message:`未找到订阅:${s}!`})}async function newSub(e,t){const s=e.body,r=$.read(SUBS_KEY);r[s.name]&&t.status(500).json({status:"failed",message:`订阅${s.name}已存在!`}),/^[\w-_]*$/.test(s.name)?(r[s.name]=s,$.write(r,SUBS_KEY),t.status(201).json({status:"success",data:s})):t.status(500).json({status:"failed",message:`订阅名称 ${s.name} 中含有非法字符!名称中只能包含英文字母、数字、下划线、横杠。`})}async function updateSub(e,t){const{name:s}=e.params;$.info(`Updating subscription: ${s}`);let r=e.body;const n=$.read(SUBS_KEY);if(n[s]){const e={...n[s],...r};if(s!==r.name){const t=$.read(COLLECTIONS_KEY);for(const e of Object.keys(t)){const n=t[e].subscriptions.indexOf(s);-1!==n&&(t[e].subscriptions[n]=r.name)}delete n[s],n[r.name]=e}else n[s]=e;$.write(n,SUBS_KEY),t.json({status:"success",data:e})}else t.statuLine truncated
|
||||
const $=API("sub-store"),$app=express();$.http=HTTP({headers:{"User-Agent":"Quantumult%20X"}});const SUBS_KEY="subs",COLLECTIONS_KEY="collections",AVAILABLE_FILTERS={"Keyword Filter":KeywordFilter,"Useless Filter":UselessFilter,"Region Filter":RegionFilter,"Regex Filter":RegexFilter,"Type Filter":TypeFilter,"Script Filter":ScriptFilter},AVAILABLE_OPERATORS={"Set Property Operator":SetPropertyOperator,"Flag Operator":FlagOperator,"Sort Operator":SortOperator,"Keyword Sort Operator":KeywordSortOperator,"Keyword Rename Operator":KeywordRenameOperator,"Keyword Delete Operator":KeywordDeleteOperator,"Regex Rename Operator":RegexRenameOperator,"Regex Delete Operator":RegexDeleteOperator,"Script Operator":ScriptOperator};async function IP_API(e,t){const s=decodeURIComponent(e.params.server),r=await $.http.get(`http://ip-api.com/json/${s}?lang=zh-CN`).then(e=>JSON.parse(e.body));t.json(r)}async function downloadResource(e){let t=await $.http.get(e).then(e=>e.body).catch(t=>{res.status(500).json({status:"failed",message:`Cannot refresh remote resource: ${e}\n Reason: ${t}`})});const s=t.indexOf("proxies:");if(-1!==s){const e=t.lastIndexOf("}")+1;t=t.substring(s,e)}return t}async function refreshResource(e,t){const s=new Base64Code,{url:r}=e.body,n=await downloadResource(r);$.write(n,`#${s.safeEncode(r)}`),t.json({status:"success"})}async function downloadSub(e,t){const{name:s}=e.params,r=e.query.target||getPlatformFromHeaders(e.headers),n=$.read(SUBS_KEY);if(n[s]){const e=n[s];try{const s=await parseSub(e,r);t.send(s)}catch(e){t.status(500).json({status:"failed",message:e})}}else t.status(404).json({status:"failed",message:`订阅${s}不存在!`})}async function parseSub(e,t){let s;const r=(new Base64Code).safeEncode(e.url);if("Raw"===t||"URI"===t){const t=$.read(`#${r}`);t?(await $.wait(10),s=t):(s=await downloadResource(e.url),$.write(s,`#${r}`))}else s=await downloadResource(e.url),$.write(s,`#${e.url}`);$.info("======================================================================="),$.info(`Processing subscription: ${e.name}, target platform ==> ${t}.`),$.info("Initializing parsers...");const n=ProxyParser(t);n.addParsers([Clash_All,URI_SS,URI_SSR,URI_VMess,URI_Trojan,QX_SS,QX_SSR,QX_VMess,QX_Trojan,QX_Http,Loon_SS,Loon_SSR,Loon_VMess,Loon_Trojan,Loon_Http,Surge_SS,Surge_VMess,Surge_Trojan,Surge_Http]),$.info("Parsers initialized.");let o=n.parse(s);for(const t of e.process||[]){let e;if(-1!==t.type.indexOf("Script")){const{mode:s,content:r}=t.args;e="link"===s?await $.http.get(r).then(e=>e.body).catch(e=>{throw new Error(`Error when downloading remote script: ${t.args.content}.\n Reason: ${e}`)}):r}if(-1!==t.type.indexOf("Filter")){const s=AVAILABLE_FILTERS[t.type];if(s){$.info(`Applying filter "${t.type}" with arguments:\n >>> ${JSON.stringify(t.args)||"None"}`);try{o=-1!==t.type.indexOf("Script")?processFilter(s(e),o):processFilter(s(t.args),o)}catch(e){$.error(`Failed to apply filter "${t.type}"!\n REASON: ${e}`)}}}else if(-1!==t.type.indexOf("Operator")){const s=AVAILABLE_OPERATORS[t.type];if(s){$.info(`Applying operator "${t.type}" with arguments: \n >>> ${JSON.stringify(t.args)||"None"}`);try{o=-1!==t.type.indexOf("Script")?processOperator(s(e),o):processOperator(s(t.args),o)}catch(e){t.type}}}}return n.addProducers([QX_Producer,Loon_Producer,Surge_Producer,Raw_Producer,URI_Producer]),n.produce(o)}function getFlowHeaders(e,t){const s=Object.keys(e).filter(e=>/SUBSCRIPTION-USERINFO/i.test(e))[0];if(s){const t=e[s],r=Number(t.match(/upload=(\d+)/)[1]),n=Number(t.match(/download=(\d+)/)[1]),o=Number(t.match(/total=(\d+)/)[1]),a=(t.match(/expire=(\d+)/)||[])[1];return{key:"Subscription-Userinfo",value:`${r?"upload="+r+";":""}${n?"download="+n+";":""}${o?"total="+o+";":""}${a?"expire="+a+";":""}`}}{let e,s;for(const r of t)-1!==r.name.indexOf("剩余流量")&&(e=r.name),-1!==r.name.indexOf("过期时间")&&(s=r.name);return{key:"Raw-Subscription-Userinfo",value:`${e?"remains="+e+";":""}${s?"expire="+s+";":""}`}}}async function getSub(e,t){const{name:s}=e.params,r=$.read(SUBS_KEY)[s];r?t.json({status:"success",data:r}):t.status(404).json({status:"failed",message:`未找到订阅:${s}!`})}async function newSub(e,t){const s=e.body,r=$.read(SUBS_KEY);r[s.name]&&t.status(500).json({status:"failed",message:`订阅${s.name}已存在!`}),/^[\w-_]*$/.test(s.name)?(r[s.name]=s,$.write(r,SUBS_KEY),t.status(201).json({status:"success",data:s})):t.status(500).json({status:"failed",message:`订阅名称 ${s.name} 中含有非法字符!名称中只能包含英文字母、数字、下划线、横杠。`})}async function updateSub(e,t){const{name:s}=e.params;$.info(`Updating subscription: ${s}`);let r=e.body;const n=$.read(SUBS_KEY);if(n[s]){const e={...n[s],...r};if(s!==r.name){const t=$.read(COLLECTIONS_KEY);for(const e of Object.keys(t)){const n=t[e].subscriptions.indexOf(s);-1!==n&&(t[e].subscriptions[n]=r.name)}delete n[s],n[r.name]=e}else n[s]=e;$.write(n,SUBS_KEY),t.json({status:"success",data:e})}else t.statuLine truncated
|
||||
@@ -45,6 +45,8 @@
|
||||
</v-chip-group>
|
||||
<v-text-field
|
||||
placeholder="添加新关键词"
|
||||
clearable
|
||||
clear-icon="clear"
|
||||
solo
|
||||
v-model="form.keyword"
|
||||
append-icon="mdi-send"
|
||||
|
||||
@@ -56,6 +56,8 @@
|
||||
</v-chip-group>
|
||||
<v-text-field
|
||||
placeholder="添加新关键词"
|
||||
clearable
|
||||
clear-icon="clear"
|
||||
solo
|
||||
v-model="form.keyword"
|
||||
append-icon="mdi-send"
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
<v-row>
|
||||
<v-col>
|
||||
<v-text-field
|
||||
clearable
|
||||
clear-icon="clear"
|
||||
placeholder="关键词"
|
||||
solo
|
||||
v-model="form.keyword"
|
||||
@@ -53,6 +55,8 @@
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-text-field
|
||||
clearable
|
||||
clear-icon="clear"
|
||||
placeholder="替换为"
|
||||
solo
|
||||
v-model="form.replace"
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
</v-chip-group>
|
||||
<v-text-field
|
||||
placeholder="添加新关键词"
|
||||
clearable
|
||||
clear-icon="clear"
|
||||
solo
|
||||
v-model="form.keyword"
|
||||
append-icon="mdi-send"
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
</v-chip-group>
|
||||
<v-text-field
|
||||
placeholder="添加新正则表达式"
|
||||
clearable
|
||||
clear-icon="clear"
|
||||
solo
|
||||
v-model="form.regex"
|
||||
append-icon="mdi-send"
|
||||
|
||||
@@ -60,6 +60,8 @@
|
||||
</v-chip-group>
|
||||
<v-text-field
|
||||
placeholder="添加新正则表达式"
|
||||
clearable
|
||||
clear-icon="clear"
|
||||
solo
|
||||
v-model="form.regex"
|
||||
append-icon="mdi-send"
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
<v-col>
|
||||
<v-text-field
|
||||
placeholder="正则表达式"
|
||||
clearable
|
||||
clear-icon="clear"
|
||||
solo
|
||||
v-model="form.regex"
|
||||
/>
|
||||
@@ -55,6 +57,8 @@
|
||||
<v-text-field
|
||||
placeholder="替换为"
|
||||
solo
|
||||
clearable
|
||||
clear-icon="clear"
|
||||
v-model="form.replace"
|
||||
append-icon="mdi-send"
|
||||
@click:append="add"
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
</v-card-text>
|
||||
<v-textarea
|
||||
solo
|
||||
clearable
|
||||
clear-icon="clear"
|
||||
:label="hint"
|
||||
v-model="content"
|
||||
/>
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
</v-radio-group>
|
||||
</v-card-text>
|
||||
<v-textarea
|
||||
clearable
|
||||
clear-icon="clear"
|
||||
solo
|
||||
:label="hint"
|
||||
v-model="content"
|
||||
|
||||
Reference in new issue
Block a user