mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-06 05:04:22 +00:00
fix(inbounds): prevent search from matching raw JSON field names in settings/streamSettings
This commit is contained in:
parent
2928b52b04
commit
54571944bb
1 changed files with 17 additions and 6 deletions
|
|
@ -129,10 +129,12 @@ function applySecondaryFilters(rows) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Search / filter projection =============================
|
// ============ Search / filter projection =============================
|
||||||
// Mirrors the legacy logic: when searching, keep inbounds that match
|
// Search mode: match on inbound metadata (remark, tag, listen, protocol,
|
||||||
// anywhere (deep search); when filtering, keep inbounds that have at
|
// port) and parsed client fields. Raw JSON strings (settings, streamSettings,
|
||||||
// least one client in the requested bucket and reduce their settings
|
// sniffing) are NOT searched as text to avoid false matches on internal
|
||||||
// to that bucket.
|
// JSON keys like "echForceQuery".
|
||||||
|
// Filter mode: keep inbounds that have at least one client in the requested
|
||||||
|
// bucket and reduce their settings to that bucket.
|
||||||
function projectInbound(dbInbound, predicate) {
|
function projectInbound(dbInbound, predicate) {
|
||||||
const next = new DBInbound(dbInbound);
|
const next = new DBInbound(dbInbound);
|
||||||
let settings;
|
let settings;
|
||||||
|
|
@ -163,8 +165,17 @@ const visibleInbounds = computed(() => {
|
||||||
if (ObjectUtil.isEmpty(searchKey.value)) return applySecondaryFilters([...props.dbInbounds]);
|
if (ObjectUtil.isEmpty(searchKey.value)) return applySecondaryFilters([...props.dbInbounds]);
|
||||||
const out = [];
|
const out = [];
|
||||||
for (const dbInbound of props.dbInbounds) {
|
for (const dbInbound of props.dbInbounds) {
|
||||||
if (!ObjectUtil.deepSearch(dbInbound, searchKey.value)) continue;
|
let settings;
|
||||||
out.push(projectInbound(dbInbound, (client) => ObjectUtil.deepSearch(client, searchKey.value)));
|
try { settings = JSON.parse(dbInbound.settings || '{}'); } catch (_e) { settings = {}; }
|
||||||
|
const clients = Array.isArray(settings.clients) ? settings.clients : [];
|
||||||
|
const hasClientMatch = clients.some(client => ObjectUtil.deepSearch(client, searchKey.value));
|
||||||
|
const metaFields = [dbInbound.remark, dbInbound.tag, dbInbound.listen, dbInbound.protocol];
|
||||||
|
const hasMetaMatch = metaFields.some(f => String(f || '').toLowerCase().includes(searchKey.value.toLowerCase())) ||
|
||||||
|
String(dbInbound.port || '').includes(searchKey.value);
|
||||||
|
if (!hasClientMatch && !hasMetaMatch) continue;
|
||||||
|
out.push(projectInbound(dbInbound, hasClientMatch
|
||||||
|
? (client) => ObjectUtil.deepSearch(client, searchKey.value)
|
||||||
|
: () => true));
|
||||||
}
|
}
|
||||||
return applySecondaryFilters(out);
|
return applySecondaryFilters(out);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue