Skip to content

Commit fa1cc40

Browse files
authored
IPv6 support for dns debugging and skip proxy address feature (#3801)
Skip Proxy Address feature relies on the openclash_debug_dns.lua script. This update has added IPv6 support, enabling the Skip Proxy Address functionality to also support IPv6.
1 parent b12c016 commit fa1cc40

File tree

1 file changed

+55
-49
lines changed

1 file changed

+55
-49
lines changed

luci-app-openclash/root/usr/share/openclash/openclash_debug_dns.lua

+55-49
Original file line numberDiff line numberDiff line change
@@ -22,61 +22,67 @@ local function debug_dns()
2222
local passwd = uci:get("openclash", "config", "dashboard_password") or ""
2323

2424
if datatype.hostname(addr) and ip and port then
25-
info = luci.sys.exec(string.format('curl -sL -m 3 -H "Content-Type: application/json" -H "Authorization: Bearer %s" -XGET http://"%s":"%s"/dns/query?name="%s"', passwd, ip, port, addr))
26-
if info then
27-
info = json.parse(info)
25+
info_v4 = luci.sys.exec(string.format('curl -sL -m 3 -H "Content-Type: application/json" -H "Authorization: Bearer %s" -XGET http://"%s":"%s"/dns/query?name="%s"', passwd, ip, port, addr))
26+
info_v6 = luci.sys.exec(string.format('curl -sL -m 3 -H "Content-Type: application/json" -H "Authorization: Bearer %s" -XGET \"http://"%s":"%s"/dns/query?name="%s"&type=AAAA\"', passwd, ip, port, addr))
27+
if info_v4 then
28+
info_v4 = json.parse(info_v4)
2829
end
29-
if info and not resolve then
30-
print("Status: "..(info.Status))
31-
print("TC: "..tostring(info.TC))
32-
print("RD: "..tostring(info.RD))
33-
print("RA: "..tostring(info.RA))
34-
print("AD: "..tostring(info.AD))
35-
print("CD: "..tostring(info.CD))
36-
print("")
37-
print("Question: ")
38-
for _, v in pairs(info.Question) do
39-
print(" Name: "..(v.Name))
40-
print(" Qtype: "..(v.Qtype))
41-
print(" Qclass: "..(v.Qclass))
30+
if info_v6 then
31+
info_v6 = json.parse(info_v6)
32+
end
33+
for _, info in pairs({info_v4, info_v6}) do
34+
if info and not resolve then
35+
print("Status: "..(info.Status))
36+
print("TC: "..tostring(info.TC))
37+
print("RD: "..tostring(info.RD))
38+
print("RA: "..tostring(info.RA))
39+
print("AD: "..tostring(info.AD))
40+
print("CD: "..tostring(info.CD))
4241
print("")
43-
end
44-
if info.Answer then
45-
print("Answer: ")
46-
for _, v in pairs(info.Answer) do
47-
print(" TTL: "..(v.TTL))
48-
print(" data: "..(v.data:gsub("\n?", "")))
49-
print(" name: "..(v.name))
50-
print(" type: "..(v.type))
42+
print("Question: ")
43+
for _, v in pairs(info.Question) do
44+
print(" Name: "..(v.Name))
45+
print(" Qtype: "..(v.Qtype))
46+
print(" Qclass: "..(v.Qclass))
5147
print("")
5248
end
53-
end
54-
if info.Additional then
55-
print("Additional: ")
56-
for _, v in pairs(info.Additional) do
57-
print(" TTL: "..(v.TTL))
58-
print(" data: "..(v.data:gsub("\n?", "")))
59-
print(" name: "..(v.name))
60-
print(" type: "..(v.type))
61-
print("")
49+
if info.Answer then
50+
print("Answer: ")
51+
for _, v in pairs(info.Answer) do
52+
print(" TTL: "..(v.TTL))
53+
print(" data: "..(v.data:gsub("\n?", "")))
54+
print(" name: "..(v.name))
55+
print(" type: "..(v.type))
56+
print("")
57+
end
6258
end
63-
end
64-
if info.Authority then
65-
print("Authority: ")
66-
for _, v in pairs(info.Authority) do
67-
print(" TTL: "..(v.TTL))
68-
print(" data: "..(v.data:gsub("\n?", "")))
69-
print(" name: "..(v.name))
70-
print(" type: "..(v.type))
71-
print("")
59+
if info.Additional then
60+
print("Additional: ")
61+
for _, v in pairs(info.Additional) do
62+
print(" TTL: "..(v.TTL))
63+
print(" data: "..(v.data:gsub("\n?", "")))
64+
print(" name: "..(v.name))
65+
print(" type: "..(v.type))
66+
print("")
67+
end
68+
end
69+
if info.Authority then
70+
print("Authority: ")
71+
for _, v in pairs(info.Authority) do
72+
print(" TTL: "..(v.TTL))
73+
print(" data: "..(v.data:gsub("\n?", "")))
74+
print(" name: "..(v.name))
75+
print(" type: "..(v.type))
76+
print("")
77+
end
7278
end
7379
end
74-
end
75-
if info and resolve then
76-
if info.Answer then
77-
for _, v in pairs(info.Answer) do
78-
if v.type == 1 then
79-
print(v.data)
80+
if info and resolve then
81+
if info.Answer then
82+
for _, v in pairs(info.Answer) do
83+
if v.type == 1 or v.type == 28 then
84+
print(v.data)
85+
end
8086
end
8187
end
8288
end
@@ -85,4 +91,4 @@ local function debug_dns()
8591
os.exit(0)
8692
end
8793

88-
debug_dns()
94+
debug_dns()

0 commit comments

Comments
 (0)