
UCI_SECTION="${NAME}.config"
UCI_VARS="dnsmasq_confdir proxy_mode proxy_local_clients nftset_clear_sets allowed_hosts_mode allowed_hosts_list bypass_mode bypass_entries_dns enable_fproxy fproxy_list enable_bllist_proxy if_vpn vpn_gw_ip vpn_route_check tor_trans_port onion_dns_addr t_proxy_type t_proxy_port_tcp t_proxy_port_udp t_proxy_allow_udp enable_logging bllist_min_entries bllist_module bllist_preset bllist_ip_limit bllist_summarize_ip bllist_summarize_cidr bllist_ip_filter bllist_ip_filter_type bllist_sd_limit bllist_fqdn_filter bllist_fqdn_filter_type bllist_enable_idn bllist_alt_nslookup bllist_alt_dns_addr update_at_startup enable_tmp_downloads"
UCI_CMD="$(which uci)"
if [ $? -ne 0 ]; then
    echo " Error! UCI doesn't exists" >&2
    exit 1
fi
AWK_CMD="awk"

eval $($UCI_CMD show "$UCI_SECTION" | $AWK_CMD -v UCI_VARS="$UCI_VARS" '
        BEGIN {
            split(UCI_VARS, split_array, " ");
            for(i in split_array)
                vars_array[split_array[i]]="";
        }
        {
            match($0, /^[^=]+/);
            end  = RSTART + RLENGTH;
            name = substr($0, RSTART, end - 1);
            val  = substr($0, end + 1);
            sub(/^.*[.]/, "", name);
            gsub(/["\047]/, "", val);
            if(name in vars_array) {
                print toupper(name) "=\"" val "\"";
                delete vars_array[name];
            };
        }
        END {
            if(length(vars_array) > 0) {
                for(i in vars_array)
                    print toupper(i) "=\"""\"";
            };
        }')

. /lib/functions/network.sh
network_get_subnet subnet_lan "lan"
if [ -n "$subnet_lan" ]; then
    FPROXY_PRIVATE_NETS="${subnet_lan} ${FPROXY_PRIVATE_NETS}"
fi
