Skip to content

Commit

Permalink
luci-app-mosdns: Fix local DNS to enable http/3 domain name lookup
Browse files Browse the repository at this point in the history
* MosDNS does not support bootstrap working on http3, and DNS domain names must be resolved in another way and made work.
  • Loading branch information
sbwml committed Aug 29, 2023
1 parent c7680b0 commit e255e8f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion luci-app-mosdns/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-mosdns
PKG_VERSION:=1.5.6
PKG_VERSION:=1.5.7
PKG_RELEASE:=1

LUCI_TITLE:=LuCI Support for mosdns
Expand Down
9 changes: 9 additions & 0 deletions luci-app-mosdns/root/etc/init.d/mosdns
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ DUMP_FILE=/etc/mosdns/cache.dump
DUMP_FILE_DEFAULT=/usr/share/mosdns/cache.dump
DEFAULT_CONF=/usr/share/mosdns/default.yaml
MOSDNS_SCRIPT=/usr/share/mosdns/mosdns.sh
RULE_HOSTS=/etc/mosdns/rule/hosts.txt

get_config() {
config_get enabled $1 enabled 0
Expand Down Expand Up @@ -70,6 +71,14 @@ init_yaml() {
[ $insecure_skip_verify -eq 1 ] && insecure_skip_verify=true || insecure_skip_verify=false
[ $enable_http3_local -eq 1 ] && enable_http3_local=true || enable_http3_local=false
[ $enable_http3_remote -eq 1 ] && enable_http3_remote=true || enable_http3_remote=false
if [ $enable_http3_local = true ]; then
http3_dns=$(uci get mosdns.config.local_dns)
echo "$http3_dns" | grep -oE 'https?://[^/]+' | while read -r domain; do
address=$(nslookup "${domain#*://}" ${bootstrap_dns} | grep -A2 Name | grep Address | awk '{print $2}')
sed -i "/${domain#*://}/d" $RULE_HOSTS
[ -n "$address" ] && echo ${domain#*://} $address >> $RULE_HOSTS
done
fi
[ "$custom_local_dns" -eq 1 ] && \
local_dns=$($MOSDNS_SCRIPT dns | awk '{for(i=1;i<=NF;i++)printf "%s- addr: \"%s\"\n%s bootstrap: '${bootstrap_dns}'\n%s enable_pipeline: '${enable_pipeline}'\n%s max_conns: '${max_conns}'\n%s insecure_skip_verify: '${insecure_skip_verify}'\n%s idle_timeout: '${idle_timeout}'\n%s enable_http3: '${enable_http3_local}'\n",s,$i,s,s,s,s,s,s}' s=' ') || \
local_dns=$($MOSDNS_SCRIPT dns | awk '{for(i=1;i<=NF;i++)printf "%s- addr: \"%s\"\n",s,$i,s}' s=' ')
Expand Down

0 comments on commit e255e8f

Please sign in to comment.