Skip to content

Commit

Permalink
feature: support lookup local network host name or ip via mDNS
Browse files Browse the repository at this point in the history
  • Loading branch information
pymumu committed Dec 22, 2023
1 parent 33ee73c commit c67031e
Show file tree
Hide file tree
Showing 13 changed files with 425 additions and 46 deletions.
6 changes: 5 additions & 1 deletion etc/smartdns/smartdns.conf
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ log-level info
# g|-group [group]: set server to group, use with nameserver /domain/group.
# e|-exclude-default-group: exclude this server from default group.
# p|-proxy [proxy-name]: use proxy to connect to server.
# -bootstrap-dns: set as bootstrap dns server.
# b|-bootstrap-dns: set as bootstrap dns server.
# -set-mark: set mark on packets.
# -subnet [ip/subnet]: set edns client subnet.
# -host-ip [ip]: set dns server host ip.
Expand Down Expand Up @@ -307,6 +307,10 @@ log-level info
# set ddns domain
# ddns-domain domain

# lookup local network hostname or ip address from mdns
# mdns-lookup [yes|no]
# mdns-lookup no

# set domain rules
# domain-rules /domain/ [-speed-check-mode [...]]
# rules:
Expand Down
6 changes: 6 additions & 0 deletions package/luci-compat/files/luci/i18n/smartdns.zh-cn.po
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ msgstr "日志数量"
msgid "Log File"
msgstr "日志文件路径"

msgid "mDNS Lookup"
msgstr "mDNS查询"

msgid "Marking Packets"
msgstr "数据包标记"

Expand Down Expand Up @@ -434,6 +437,9 @@ msgstr "解析本地主机名"
msgid "Resolve local hostnames by reading Dnsmasq lease file."
msgstr "读取Dnsmasq的租约文件解析本地主机名。"

msgid "Resolve local network hostname via mDNS protocol."
msgstr "使用mDNS协议解析本地网络主机名。"

msgid "Response Mode"
msgstr "响应模式"

Expand Down
10 changes: 9 additions & 1 deletion package/luci-compat/files/luci/model/cbi/smartdns/smartdns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,22 @@ o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end

-- cache-size
-- resolve local hostname
o = s:taboption("advanced", Flag, "resolve_local_hostnames", translate("Resolve Local Hostnames"), translate("Resolve local hostnames by reading Dnsmasq lease file."))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end

-- resolve local network hostname via mDNS
o = s:taboption("advanced", Flag, "mdns_lookup", translate("mDNS Lookup"), translate("Resolve local network hostname via mDNS protocol."))
o.rmempty = true
o.default = o.disabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "0"
end

-- Force AAAA SOA
o = s:taboption("advanced", Flag, "force_aaaa_soa", translate("Force AAAA SOA"), translate("Force AAAA SOA."))
o.rmempty = true
Expand Down
6 changes: 6 additions & 0 deletions package/luci/files/luci/i18n/smartdns.zh-cn.po
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,9 @@ msgstr "日志数量"
msgid "Log File"
msgstr "日志文件路径"

msgid "mDNS Lookup"
msgstr "mDNS查询"

msgid "Marking Packets"
msgstr "数据包标记"

Expand Down Expand Up @@ -483,6 +486,9 @@ msgstr "解析本地主机名"
msgid "Resolve local hostnames by reading Dnsmasq lease file."
msgstr "读取Dnsmasq的租约文件解析本地主机名。"

msgid "Resolve local network hostname via mDNS protocol."
msgstr "使用mDNS协议解析本地网络主机名。"

msgid "Response Mode"
msgstr "响应模式"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,16 @@ return view.extend({
o.rmempty = false;
o.default = o.enabled;

// cache-size;
// resolve local hostname;
o = s.taboption("advanced", form.Flag, "resolve_local_hostnames", _("Resolve Local Hostnames"), _("Resolve local hostnames by reading Dnsmasq lease file."));
o.rmempty = false;
o.default = o.enabled;

// resolve local network hostname via mDNS;
o = s.taboption("advanced", form.Flag, "mdns_lookup", _("mDNS Lookup"), _("Resolve local network hostname via mDNS protocol."));
o.rmempty = true;
o.default = o.disabled;

// Force AAAA SOA
o = s.taboption("advanced", form.Flag, "force_aaaa_soa", _("Force AAAA SOA"), _("Force AAAA SOA."));
o.rmempty = true;
Expand Down
3 changes: 3 additions & 0 deletions package/openwrt/files/etc/init.d/smartdns
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,9 @@ load_service()
config_get dns64 "$section" "dns64" ""
[ -z "$dns64" ] || conf_append "dns64" "$dns64"

config_get_bool mdns_lookup "$section" "mdns_lookup" "0"
[ "$mdns_lookup" = "1" ] && conf_append "mdns-lookup" "yes"

config_get redirect "$section" "redirect" ""
config_get old_port "$section" "old_port" "0"
config_get old_enabled "$section" "old_enabled" "0"
Expand Down
Loading

0 comments on commit c67031e

Please sign in to comment.