apfree-wifidog: support wildcard domain

Signed-off-by: Dengfeng Liu <liudf0716@gmail.com>
This commit is contained in:
Dengfeng Liu
2024-07-10 17:02:46 +08:00
committed by Tianling Shen
parent 2c96a5bb1d
commit ca8fe51fd8
2 changed files with 39 additions and 9 deletions

View File

@@ -14,25 +14,38 @@ config wifidogx 'common'
option enable_dns_forward 1 option enable_dns_forward 1
config group 'wechat' config group 'wechat'
option g_type '1' option g_type '3'
list domain_name 'open.weixin.qq.com' list wildcard_domain '.weixin.qq.com'
list domain_name 'api.weixin.qq.com' option g_desc '微信泛域名'
config group 'wechat2'
option g_type '1'
list domain_name 'weixin.qq.com' list domain_name 'weixin.qq.com'
option g_desc '微信' option g_desc '微信域名'
config group 'dingtalk' config group 'dingtalk'
option g_type '1' option g_type '3'
list domain_name 'oapi.dingtalk.com' list wildcard_domain '.dingtalk.com'
list domain_name 'open-dev.dingtalk.com'
list domain_name 'dingtalk.com'
option g_desc '钉钉' option g_desc '钉钉'
config group 'dingtalk2'
option g_type '1'
list domain_name 'dingtalk.com'
option g_desc '钉钉域名'
config group 'alipay' config group 'alipay'
option g_type '3'
list wildcard_domain '.alipay.com'
list wildcard_domain '.alipayobjects.com'
list wildcard_domain '.alipaydev.com'
option g_desc '支付宝'
config group 'alipay2'
option g_type '1' option g_type '1'
list domain_name 'alipay.com' list domain_name 'alipay.com'
list domain_name 'alipayobjects.com' list domain_name 'alipayobjects.com'
list domain_name 'alipaydev.com' list domain_name 'alipaydev.com'
option g_desc '支付宝' option g_desc '支付宝域名'
config group 'macdemo' config group 'macdemo'
option g_type '2' option g_type '2'

View File

@@ -26,9 +26,11 @@ prepare_wifidog_conf() {
'apple_cna:bool:0' \ 'apple_cna:bool:0' \
'channel_path:string' \ 'channel_path:string' \
'trusted_domains:list(host)' \ 'trusted_domains:list(host)' \
'trusted_wildcard_domains:list(string)' \
'trusted_macs:list(string)' \ 'trusted_macs:list(string)' \
'app_white_list:list(string)' \ 'app_white_list:list(string)' \
'mac_white_list:list(string)' \ 'mac_white_list:list(string)' \
'wildcard_white_list:list(string)' \
'enable_dns_forward:bool:1' \ 'enable_dns_forward:bool:1' \
'enable_websocket:bool:1' \ 'enable_websocket:bool:1' \
'js_filter:bool:1' 'js_filter:bool:1'
@@ -72,6 +74,16 @@ prepare_wifidog_conf() {
done done
fi fi
if [ ! -z "$wildcard_white_list" ]; then
# iterate wildcard_white_list and find the corresponding domain according to the item
for group in $wildcard_white_list; do
group_wildcard_list=$(uci get wifidogx.$group.wildcard_domain)
if [ ! -z "$group_wildcard_list" ]; then
trusted_wildcard_domains="$trusted_wildcard_domains $group_wildcard_list"
fi
done
fi
# set above variables to config file # set above variables to config file
echo "GatewayID $gateway_id" > ${CONFIGFILE} echo "GatewayID $gateway_id" > ${CONFIGFILE}
echo "GatewayInterface $gateway_interface" >> ${CONFIGFILE} echo "GatewayInterface $gateway_interface" >> ${CONFIGFILE}
@@ -97,6 +109,11 @@ prepare_wifidog_conf() {
trusted_macs=$(echo $trusted_macs | tr ' ' ',') trusted_macs=$(echo $trusted_macs | tr ' ' ',')
echo "TrustedMACList $trusted_macs" >> ${CONFIGFILE} echo "TrustedMACList $trusted_macs" >> ${CONFIGFILE}
fi fi
# if has trusted_wildcard_domains, add it to config file
if [ ! -z "$trusted_wildcard_domains" ]; then
trusted_wildcard_domains=$(echo $trusted_wildcard_domains | tr ' ' ',')
echo "TrustedPanDomains $trusted_wildcard_domains" >> ${CONFIGFILE}
fi
} }
start_service() { start_service() {