mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
fix: the problem that the DNS override nameserver-policy field cannot correctly recognize multiple writing methods (#4011)
* fix: the problem that the DNS override nameserver-policy field cannot correctly recognize multiple writing methods * update logs * fix-dns-viewer.tsx
This commit is contained in:
@@ -10,7 +10,8 @@
|
|||||||
- 修复导入订阅时非 http 协议链接被错误尝试导入
|
- 修复导入订阅时非 http 协议链接被错误尝试导入
|
||||||
- 修复切换节点后页面长时间 loading 及缓存过期导致的数据不同步问题
|
- 修复切换节点后页面长时间 loading 及缓存过期导致的数据不同步问题
|
||||||
- 修复将快捷键名称更名为 `Clash Verge`之后无法删除图标和无法删除注册表
|
- 修复将快捷键名称更名为 `Clash Verge`之后无法删除图标和无法删除注册表
|
||||||
- 修复`DNS`覆写服务器支持默认留空
|
- 修复`DNS`覆写 `fallback` `proxy server` `nameserver` `direct Nameserver` 字段支持留空
|
||||||
|
- 修复`DNS`覆写 `nameserver-policy` 字段无法正确识别 `geo` 库
|
||||||
|
|
||||||
### ✨ 新增功能
|
### ✨ 新增功能
|
||||||
|
|
||||||
|
|||||||
@@ -332,54 +332,51 @@ export const DnsViewer = forwardRef<DialogRef>((props, ref) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 格式化nameserver-policy为字符串
|
|
||||||
const formatNameserverPolicy = (policy: any): string => {
|
|
||||||
if (!policy) return "";
|
|
||||||
|
|
||||||
let result: string[] = [];
|
|
||||||
|
|
||||||
Object.entries(policy).forEach(([domain, servers]) => {
|
|
||||||
if (Array.isArray(servers)) {
|
|
||||||
// 处理数组格式的服务器
|
|
||||||
const serversStr = servers.join(";");
|
|
||||||
result.push(`${domain}=${serversStr}`);
|
|
||||||
} else {
|
|
||||||
// 处理单个服务器
|
|
||||||
result.push(`${domain}=${servers}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return result.join(", ");
|
|
||||||
};
|
|
||||||
|
|
||||||
// 解析nameserver-policy为对象
|
// 解析nameserver-policy为对象
|
||||||
const parseNameserverPolicy = (str: string): Record<string, any> => {
|
const parseNameserverPolicy = (str: string): Record<string, any> => {
|
||||||
const result: Record<string, any> = {};
|
const result: Record<string, any> = {};
|
||||||
if (!str) return result;
|
if (!str) return result;
|
||||||
|
|
||||||
str.split(",").forEach((item) => {
|
// 处理geosite:xxx,yyy格式
|
||||||
const parts = item.trim().split("=");
|
const ruleRegex = /\s*([^=]+?)\s*=\s*([^,]+)(?:,|$)/g;
|
||||||
if (parts.length < 2) return;
|
let match;
|
||||||
|
|
||||||
const domain = parts[0].trim();
|
while ((match = ruleRegex.exec(str)) !== null) {
|
||||||
const serversStr = parts.slice(1).join("=").trim();
|
const [, domainsPart, serversPart] = match;
|
||||||
|
|
||||||
// 检查是否包含多个分号分隔的服务器
|
// 处理域名部分
|
||||||
if (serversStr.includes(";")) {
|
let domains;
|
||||||
// 多个服务器,作为数组处理
|
if (domainsPart.startsWith("geosite:")) {
|
||||||
result[domain] = serversStr
|
domains = [domainsPart.trim()];
|
||||||
.split(";")
|
|
||||||
.map((s) => s.trim())
|
|
||||||
.filter(Boolean);
|
|
||||||
} else {
|
} else {
|
||||||
// 单个服务器
|
domains = [domainsPart.trim()];
|
||||||
result[domain] = serversStr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理服务器部分
|
||||||
|
const servers = serversPart.split(";").map((s) => s.trim());
|
||||||
|
|
||||||
|
// 为每个域名组分配相同的服务器列表
|
||||||
|
domains.forEach((domain) => {
|
||||||
|
result[domain] = servers;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 格式化nameserver-policy为字符串
|
||||||
|
const formatNameserverPolicy = (policy: any): string => {
|
||||||
|
if (!policy || typeof policy !== "object") return "";
|
||||||
|
|
||||||
|
// 直接将对象转换为字符串格式
|
||||||
|
return Object.entries(policy)
|
||||||
|
.map(([domain, servers]) => {
|
||||||
|
const serversStr = Array.isArray(servers) ? servers.join(";") : servers;
|
||||||
|
return `${domain}=${serversStr}`;
|
||||||
|
})
|
||||||
|
.join(", ");
|
||||||
|
};
|
||||||
|
|
||||||
// 格式化hosts为字符串
|
// 格式化hosts为字符串
|
||||||
const formatHosts = (hosts: any): string => {
|
const formatHosts = (hosts: any): string => {
|
||||||
if (!hosts || typeof hosts !== "object") return "";
|
if (!hosts || typeof hosts !== "object") return "";
|
||||||
|
|||||||
Reference in New Issue
Block a user