Add gateway auto-deploy and tag matching fallback
This commit is contained in:
@@ -184,8 +184,8 @@ async function handleApi(req, res) {
|
||||
|
||||
if (req.method === 'POST' && req.url === '/api/apply') {
|
||||
const body = await readBody(req);
|
||||
const selectedTag = String(body.selectedTag || '').trim();
|
||||
if (!selectedTag) return sendJson(res, 400, { success: false, error: 'selectedTag is required' });
|
||||
const selectedTag = String(body.selectedTag || '');
|
||||
if (!selectedTag.trim()) return sendJson(res, 400, { success: false, error: 'selectedTag is required' });
|
||||
|
||||
const cached = readJson(settings.subscriptionCachePath, null);
|
||||
if (!cached?.config) {
|
||||
|
||||
@@ -11,7 +11,11 @@ function clone(value) {
|
||||
|
||||
function findOutbound(subscriptionConfig, selectedTag) {
|
||||
const outbounds = Array.isArray(subscriptionConfig?.outbounds) ? subscriptionConfig.outbounds : [];
|
||||
return outbounds.find((outbound) => outbound.tag === selectedTag && PROXY_TYPES.has(outbound.type));
|
||||
const exact = outbounds.find((outbound) => outbound.tag === selectedTag && PROXY_TYPES.has(outbound.type));
|
||||
if (exact) return exact;
|
||||
|
||||
const trimmedTag = String(selectedTag || '').trim();
|
||||
return outbounds.find((outbound) => String(outbound.tag || '').trim() === trimmedTag && PROXY_TYPES.has(outbound.type));
|
||||
}
|
||||
|
||||
function ruleSets() {
|
||||
|
||||
Reference in New Issue
Block a user