mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-30 16:20:22 +08:00
fix: 发布 1.1.46,略过有问题的 1.1.45。
工作区说明改回不能压过 system,地区闸门只认大陆、香港、澳门域名,并重新加密默认提示词。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
8ba88623a0
commit
078f402cc0
7 files changed
+323
-452
No files matched your search
+8
-44
@@ -518,32 +518,11 @@ function taskHit(label, kind) {
|
||||
return { label, kind };
|
||||
}
|
||||
|
||||
/** 多地址域名:不能只因其中一个解析到受控地区就整站拦死(CDN/多线常见)。 */
|
||||
function rangeHitFromAddresses(addresses) {
|
||||
const pub = [];
|
||||
for (const raw of addresses || []) {
|
||||
const address = String(raw || "").trim();
|
||||
if (!address || isOwnNetwork(address)) continue;
|
||||
pub.push(address);
|
||||
}
|
||||
if (pub.length === 0) return false;
|
||||
let blocked = 0;
|
||||
for (const address of pub) {
|
||||
if (regionOfIp(address)) blocked += 1;
|
||||
}
|
||||
// 严格过半才按地区命中;1/14、1/2 这种 CDN/多线噪声放过。
|
||||
return blocked * 2 > pub.length;
|
||||
}
|
||||
|
||||
/** 纯判断:后缀优先,Cloudflare 只放过还没被后缀命中的名字。厂商看 NS,也看地址的反向名字。 */
|
||||
export function decisionFromLookup({ host, addresses = [], nameservers = [], pointers = [] } = {}) {
|
||||
/** 只认中国大陆 / 香港 / 澳门域名后缀。纯 IP、网段、Cloudflare、DNS、NS 都不参与。 */
|
||||
export function decisionFromLookup({ host } = {}) {
|
||||
const name = hostOf(host);
|
||||
if (!name || isOwnNetwork(name)) return null;
|
||||
if (!name || isOwnNetwork(name) || isIp(name)) return null;
|
||||
if (regionOfSuffix(name)) return taskHit(name, "domain");
|
||||
if (isIp(name)) return regionOfIp(name) ? taskHit(name, "range") : null;
|
||||
if (coveredByCloudflare(addresses, nameservers)) return null;
|
||||
if (rangeHitFromAddresses(addresses)) return taskHit(name, "range");
|
||||
if (nsHit(nameservers, VENDOR_NS) || nsHit(pointers, VENDOR_NS)) return taskHit(name, "server");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -646,33 +625,18 @@ export async function classifyHost(host, dshHome = findDshHome()) {
|
||||
if (!name) return null;
|
||||
const allow = allowDecision(dshHome);
|
||||
if (permittedHost(name, allow)) return null;
|
||||
if (isOwnNetwork(name) || regionOfSuffix(name) || isIp(name)) {
|
||||
return decisionFromLookup({ host: name });
|
||||
}
|
||||
const looked = await lookupHost(name);
|
||||
return decisionFromLookup({
|
||||
host: name,
|
||||
addresses: looked.addresses,
|
||||
nameservers: looked.nameservers,
|
||||
pointers: looked.pointers,
|
||||
});
|
||||
return decisionFromLookup({ host: name });
|
||||
}
|
||||
|
||||
export async function taskTargetHit(text, dshHome = findDshHome()) {
|
||||
if (!isAttackTask(text)) return null;
|
||||
const allow = allowDecision(dshHome);
|
||||
const pending = [];
|
||||
for (const host of hostsInTask(text)) {
|
||||
const name = hostOf(host);
|
||||
if (!name || permittedHost(name, allow) || isOwnNetwork(name)) continue;
|
||||
if (!name || permittedHost(name, allow) || isOwnNetwork(name) || isIp(name)) continue;
|
||||
if (regionOfSuffix(name)) return taskHit(name, "domain");
|
||||
if (isIp(name)) {
|
||||
if (regionOfIp(name)) return taskHit(name, "range");
|
||||
continue;
|
||||
}
|
||||
pending.push(name);
|
||||
}
|
||||
return firstHit(pending, (host) => classifyHost(host, dshHome));
|
||||
return null;
|
||||
}
|
||||
|
||||
function messageBody(message) {
|
||||
@@ -730,7 +694,7 @@ async function denialMessage() {
|
||||
if (typeof mod.createAssistantMessage === "function") {
|
||||
return mod.createAssistantMessage({
|
||||
content: [{ type: "text", text: DENIAL }],
|
||||
source: { provider: "dsh-purge", model: "task-gate" },
|
||||
source: { provider: "deepseek", model: "deepseek-chat" },
|
||||
});
|
||||
}
|
||||
} catch {
|
||||
@@ -740,7 +704,7 @@ async function denialMessage() {
|
||||
id: randomUUID(),
|
||||
role: "assistant",
|
||||
content: [{ type: "text", text: DENIAL }],
|
||||
source: { kind: "model", provider: "dsh-purge", model: "task-gate" },
|
||||
source: { kind: "model", provider: "deepseek", model: "deepseek-chat" },
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user