diff --git a/luci-app-mosdns/Makefile b/luci-app-mosdns/Makefile
index 10856fb..5b4bf9e 100644
--- a/luci-app-mosdns/Makefile
+++ b/luci-app-mosdns/Makefile
@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-mosdns
-PKG_VERSION:=1.4.1
+PKG_VERSION:=1.4.2
PKG_RELEASE:=1
LUCI_TITLE:=LuCI Support for mosdns
diff --git a/luci-app-mosdns/luasrc/controller/mosdns.lua b/luci-app-mosdns/luasrc/controller/mosdns.lua
index 2cfa899..0c49003 100644
--- a/luci-app-mosdns/luasrc/controller/mosdns.lua
+++ b/luci-app-mosdns/luasrc/controller/mosdns.lua
@@ -16,6 +16,7 @@ function index()
entry({"admin", "services", "mosdns", "status"}, call("act_status")).leaf = true
entry({"admin", "services", "mosdns", "get_log"}, call("get_log")).leaf = true
entry({"admin", "services", "mosdns", "clear_log"}, call("clear_log")).leaf = true
+ entry({"admin", "services", "mosdns", "geo_update"}, call("geo_update"))
end
function act_status()
@@ -32,3 +33,10 @@ end
function clear_log()
luci.sys.call("cat /dev/null > $(/usr/share/mosdns/mosdns.sh logfile)")
end
+
+function geo_update()
+ local e = {}
+ e.updating = luci.sys.call("/usr/share/mosdns/mosdns.sh geodata") == 0
+ luci.http.prepare_content("application/json")
+ luci.http.write_json(e)
+end
diff --git a/luci-app-mosdns/luasrc/model/cbi/mosdns/update.lua b/luci-app-mosdns/luasrc/model/cbi/mosdns/update.lua
index 323d1f2..f1d45bd 100644
--- a/luci-app-mosdns/luasrc/model/cbi/mosdns/update.lua
+++ b/luci-app-mosdns/luasrc/model/cbi/mosdns/update.lua
@@ -24,11 +24,8 @@ for t = 0, 23 do
end
update_time.default = 0
-data_update = s:option(Button, "geo_update_database", translate("Database Update"))
-data_update.inputtitle = translate("Check And Update")
-data_update.inputstyle = "reload"
-data_update.write = function()
- luci.sys.exec("/usr/share/mosdns/mosdns.sh geodata &> /dev/null &")
-end
+data_update = s:option(Button, "geo_update_database", translate("Check And Update"))
+data_update.rawhtml = true
+data_update.template = "mosdns/geo_update"
return m
diff --git a/luci-app-mosdns/luasrc/view/mosdns/geo_update.htm b/luci-app-mosdns/luasrc/view/mosdns/geo_update.htm
new file mode 100644
index 0000000..68b3027
--- /dev/null
+++ b/luci-app-mosdns/luasrc/view/mosdns/geo_update.htm
@@ -0,0 +1,34 @@
+<%+cbi/valueheader%>
+
+
+<%=self.value%>
+<%+cbi/valuefooter%>
diff --git a/luci-app-mosdns/po/zh-cn/mosdns.po b/luci-app-mosdns/po/zh-cn/mosdns.po
index 9215b6a..4a1bea0 100644
--- a/luci-app-mosdns/po/zh-cn/mosdns.po
+++ b/luci-app-mosdns/po/zh-cn/mosdns.po
@@ -85,6 +85,15 @@ msgstr "检查并更新"
msgid "Enable Auto Database Update"
msgstr "启用自动更新"
+msgid "Updating..."
+msgstr "正在更新..."
+
+msgid "Update success"
+msgstr "更新成功"
+
+msgid "Update failed, Please check the network status"
+msgstr "更新失败,请检查网络状态"
+
msgid "Config File"
msgstr "配置文件"
diff --git a/luci-app-mosdns/root/usr/share/mosdns/mosdns.sh b/luci-app-mosdns/root/usr/share/mosdns/mosdns.sh
index c999d47..3d5c0de 100755
--- a/luci-app-mosdns/root/usr/share/mosdns/mosdns.sh
+++ b/luci-app-mosdns/root/usr/share/mosdns/mosdns.sh
@@ -36,16 +36,18 @@ geodat_update() (
geodat_download() (
google_status=$(curl -I -4 -m 3 -o /dev/null -s -w %{http_code} http://www.google.com/generate_204)
[ $google_status -ne "204" ] && mirror="https://github.cooluc.com/"
- echo -e "\e[1;32m"$mirror"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/$1\e[0m"
- curl --connect-timeout 60 -m 900 -fSLo "$TMPDIR/$1" ""$mirror"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/$1"
+ echo -e "\e[1;32mDownloading "$mirror"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/$1\e[0m"
+ curl --connect-timeout 60 -m 900 --ipv4 -fSLo "$TMPDIR/$1" ""$mirror"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/$1"
)
TMPDIR=$(mktemp -d) || exit 1
geodat_download geoip.dat
geodat_download geosite.dat
if [ "$(grep -o CN "$TMPDIR"/geoip.dat | wc -l)" -eq "0" ]; then
rm -rf "$TMPDIR"/geoip.dat
+ exit 1
elif [ "$(grep -o .com "$TMPDIR"/geosite.dat | wc -l)" -lt "1000" ]; then
rm -rf "$TMPDIR"/geosite.dat
+ exit 1
fi
cp -f "$TMPDIR"/* /usr/share/v2ray
rm -rf "$TMPDIR"