Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

最新版op luci开关反置 #8

Closed
Mosney opened this issue Dec 2, 2019 · 40 comments
Closed

最新版op luci开关反置 #8

Mosney opened this issue Dec 2, 2019 · 40 comments
Labels
question Further information is requested

Comments

@Mosney
Copy link

Mosney commented Dec 2, 2019

提交之前

在你提交问题之前请回答以下问题
你可以删掉提交之前这个部分

  • [Y] 我用着最新版的 luci-app-adguardhome
  • [Y] 我检查了没有人提交同样的问题

问题详细信息

  • AdGuard Home luci的版本:
    • 1.7-8
  • AdGuard Home server的版本:
    • 0.99.3
  • 操作系统和版本:
    • OpenWrt 19.07.0-rc1 r10649-c4fdb377a2 / LuCI openwrt-19.07 branch git-19.332.23110-3e90684

勾选时,实际作用为禁用。不勾选时,实际作用为启用

image

@Mosney Mosney changed the title luci开关 疑似luci开关反置 Dec 2, 2019
@Mosney
Copy link
Author

Mosney commented Dec 2, 2019

手动编辑luci配置文件、修改工作目录后解决,似乎是因为之前有独立的ADG二进制在运行的缘故

@Mosney Mosney closed this as completed Dec 2, 2019
@Mosney
Copy link
Author

Mosney commented Dec 3, 2019

启动脚本第9行开始似乎是把binpath和configpath写死了?

config_get configpath $CONFIGURATION configpath "/etc/AdGuardHome.yaml"
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome/AdGuardHome"

实测会出现不按luci的配置放置/执行二进制的情况出现,另外同时也的确是存在开关反置现象,看了半天启动脚本和lua也没看出个所以然,只能描述一下观察到的现象。

@Mosney Mosney reopened this Dec 3, 2019
@Mosney
Copy link
Author

Mosney commented Dec 3, 2019

贴一下目前的配置,


config AdGuardHome 'AdGuardHome'
	option httpport '3000'
	option redirect 'none'
	option configpath '/etc/AdGuardHome.yaml'
	option verbose '0'
	option version 'v0.99.3'
	option gfwupstream ' '
	option workdir '/var/AdGuardHome/'
	option logfile 'syslog'
	option binpath '/usr/bin/AdGuardHome'
	option lastbinpath '/usr/bin/AdGuardHome'
	list old_redirect 'none'
	list old_port '53'
	list old_enabled '1'
	option enabled '1'


另外还有两个小问题:

  • 使用syslog时luci的日志显示功能也不正常。
(tail call): ?
	/usr/lib/lua/luci/controller/AdGuardHome.lua:45: in function </usr/lib/lua/luci/controller/AdGuardHome.lua:31>
stack traceback:
/usr/lib/lua/luci/controller/AdGuardHome.lua:45: attempt to index global 'f' (a nil value)
The called action terminated with an exception:
Failed to execute call dispatcher target for entry '/admin/services/AdGuardHome/getlog'. 
  • luci的 gfw列表上游服务器 项清除内容保存后/etc/config/中的配置文件正常删除此项,但luci文本框会重新填充 tcp://208.67.220.220#5353。一方面前后端不一致,另一方面如果此时再次点击保存应用就会再次把这一项写入/etc/config/中。

@Mosney
Copy link
Author

Mosney commented Dec 3, 2019

另外也不是很懂gfw列表上游服务器这个选项有什么用途,README里似乎也没有具体说明。

@rufengsuixing
Copy link
Owner

开关相反是op新版luci的bug,在uci get 或者config get 时会获取和其他op版本相反的值,只涉及到最新版本op,不会修复,等待op官方修复

@rufengsuixing
Copy link
Owner

rufengsuixing commented Dec 4, 2019

syslog,确实写入日志貌似是不能用的,这个是adh自己的bug,另外能用的话也没有必要在这里显示系统日志

@rufengsuixing
Copy link
Owner

gfw列表上游服务器在没有点击添加gfw加入列表之前是没有用的,如果用不到此功能,可以不用管这个值

@rufengsuixing
Copy link
Owner

关于luci在脚本中获取配置的方式可以参照luci的wiki,你看到的写死是没有值时的默认值

@rufengsuixing
Copy link
Owner

