MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / parseDnsRecord

Function parseDnsRecord

dig/dig.ts:255–279  ·  view source on GitHub ↗
(
  line: string
)

Source from the content-addressed store, hash-verified

253 const domain = parts[0]?.replace(/\.$/, "") || "";
254 let ttl = "";
255 let type = "";
256 let value = "";
257
258 const inIndex = parts.findIndex((p) => p === "IN");
259 if (inIndex >= 0 && inIndex + 2 < parts.length) {
260 if (inIndex > 1) ttl = parts[inIndex - 1] || "";
261 type = parts[inIndex + 1] || "";
262 value = parts.slice(inIndex + 2).join(" ");
263 } else if (parts.length >= 4) {
264 type = parts[parts.length - 2] || "";
265 value = parts[parts.length - 1] || "";
266 }
267
268 return { domain, type, value, ttl };
269}
270
271async function formatDetailedDnsResults(
272 output: string,
273 args: string[]
274): Promise<string> {
275 if (!output || output.trim() === "") {
276 return `❌ <b>解析失败</b>
277
278无记录或查询失败`;
279 }
280
281 const lines = output.split("\n");
282

Callers 1

formatDetailedDnsResultsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected