瀏覽代碼

add redirect status

rufengsuixing 5 年之前
父節點
當前提交
9600c815b3
共有 3 個文件被更改,包括 18 次插入2 次删除
  1. 6 0
      luasrc/controller/AdGuardHome.lua
  2. 7 2
      luasrc/view/AdGuardHome/AdGuardHome_status.htm
  3. 5 0
      root/etc/init.d/AdGuardHome

+ 6 - 0
luasrc/controller/AdGuardHome.lua

@@ -19,6 +19,12 @@ function act_status()
 	local e={}
 	binpath=uci:get("AdGuardHome","AdGuardHome","binpath")
 	e.running=luci.sys.call("pgrep "..binpath.." >/dev/null")==0
+	st=nixio.fs.readfile("/var/run/AdGredir")
+	if (st=="0") then
+		e.redirect=false
+	else
+		e.redirect=true
+	end
 	luci.http.prepare_content("application/json")
 	luci.http.write_json(e)
 end

+ 7 - 2
luasrc/view/AdGuardHome/AdGuardHome_status.htm

@@ -4,11 +4,16 @@ XHR.poll(3, '<%=url([[admin]], [[services]], [[AdGuardHome]], [[status]])%>', nu
 		var tb = document.getElementById('AdGuardHome_status');
 		if (data && tb) {
 			if (data.running) {
-				var links = '<em><b><font color=green>AdGuardHome <%:RUNNING%></font></b></em>';
-				tb.innerHTML = links;
+				tb.innerHTML = '<em><b><font color=green>AdGuardHome <%:RUNNING%></font></b></em>';
 			} else {
 				tb.innerHTML = '<em><b><font color=red>AdGuardHome <%:NOT RUNNING%></font></b></em>';
 			}
+			if (data.redirect)
+			{
+				tb.innerHTML+='<em><b><font color=green><%:Redirected%></font></b></em>'
+			} else {
+				tb.innerHTML+='<em><b><font color=red><%:Not redirect%></font></b></em>'	
+			}
 		}
 	}
 );

+ 5 - 0
root/etc/init.d/AdGuardHome

@@ -181,6 +181,11 @@ do_redirect()
 	ipv6_server=1
 	tcp_server=0
 	enabled=$1
+	if [ "$enabled" == "1" ]; then
+		echo -n "1">/var/run/AdGredir
+	else
+		echo -n "0">/var/run/AdGredir
+	fi
 	config_get configpath $CONFIGURATION configpath "/etc/AdGuardHome.yaml"
 	AdGuardHome_PORT=$(awk '/  port:/{printf($2)}' $configpath)
 	if [ -z "$AdGuardHome_PORT" ]; then