wifidog 支持域名白名单

修改源码:
fw_iptables.c,iptables_compile 函数修改:

if (rule->mask != NULL) {
    char *mask=rule->mask;
    int mask_len=strlen(mask);
    int is_domain=0,
        i=0;
    for(;i<mask_len;i++){
        if((mask[i]>=46&&mask[i]<=57)||mask[i]==32){
            continue;
        }else{
            is_domain=1;
            break;
        }
    }
    char * ip =NULL;
    if(is_domain){
        struct in_addr * h_addr =wd_gethostbyname(mask);
        if(h_addr){
            ip= safe_strdup(inet_ntoa(*h_addr));
            free(h_addr);
        }
        if(ip){
            mask=ip;
        }else{
            debug(LOG_ERR, "doamin %s not find ip try again!",mask);
            mask="0.0.0.0";
        }
    }
    snprintf((command + strlen(command)), (sizeof(command) - 
                strlen(command)), "-d %s ", mask);
    if(ip){
        free(ip);
    }
}

conf.c, _parse_firewall_rule 修改:

for (i = 0; *(mask + i) != '\0'; i++)
        if (!isdigit((unsigned char)*(mask + i))
                &&!isalpha((unsigned char)*(mask + i))
                && (*(mask + i) != '-')
                && (*(mask + i) != '.')
                && (*(mask + i) != '/'))
            all_nums = 0; /*< No longer only digits */

本文章由 http://www.wifidog.pro/2014/12/17/wifidog-%E5%9F%9F%E5%90%8D%E7%99%BD%E5%90%8D%E5%8D%95.html 整理编辑,转载请注明出处

标签: wifidog认证 wifidog安装 wifidog原理 wifidog分析 wifidog配置 wifidog流程 wifidog服务器 wifidog-ddwrt wifidog openwrt