fixed possibility of duplicate entries
This commit is contained in:
@@ -277,7 +277,25 @@ cache_log /var/log/squid/cache.log
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
function genDomains(s) {
|
function genDomains(s) {
|
||||||
return s.domains.map(d => d.startsWith('*.') ? '.' + d.slice(2) : d).join('\n') + '\n';
|
let wildcardBases = s.domains
|
||||||
|
.filter(d => d.startsWith('*.'))
|
||||||
|
.map(d => d.slice(2));
|
||||||
|
wildcardBases = wildcardBases.filter(base =>
|
||||||
|
!wildcardBases.some(other => other !== base && base.endsWith('.' + other))
|
||||||
|
);
|
||||||
|
const isCovered = d => wildcardBases.some(b => d === b || d.endsWith('.' + b));
|
||||||
|
const seen = new Set();
|
||||||
|
const out = [];
|
||||||
|
for (const base of wildcardBases) {
|
||||||
|
const dotted = '.' + base;
|
||||||
|
if (!seen.has(dotted)) { out.push(dotted); seen.add(dotted); }
|
||||||
|
}
|
||||||
|
for (const d of s.domains) {
|
||||||
|
if (d.startsWith('*.')) continue;
|
||||||
|
if (isCovered(d) || seen.has(d)) continue;
|
||||||
|
out.push(d); seen.add(d);
|
||||||
|
}
|
||||||
|
return out.join('\n') + '\n';
|
||||||
}
|
}
|
||||||
function genWpad(s) {
|
function genWpad(s) {
|
||||||
return `function FindProxyForURL(url, host) {
|
return `function FindProxyForURL(url, host) {
|
||||||
|
|||||||
+34
-5
@@ -105,11 +105,40 @@ cache_log /var/log/squid/cache.log
|
|||||||
}
|
}
|
||||||
|
|
||||||
function generateVpnDomains(s) {
|
function generateVpnDomains(s) {
|
||||||
return (
|
// Wildcards: '*.foo.bar' -> covers 'foo.bar' und alle Subdomains in squid
|
||||||
s.domains
|
let wildcardBases = s.domains
|
||||||
.map((d) => (d.startsWith("*.") ? "." + d.slice(2) : d))
|
.filter((d) => d.startsWith("*."))
|
||||||
.join("\n") + "\n"
|
.map((d) => d.slice(2));
|
||||||
);
|
|
||||||
|
// Dedupe: wenn '*.bar' und '*.foo.bar' beide drin sind, '*.foo.bar' droppen
|
||||||
|
wildcardBases = wildcardBases.filter((base) => {
|
||||||
|
return !wildcardBases.some(
|
||||||
|
(other) => other !== base && base.endsWith("." + other)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const isCoveredByWildcard = (d) =>
|
||||||
|
wildcardBases.some((base) => d === base || d.endsWith("." + base));
|
||||||
|
|
||||||
|
const seen = new Set();
|
||||||
|
const out = [];
|
||||||
|
|
||||||
|
for (const base of wildcardBases) {
|
||||||
|
const dotted = "." + base;
|
||||||
|
if (!seen.has(dotted)) {
|
||||||
|
out.push(dotted);
|
||||||
|
seen.add(dotted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const d of s.domains) {
|
||||||
|
if (d.startsWith("*.")) continue;
|
||||||
|
if (isCoveredByWildcard(d) || seen.has(d)) continue;
|
||||||
|
out.push(d);
|
||||||
|
seen.add(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
return out.join("\n") + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateWpadDat(s) {
|
function generateWpadDat(s) {
|
||||||
|
|||||||
Reference in New Issue
Block a user