mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-11 03:19:02 +08:00
Merge ; commit '5b1e24a4afdc1ca8d06293c172f7130a1c91a1fc'
Conflicts: backend/sub-store.min.js
This commit is contained in:
commit
fa30c487ab
@ -773,10 +773,10 @@ function service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function refreshCache(req, res) {
|
async function refreshCache(req, res) {
|
||||||
const {url} = req.body;
|
const { url, ua } = req.body;
|
||||||
$.info(`Refreshing cache for URL: ${url}`);
|
$.info(`Refreshing cache for URL: ${url}`);
|
||||||
try {
|
try {
|
||||||
const raw = await getResource(url, false);
|
const raw = await getResource(url, false, ua);
|
||||||
$.write(raw, `#${Base64.safeEncode(url)}`);
|
$.write(raw, `#${Base64.safeEncode(url)}`);
|
||||||
res.json({
|
res.json({
|
||||||
status: "success",
|
status: "success",
|
||||||
@ -871,11 +871,16 @@ function service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get resource, with cache ability to speedup response time
|
// get resource, with cache ability to speedup response time
|
||||||
async function getResource(url, useCache = true) {
|
async function getResource(url, useCache = true, userAgent) {
|
||||||
// use QX agent to get flow headers
|
// use QX agent to get flow headers ,if not assign user-agent
|
||||||
|
let ua = userAgent
|
||||||
|
if (typeof userAgent == "undefined" || userAgent == null || userAgent.trim().length == 0) {
|
||||||
|
ua = "Quantumult%20X"
|
||||||
|
}
|
||||||
|
|
||||||
const $http = HTTP({
|
const $http = HTTP({
|
||||||
headers: {
|
headers: {
|
||||||
"User-Agent": "Quantumult%20X",
|
"User-Agent": ua,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const key = "#" + Base64.safeEncode(url);
|
const key = "#" + Base64.safeEncode(url);
|
||||||
@ -915,7 +920,7 @@ function service() {
|
|||||||
) {
|
) {
|
||||||
if (type === "subscription") {
|
if (type === "subscription") {
|
||||||
const sub = item;
|
const sub = item;
|
||||||
const raw = await getResource(sub.url, useCache);
|
const raw = await getResource(sub.url, useCache, sub.ua);
|
||||||
// parse proxies
|
// parse proxies
|
||||||
let proxies = ProxyUtils.parse(raw);
|
let proxies = ProxyUtils.parse(raw);
|
||||||
if (!noProcessor) {
|
if (!noProcessor) {
|
||||||
@ -945,7 +950,7 @@ function service() {
|
|||||||
}% `
|
}% `
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
const raw = await getResource(sub.url, useCache);
|
const raw = await getResource(sub.url, useCache, sub.ua);
|
||||||
// parse proxies
|
// parse proxies
|
||||||
let currentProxies = ProxyUtils.parse(raw);
|
let currentProxies = ProxyUtils.parse(raw);
|
||||||
if (!noProcessor) {
|
if (!noProcessor) {
|
||||||
@ -1379,13 +1384,13 @@ var ProxyUtils = (function () {
|
|||||||
let paramArr = line.split("?")
|
let paramArr = line.split("?")
|
||||||
let sni=null
|
let sni=null
|
||||||
if (paramArr.length > 1) {
|
if (paramArr.length > 1) {
|
||||||
paramArr=paramArr[1].split("#")[0].split("&")
|
paramArr = paramArr[1].split("#")[0].split("&")
|
||||||
const params = new Map(paramArr.map((item) => {
|
const params = new Map(paramArr.map((item) => {
|
||||||
return item.split("=")
|
return item.split("=")
|
||||||
}))
|
}))
|
||||||
sni = params.get("sni")
|
sni = params.get("sni")
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: name || `[Trojan] ${server}`, // trojan uri may have no server tag!
|
name: name || `[Trojan] ${server}`, // trojan uri may have no server tag!
|
||||||
type: "trojan",
|
type: "trojan",
|
||||||
|
4
backend/sub-store.min.js
vendored
4
backend/sub-store.min.js
vendored
File diff suppressed because one or more lines are too long
@ -49,6 +49,16 @@
|
|||||||
/>
|
/>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list>
|
</v-list>
|
||||||
|
<v-textarea
|
||||||
|
v-model="options.ua"
|
||||||
|
auto-grow
|
||||||
|
class="mt-2"
|
||||||
|
clear-icon="clear"
|
||||||
|
clearable
|
||||||
|
label="User-Agent"
|
||||||
|
placeholder="自定义下载订阅使用的User-Agent,可选。"
|
||||||
|
rows="2"
|
||||||
|
/>
|
||||||
<v-textarea
|
<v-textarea
|
||||||
v-model="options.icon"
|
v-model="options.icon"
|
||||||
auto-grow
|
auto-grow
|
||||||
@ -354,6 +364,7 @@ export default {
|
|||||||
name: "",
|
name: "",
|
||||||
url: "",
|
url: "",
|
||||||
icon: "",
|
icon: "",
|
||||||
|
ua: "",
|
||||||
useless: "KEEP",
|
useless: "KEEP",
|
||||||
udp: "DEFAULT",
|
udp: "DEFAULT",
|
||||||
"skip-cert-verify": "DEFAULT",
|
"skip-cert-verify": "DEFAULT",
|
||||||
@ -413,6 +424,13 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
output.url = this.options.url;
|
output.url = this.options.url;
|
||||||
}
|
}
|
||||||
|
// assign user-agent, if ua is set
|
||||||
|
let ua = this.options.ua;
|
||||||
|
if (typeof ua != "undefined" && ua != null && ua.trim().length > 0) {
|
||||||
|
output.ua = ua;
|
||||||
|
}else{
|
||||||
|
output.ua=""
|
||||||
|
}
|
||||||
// useless filter
|
// useless filter
|
||||||
if (this.options.useless === 'REMOVE') {
|
if (this.options.useless === 'REMOVE') {
|
||||||
output.process.push({
|
output.process.push({
|
||||||
@ -573,6 +591,7 @@ function loadProcess(options, source, isCollection = false) {
|
|||||||
...options,
|
...options,
|
||||||
name: source.name,
|
name: source.name,
|
||||||
icon: source.icon,
|
icon: source.icon,
|
||||||
|
ua: source.ua
|
||||||
};
|
};
|
||||||
if (isCollection) {
|
if (isCollection) {
|
||||||
options.subscriptions = source.subscriptions;
|
options.subscriptions = source.subscriptions;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user