手动配置时,在配置提交前会调用二进制对配置文件进行检查,应该不会出现意外启动的情况

@Mosney
Copy link
Author

Mosney commented Dec 4, 2019

syslog,确实写入日志貌似是不能用的,这个是adh自己的bug,另外能用的话也没有必要在这里显示系统日志

之前用二进制+配置文件跑的时候是可以写入syslog的,可能是通过-l指定的log文件不支持syslog?

@rufengsuixing
Copy link
Owner

我测试了,syslog可用,并且我也更新了一下支持syslog日志在日志中显示,稍等我会发布release

@rufengsuixing
Copy link
Owner

注意syslog有时候会失败,这是AdG的锅
/usr/bin/AdGuardHome/AdGuardHome -c /etc/AdGuardHome.yaml -
p 3000 -w /usr/bin/AdGuardHome -l syslog
2019/12/04 02:59:53 [fatal] cannot initialize syslog: Unix syslog delivery error

@rufengsuixing
Copy link
Owner

你可以测试打印下
test=$(uci get AdGuardHome.@AdGuardHome[0].enabled)
echo $test
test=$(uci get AdGuardHome.@AdGuardHome[0].enabled 2>/dev/null)
echo $test

@rufengsuixing
Copy link
Owner

rufengsuixing commented Dec 4, 2019

更多内容 #7

@rufengsuixing rufengsuixing changed the title 疑似luci开关反置 最新版op luci开关反置 Dec 4, 2019
@rufengsuixing rufengsuixing reopened this Dec 4, 2019
@rufengsuixing
Copy link
Owner

test=$(uci get AdGuardHome.@AdGuardHome[0].enabled)
echo $test
test=$(uci get AdGuardHome.@AdGuardHome[0].enabled 2>/dev/null)
echo $test
能提供下测试结果么,确保测试过程中没有修改enabled

@rufengsuixing rufengsuixing added the question Further information is requested label Dec 4, 2019
@liyiecho
Copy link

liyiecho commented Dec 4, 2019

1对应停止运行,0对应运行中
QQ20191204-190428@2x

QQ20191204-190333@2x

@liyiecho
Copy link

liyiecho commented Dec 4, 2019

发现是killall -q /usr/bin/AdGuardHome/AdGuardHome这条命令的问题,执行这条命令无法结束程序运行

@rufengsuixing
Copy link
Owner

如果path路径正确的话,这条命令应该没问题啊,可以去掉-q再试看看有没有报错

@liyiecho
Copy link

liyiecho commented Dec 4, 2019

killall: /usr/bin/AdGuardHome/AdGuardHome: no process killed
image
image

@rufengsuixing
Copy link
Owner

这个确实是一个bug,我尝试修复一下

@rufengsuixing
Copy link
Owner

你可以尝试release

@liyiecho
Copy link

liyiecho commented Dec 4, 2019

现在需要点两次保存并应用才能得到正确的,AdGuardHome.AdGuardHome.old_enabled的值对应相应的状态
image

@rufengsuixing
Copy link
Owner

AdGuardHome.AdGuardHome.old_enabled 对应的只是对于重定向的设置,只影响到redirect,不会影响程序启动

@liyiecho
Copy link

liyiecho commented Dec 4, 2019

你看点两次保存并应用的结果里面enabled值不变,而old_enabled的值却改变了,按理来说,第二次点保存并应用不会改变old_enabled的值

@rufengsuixing
Copy link
Owner

old 表示的是开关上一次的状态,连续两次应用,开关值不变,必然记录enable值

@liyiecho
Copy link

liyiecho commented Dec 4, 2019

enable值为0且old_enabled为1时,AdGuardHome还存活
image
enable值为0且old_enabled为0时,AdGuardHome停止运行
image

@rufengsuixing
Copy link
Owner

总觉得是其他问题导致了表面上看到的开关相反的问题

@Mosney
Copy link
Author

Mosney commented Dec 5, 2019

test=$(uci get AdGuardHome.@AdGuardHome[0].enabled)
echo $test
test=$(uci get AdGuardHome.@AdGuardHome[0].enabled 2>/dev/null)
echo $test
能提供下测试结果么,确保测试过程中没有修改enabled

1.7-8版本下正常使用状态下测得的结果

