mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-10 02:49:01 +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) {
|
||||
const {url} = req.body;
|
||||
const { url, ua } = req.body;
|
||||
$.info(`Refreshing cache for URL: ${url}`);
|
||||
try {
|
||||
const raw = await getResource(url, false);
|
||||
const raw = await getResource(url, false, ua);
|
||||
$.write(raw, `#${Base64.safeEncode(url)}`);
|
||||
res.json({
|
||||
status: "success",
|
||||
@ -871,11 +871,16 @@ function service() {
|
||||
}
|
||||
|
||||
// get resource, with cache ability to speedup response time
|
||||
async function getResource(url, useCache = true) {
|
||||
// use QX agent to get flow headers
|
||||
async function getResource(url, useCache = true, userAgent) {
|
||||
// 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({
|
||||
headers: {
|
||||
"User-Agent": "Quantumult%20X",
|
||||
"User-Agent": ua,
|
||||
},
|
||||
});
|
||||
const key = "#" + Base64.safeEncode(url);
|
||||
@ -915,7 +920,7 @@ function service() {
|
||||
) {
|
||||
if (type === "subscription") {
|
||||
const sub = item;
|
||||
const raw = await getResource(sub.url, useCache);
|
||||
const raw = await getResource(sub.url, useCache, sub.ua);
|
||||
// parse proxies
|
||||
let proxies = ProxyUtils.parse(raw);
|
||||
if (!noProcessor) {
|
||||
@ -945,7 +950,7 @@ function service() {
|
||||
}% `
|
||||
);
|
||||
try {
|
||||
const raw = await getResource(sub.url, useCache);
|
||||
const raw = await getResource(sub.url, useCache, sub.ua);
|
||||
// parse proxies
|
||||
let currentProxies = ProxyUtils.parse(raw);
|
||||
if (!noProcessor) {
|
||||
@ -1379,13 +1384,13 @@ var ProxyUtils = (function () {
|
||||
let paramArr = line.split("?")
|
||||
let sni=null
|
||||
if (paramArr.length > 1) {
|
||||
paramArr=paramArr[1].split("#")[0].split("&")
|
||||
paramArr = paramArr[1].split("#")[0].split("&")
|
||||
const params = new Map(paramArr.map((item) => {
|
||||
return item.split("=")
|
||||
}))
|
||||
sni = params.get("sni")
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
name: name || `[Trojan] ${server}`, // trojan uri may have no server tag!
|
||||
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>
|
||||
<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-model="options.icon"
|
||||
auto-grow
|
||||
@ -354,6 +364,7 @@ export default {
|
||||
name: "",
|
||||
url: "",
|
||||
icon: "",
|
||||
ua: "",
|
||||
useless: "KEEP",
|
||||
udp: "DEFAULT",
|
||||
"skip-cert-verify": "DEFAULT",
|
||||
@ -413,6 +424,13 @@ export default {
|
||||
} else {
|
||||
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
|
||||
if (this.options.useless === 'REMOVE') {
|
||||
output.process.push({
|
||||
@ -573,6 +591,7 @@ function loadProcess(options, source, isCollection = false) {
|
||||
...options,
|
||||
name: source.name,
|
||||
icon: source.icon,
|
||||
ua: source.ua
|
||||
};
|
||||
if (isCollection) {
|
||||
options.subscriptions = source.subscriptions;
|
||||
|
Loading…
x
Reference in New Issue
Block a user