apfree-wifidog: support wildcard domain
authorDengfeng Liu <liudf0716@gmail.com>
Wed, 10 Jul 2024 09:02:46 +0000 (17:02 +0800)
committerTianling Shen <cnsztl@gmail.com>
Wed, 10 Jul 2024 11:41:47 +0000 (19:41 +0800)
Signed-off-by: Dengfeng Liu <liudf0716@gmail.com>
net/apfree-wifidog/files/wifidogx.conf
net/apfree-wifidog/files/wifidogx.init

index 0733853219a446f292442824c674a3704d93c4c6..7026418648d7be216a74573a0ed562fb958a8216 100644 (file)
@@ -14,25 +14,38 @@ config wifidogx 'common'
        option enable_dns_forward 1
 
 config group 'wechat'
-        option g_type '1'
-        list domain_name 'open.weixin.qq.com'
-        list domain_name 'api.weixin.qq.com'
+        option g_type '3'
+               list wildcard_domain '.weixin.qq.com'
+        option g_desc '微信泛域名'
+
+config group 'wechat2'
+               option g_type '1'
                list domain_name 'weixin.qq.com'
-        option g_desc '微信'
+               option g_desc '微信域名'
 
 config group 'dingtalk'
-        option g_type '1'
-        list domain_name 'oapi.dingtalk.com'
-        list domain_name 'open-dev.dingtalk.com'
-        list domain_name 'dingtalk.com'
+        option g_type '3'
+        list wildcard_domain '.dingtalk.com'
         option g_desc '钉钉'
 
+config group 'dingtalk2'
+               option g_type '1'
+               list domain_name 'dingtalk.com'
+               option g_desc '钉钉域名'
+
 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'
                list domain_name 'alipay.com'
                list domain_name 'alipayobjects.com'
                list domain_name 'alipaydev.com'
-               option g_desc '支付宝'
+               option g_desc '支付宝域名'
 
 config group 'macdemo'
         option g_type '2'
index 31795e512561b5a66681b816df204ebc4f7f3420..db2e7a74cbd5138b9d75942ddeb221655b62ad27 100644 (file)
@@ -26,9 +26,11 @@ prepare_wifidog_conf() {
                'apple_cna:bool:0' \
                'channel_path:string' \
                'trusted_domains:list(host)' \
+               'trusted_wildcard_domains:list(string)' \
                'trusted_macs:list(string)' \
                'app_white_list:list(string)' \
                'mac_white_list:list(string)' \
+               'wildcard_white_list:list(string)' \
                'enable_dns_forward:bool:1' \
                'enable_websocket:bool:1' \
                'js_filter:bool:1' 
@@ -72,6 +74,16 @@ prepare_wifidog_conf() {
                done
        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
        echo "GatewayID $gateway_id" > ${CONFIGFILE}
        echo "GatewayInterface $gateway_interface" >> ${CONFIGFILE}
@@ -97,6 +109,11 @@ prepare_wifidog_conf() {
                trusted_macs=$(echo $trusted_macs | tr ' ' ',')
                echo "TrustedMACList $trusted_macs" >> ${CONFIGFILE}
        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() {