root@OP19:~# test=$(uci get AdGuardHome.@AdGuardHome[0].enabled)
root@OP19:~# echo $test
1
root@OP19:~# test=$(uci get AdGuardHome.@AdGuardHome[0].enabled 2>/dev/null)
root@OP19:~# echo $test
1
root@OP19:~# 

附上此时的配置

root@OP19:~# uci show AdGuardHome
AdGuardHome.AdGuardHome=AdGuardHome
AdGuardHome.AdGuardHome.httpport='3000'
AdGuardHome.AdGuardHome.redirect='none'
AdGuardHome.AdGuardHome.configpath='/etc/AdGuardHome.yaml'
AdGuardHome.AdGuardHome.verbose='0'
AdGuardHome.AdGuardHome.version='v0.99.3'
AdGuardHome.AdGuardHome.workdir='/var/AdGuardHome/'
AdGuardHome.AdGuardHome.logfile='syslog'
AdGuardHome.AdGuardHome.binpath='/usr/bin/AdGuardHome'
AdGuardHome.AdGuardHome.lastbinpath='/usr/bin/AdGuardHome'
AdGuardHome.AdGuardHome.enabled='1'
AdGuardHome.AdGuardHome.old_redirect='none'
AdGuardHome.AdGuardHome.old_port='53'
AdGuardHome.AdGuardHome.old_enabled='1'

@Mosney
Copy link
Author

Mosney commented Dec 5, 2019

以下是1.7-16版本由开启状态取消勾选启用并保存应用后的测试结果 ,问题依旧

root@OP19:~# test=$(uci get AdGuardHome.@AdGuardHome[0].enabled)
root@OP19:~# echo $test
0
root@OP19:~# test=$(uci get AdGuardHome.@AdGuardHome[0].enabled 2>/dev/null)
root@OP19:~# echo $test
0
root@OP19:~# uci show AdGuardHome
AdGuardHome.AdGuardHome=AdGuardHome
AdGuardHome.AdGuardHome.httpport='3000'
AdGuardHome.AdGuardHome.redirect='none'
AdGuardHome.AdGuardHome.configpath='/etc/AdGuardHome.yaml'
AdGuardHome.AdGuardHome.verbose='0'
AdGuardHome.AdGuardHome.version='v0.99.3'
AdGuardHome.AdGuardHome.workdir='/var/AdGuardHome/'
AdGuardHome.AdGuardHome.logfile='syslog'
AdGuardHome.AdGuardHome.binpath='/usr/bin/AdGuardHome'
AdGuardHome.AdGuardHome.lastbinpath='/usr/bin/AdGuardHome'
AdGuardHome.AdGuardHome.old_redirect='none'
AdGuardHome.AdGuardHome.old_port='53'
AdGuardHome.AdGuardHome.old_enabled='1'
AdGuardHome.AdGuardHome.enabled='0'
AdGuardHome.AdGuardHome.gfwupstream='tcp://208.67.220.220#5353'

image

@Mosney
Copy link
Author

Mosney commented Dec 5, 2019

以下是1.7-16版本由上步实际运行状态勾选启用并保存应用后的测试结果 ,


root@OP19:~# test=$(uci get AdGuardHome.@AdGuardHome[0].enabled)
root@OP19:~# echo $test
1
root@OP19:~# test=$(uci get AdGuardHome.@AdGuardHome[0].enabled 2>/dev/null)
root@OP19:~# echo $test
1
root@OP19:~# uci show AdGuardHome
AdGuardHome.AdGuardHome=AdGuardHome
AdGuardHome.AdGuardHome.httpport='3000'
AdGuardHome.AdGuardHome.redirect='none'
AdGuardHome.AdGuardHome.configpath='/etc/AdGuardHome.yaml'
AdGuardHome.AdGuardHome.verbose='0'
AdGuardHome.AdGuardHome.version='v0.99.3'
AdGuardHome.AdGuardHome.workdir='/var/AdGuardHome/'
AdGuardHome.AdGuardHome.logfile='syslog'
AdGuardHome.AdGuardHome.binpath='/usr/bin/AdGuardHome'
AdGuardHome.AdGuardHome.lastbinpath='/usr/bin/AdGuardHome'
AdGuardHome.AdGuardHome.gfwupstream='tcp://208.67.220.220#5353'
AdGuardHome.AdGuardHome.old_redirect='none'
AdGuardHome.AdGuardHome.old_port='53'
AdGuardHome.AdGuardHome.old_enabled='0'
AdGuardHome.AdGuardHome.enabled='1'

