luci-app-mosdns: add block local PTR requests
* according to https://github.com/IrineSistiana/mosdns/discussions/39#discussioncomment-286339
This commit is contained in:
parent
6ebb46c873
commit
459a87d6ef
@ -4,6 +4,7 @@ local white_list_file = "/etc/mosdns/rule/whitelist.txt"
|
|||||||
local block_list_file = "/etc/mosdns/rule/blocklist.txt"
|
local block_list_file = "/etc/mosdns/rule/blocklist.txt"
|
||||||
local hosts_list_file = "/etc/mosdns/rule/hosts.txt"
|
local hosts_list_file = "/etc/mosdns/rule/hosts.txt"
|
||||||
local redirect_list_file = "/etc/mosdns/rule/redirect.txt"
|
local redirect_list_file = "/etc/mosdns/rule/redirect.txt"
|
||||||
|
local local_ptr_file = "/etc/mosdns/rule/local-ptr.txt"
|
||||||
|
|
||||||
m = Map("mosdns")
|
m = Map("mosdns")
|
||||||
|
|
||||||
@ -14,6 +15,7 @@ s:tab("white_list", translate("White Lists"))
|
|||||||
s:tab("block_list", translate("Block Lists"))
|
s:tab("block_list", translate("Block Lists"))
|
||||||
s:tab("hosts_list", translate("Hosts"))
|
s:tab("hosts_list", translate("Hosts"))
|
||||||
s:tab("redirect_list", translate("Redirect"))
|
s:tab("redirect_list", translate("Redirect"))
|
||||||
|
s:tab("local_ptr_list", translate("Block PTR"))
|
||||||
|
|
||||||
o = s:taboption("white_list", TextValue, "whitelist", "", "<font color='red'>" .. translate("These domain names allow DNS resolution with the highest priority. Please input the domain names of websites, every line can input only one website domain. For example: hm.baidu.com.") .. "</font>" .. "<font color='#00bd3e'>" .. translate("<br>The list of rules only apply to 'Default Config' profiles.") .. "</font>")
|
o = s:taboption("white_list", TextValue, "whitelist", "", "<font color='red'>" .. translate("These domain names allow DNS resolution with the highest priority. Please input the domain names of websites, every line can input only one website domain. For example: hm.baidu.com.") .. "</font>" .. "<font color='#00bd3e'>" .. translate("<br>The list of rules only apply to 'Default Config' profiles.") .. "</font>")
|
||||||
o.rows = 15
|
o.rows = 15
|
||||||
@ -55,6 +57,16 @@ o.validate = function(self, value)
|
|||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
o = s:taboption("local_ptr_list", TextValue, "local_ptr", "", "<font color='red'>" .. translate("These domains are blocked from PTR requests") .. "</font>" .. "<font color='#00bd3e'>" .. translate("<br>The list of rules only apply to 'Default Config' profiles.") .. "</font>")
|
||||||
|
o.rows = 15
|
||||||
|
o.wrap = "off"
|
||||||
|
o.cfgvalue = function(self, section) return nixio.fs.readfile(local_ptr_file) or "" end
|
||||||
|
o.write = function(self, section, value) nixio.fs.writefile(local_ptr_file, value:gsub("\r\n", "\n")) end
|
||||||
|
o.remove = function(self, section, value) nixio.fs.writefile(local_ptr_file, "") end
|
||||||
|
o.validate = function(self, value)
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
|
||||||
local apply = luci.http.formvalue("cbi.apply")
|
local apply = luci.http.formvalue("cbi.apply")
|
||||||
if apply then
|
if apply then
|
||||||
luci.sys.exec("/etc/init.d/mosdns reload")
|
luci.sys.exec("/etc/init.d/mosdns reload")
|
||||||
|
@ -98,10 +98,10 @@ msgid "Cache Survival Time"
|
|||||||
msgstr "缓存生存时间(秒)"
|
msgstr "缓存生存时间(秒)"
|
||||||
|
|
||||||
msgid "Minimum TTL"
|
msgid "Minimum TTL"
|
||||||
msgstr "覆盖最小 TTL 值(禁用:0)"
|
msgstr "覆盖最小 TTL 值(默认 0)"
|
||||||
|
|
||||||
msgid "Maximum TTL"
|
msgid "Maximum TTL"
|
||||||
msgstr "覆盖最大 TTL 值(禁用:0)"
|
msgstr "覆盖最大 TTL 值(默认 0)"
|
||||||
|
|
||||||
msgid "Logs"
|
msgid "Logs"
|
||||||
msgstr "日志"
|
msgstr "日志"
|
||||||
@ -138,3 +138,9 @@ msgstr "重定向"
|
|||||||
|
|
||||||
msgid "The domain name to redirect the request to. Requests domain A, but returns records for domain B. example: a.com b.com"
|
msgid "The domain name to redirect the request to. Requests domain A, but returns records for domain B. example: a.com b.com"
|
||||||
msgstr "重定向请求的域名。请求域名 A,但返回域名 B 的记录,如:baidu.com qq.com(每个规则一行)"
|
msgstr "重定向请求的域名。请求域名 A,但返回域名 B 的记录,如:baidu.com qq.com(每个规则一行)"
|
||||||
|
|
||||||
|
msgid "Block PTR"
|
||||||
|
msgstr "PTR 黑名单"
|
||||||
|
|
||||||
|
msgid "These domains are blocked from PTR requests"
|
||||||
|
msgstr "加入的域名将阻止 PTR 请求(每个域名一行,支持域名匹配规则)"
|
||||||
|
102
luci-app-mosdns/root/etc/mosdns/rule/local-ptr.txt
Normal file
102
luci-app-mosdns/root/etc/mosdns/rule/local-ptr.txt
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
# from unbound.conf
|
||||||
|
127.in-addr.arpa
|
||||||
|
1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa
|
||||||
|
onion
|
||||||
|
test
|
||||||
|
invalid
|
||||||
|
10.in-addr.arpa
|
||||||
|
16.172.in-addr.arpa
|
||||||
|
17.172.in-addr.arpa
|
||||||
|
18.172.in-addr.arpa
|
||||||
|
19.172.in-addr.arpa
|
||||||
|
20.172.in-addr.arpa
|
||||||
|
21.172.in-addr.arpa
|
||||||
|
22.172.in-addr.arpa
|
||||||
|
23.172.in-addr.arpa
|
||||||
|
24.172.in-addr.arpa
|
||||||
|
25.172.in-addr.arpa
|
||||||
|
26.172.in-addr.arpa
|
||||||
|
27.172.in-addr.arpa
|
||||||
|
28.172.in-addr.arpa
|
||||||
|
29.172.in-addr.arpa
|
||||||
|
30.172.in-addr.arpa
|
||||||
|
31.172.in-addr.arpa
|
||||||
|
168.192.in-addr.arpa
|
||||||
|
0.in-addr.arpa
|
||||||
|
254.169.in-addr.arpa
|
||||||
|
2.0.192.in-addr.arpa
|
||||||
|
100.51.198.in-addr.arpa
|
||||||
|
113.0.203.in-addr.arpa
|
||||||
|
255.255.255.255.in-addr.arpa
|
||||||
|
0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa
|
||||||
|
d.f.ip6.arpa
|
||||||
|
8.e.f.ip6.arpa
|
||||||
|
9.e.f.ip6.arpa
|
||||||
|
a.e.f.ip6.arpa
|
||||||
|
b.e.f.ip6.arpa
|
||||||
|
8.b.d.0.1.0.0.2.ip6.arpa
|
||||||
|
# 100.64.0.0/10 reserved address
|
||||||
|
64.100.in-addr.arpa
|
||||||
|
65.100.in-addr.arpa
|
||||||
|
66.100.in-addr.arpa
|
||||||
|
67.100.in-addr.arpa
|
||||||
|
68.100.in-addr.arpa
|
||||||
|
69.100.in-addr.arpa
|
||||||
|
70.100.in-addr.arpa
|
||||||
|
71.100.in-addr.arpa
|
||||||
|
72.100.in-addr.arpa
|
||||||
|
73.100.in-addr.arpa
|
||||||
|
74.100.in-addr.arpa
|
||||||
|
75.100.in-addr.arpa
|
||||||
|
76.100.in-addr.arpa
|
||||||
|
77.100.in-addr.arpa
|
||||||
|
78.100.in-addr.arpa
|
||||||
|
79.100.in-addr.arpa
|
||||||
|
80.100.in-addr.arpa
|
||||||
|
81.100.in-addr.arpa
|
||||||
|
82.100.in-addr.arpa
|
||||||
|
83.100.in-addr.arpa
|
||||||
|
84.100.in-addr.arpa
|
||||||
|
85.100.in-addr.arpa
|
||||||
|
86.100.in-addr.arpa
|
||||||
|
87.100.in-addr.arpa
|
||||||
|
88.100.in-addr.arpa
|
||||||
|
89.100.in-addr.arpa
|
||||||
|
90.100.in-addr.arpa
|
||||||
|
91.100.in-addr.arpa
|
||||||
|
92.100.in-addr.arpa
|
||||||
|
93.100.in-addr.arpa
|
||||||
|
94.100.in-addr.arpa
|
||||||
|
95.100.in-addr.arpa
|
||||||
|
96.100.in-addr.arpa
|
||||||
|
97.100.in-addr.arpa
|
||||||
|
98.100.in-addr.arpa
|
||||||
|
99.100.in-addr.arpa
|
||||||
|
100.100.in-addr.arpa
|
||||||
|
101.100.in-addr.arpa
|
||||||
|
102.100.in-addr.arpa
|
||||||
|
103.100.in-addr.arpa
|
||||||
|
104.100.in-addr.arpa
|
||||||
|
105.100.in-addr.arpa
|
||||||
|
106.100.in-addr.arpa
|
||||||
|
107.100.in-addr.arpa
|
||||||
|
108.100.in-addr.arpa
|
||||||
|
109.100.in-addr.arpa
|
||||||
|
110.100.in-addr.arpa
|
||||||
|
111.100.in-addr.arpa
|
||||||
|
112.100.in-addr.arpa
|
||||||
|
113.100.in-addr.arpa
|
||||||
|
114.100.in-addr.arpa
|
||||||
|
115.100.in-addr.arpa
|
||||||
|
116.100.in-addr.arpa
|
||||||
|
117.100.in-addr.arpa
|
||||||
|
118.100.in-addr.arpa
|
||||||
|
119.100.in-addr.arpa
|
||||||
|
120.100.in-addr.arpa
|
||||||
|
121.100.in-addr.arpa
|
||||||
|
122.100.in-addr.arpa
|
||||||
|
123.100.in-addr.arpa
|
||||||
|
124.100.in-addr.arpa
|
||||||
|
125.100.in-addr.arpa
|
||||||
|
126.100.in-addr.arpa
|
||||||
|
127.100.in-addr.arpa
|
@ -29,6 +29,10 @@ data_providers:
|
|||||||
file: "/etc/mosdns/rule/redirect.txt"
|
file: "/etc/mosdns/rule/redirect.txt"
|
||||||
auto_reload: true
|
auto_reload: true
|
||||||
|
|
||||||
|
- tag: local_ptr
|
||||||
|
file: "/etc/mosdns/rule/local_ptr.txt"
|
||||||
|
auto_reload: true
|
||||||
|
|
||||||
plugins:
|
plugins:
|
||||||
- tag: lazy_cache
|
- tag: lazy_cache
|
||||||
type: cache
|
type: cache
|
||||||
@ -104,6 +108,13 @@ plugins:
|
|||||||
domain:
|
domain:
|
||||||
- "adblock"
|
- "adblock"
|
||||||
|
|
||||||
|
- tag: match_local_ptr
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
qtype: [12]
|
||||||
|
domain:
|
||||||
|
- "provider:local_ptr"
|
||||||
|
|
||||||
- tag: "main_sequence"
|
- tag: "main_sequence"
|
||||||
type: "sequence"
|
type: "sequence"
|
||||||
args:
|
args:
|
||||||
@ -117,7 +128,7 @@ plugins:
|
|||||||
- modify_ttl
|
- modify_ttl
|
||||||
- _return
|
- _return
|
||||||
|
|
||||||
- if: "query_is_blocklist_domain || query_is_ad_domain"
|
- if: "query_is_blocklist_domain || query_is_ad_domain || match_local_ptr"
|
||||||
exec:
|
exec:
|
||||||
- _new_nxdomain_response
|
- _new_nxdomain_response
|
||||||
- _return
|
- _return
|
||||||
|
Loading…
Reference in New Issue
Block a user