image

@Mosney
Copy link
Author

Mosney commented Dec 5, 2019

刚刚在上步状态下未作任何更改,仅重新点击了一下“保存并应用”按钮,提示“没有待应用的更改”,返回后发现状态变为运行,至此实际运行状态与开关匹配,配置文件数据如下所示。

root@OP19:~# uci show AdGuardHome
AdGuardHome.AdGuardHome=AdGuardHome
AdGuardHome.AdGuardHome.httpport='3000'
AdGuardHome.AdGuardHome.redirect='none'
AdGuardHome.AdGuardHome.configpath='/etc/AdGuardHome.yaml'
AdGuardHome.AdGuardHome.verbose='0'
AdGuardHome.AdGuardHome.version='v0.99.3'
AdGuardHome.AdGuardHome.workdir='/var/AdGuardHome/'
AdGuardHome.AdGuardHome.logfile='syslog'
AdGuardHome.AdGuardHome.binpath='/usr/bin/AdGuardHome'
AdGuardHome.AdGuardHome.lastbinpath='/usr/bin/AdGuardHome'
AdGuardHome.AdGuardHome.gfwupstream='tcp://208.67.220.220#5353'
AdGuardHome.AdGuardHome.enabled='1'
AdGuardHome.AdGuardHome.old_redirect='none'
AdGuardHome.AdGuardHome.old_port='53'
AdGuardHome.AdGuardHome.old_enabled='1'


root@OP19:~# test=$(uci get AdGuardHome.@AdGuardHome[0].enabled)
root@OP19:~# echo $test
1
root@OP19:~# test=$(uci get AdGuardHome.@AdGuardHome[0].enabled 2>/dev/null)
root@OP19:~# echo $test
1

@Mosney
Copy link
Author

Mosney commented Dec 5, 2019

根据以上三条,看起来是实际运行状态与old_enabled匹配。
状态与开关匹配之后与之前的配置文件就只有这一项存在差异,且可以明显看出在这个过程中发生变更的配置只有三条old_
另外没看懂保留上次的部分配置有何意义。

@Mosney
Copy link
Author

Mosney commented Dec 5, 2019

#8 (comment)
经过重复测试,以上步骤可以稳定复现,基本可以确定是跟这三个上次状态的配置项有关系,实际问题应该是启动脚本逻辑判断上顺序的问题。
目前lean的luci相关代码均落后于目前官方分支的两个19.07的rc版本,应该是由于新版的luci导致这个问题暴露出来。

@rufengsuixing
Copy link
Owner

结果如果和你说的一致,我的结论是,配置未完全写入时触发了reload,我会在reload前添加一个一秒的延时

@liyiecho
Copy link

liyiecho commented Dec 6, 2019

1.7-17版本,无论点几次“保存并应用”按钮,显示停止的还是停止不会启动,运行的还是运行不会停止
QQ20191204-190428@2x
也不会改变old_enabled的值,old_enabled为1时,AdGuardHome还存活,只能手动/etc/init.d/AdGuardHome stop来停止
54AF1061-DEDD-47B8-948D-A01B3968B7B6
55C56CE6-9011-4BF5-B822-EE31A343C495
手动执行命令来看enable值没变,改变的是old_enabled,且old_enabled的值刚好对应状态
QQ20191206-123310@2x

@rufengsuixing
Copy link
Owner

启动命令加载失误了,已修复

@liyiecho
Copy link

liyiecho commented Dec 6, 2019

1.7-18版可以正常控制了,但还是有个小问题,当从停用状态到启用状态时AdGuardHome.AdGuardHome.enabled='1'AdGuardHome.AdGuardHome.old_enabled应该为0,可现在却是1
QQ20191206-144447@2x
干脆直接把old_enabled相关的去掉吧

@rufengsuixing
Copy link
Owner

old_enabled 是为了控制重定向功能的,会检测两次开关状态来决定是否改动防火墙或者dnsmasq规则,因为现在我没有实现快速reload,可能用处少一点

@rufengsuixing
Copy link
Owner

已经实现了快速reload

@Mosney
Copy link
Author

Mosney commented Dec 6, 2019

1.7-21测试正常

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants