Merge pull request #9 from Akiyamov/main

Custom domains from local file and dnsmasq.d confdir
This commit is contained in:
itdoginfo
2024-12-11 23:55:21 +03:00
committed by GitHub
3 changed files with 32 additions and 1 deletions

View File

@@ -25,7 +25,16 @@ main() {
[ -f /etc/config/dhcp-opkg ] && cp /etc/config/dhcp /etc/config/dhcp-old && mv /etc/config/dhcp-opkg /etc/config/dhcp
fi
openwrt_release=$(cat /etc/openwrt_release | grep -Eo [0-9]{2}[.][0-9]{2}[.][0-9]* | cut -d '.' -f 1 | tail -n 1)
if [ $openwrt_release -ge 24 ]; then
if uci get dhcp.@dnsmasq[0].confdir | grep -q /tmp/dnsmasq.d; then
echo "confdir alreadt set"
else
printf "Setting confdir"
uci set dhcp.@dnsmasq[0].confdir='/tmp/dnsmasq.d'
uci commit dhcp
fi
fi
if [ -f "/etc/init.d/podkop" ]; then
printf "\033[32;1mPodkop is already installed. Just upgrade it? (y/n)\033[0m\n"
printf "\033[32;1my - Only upgrade podkop\033[0m\n"

View File

@@ -8,6 +8,8 @@ config main 'main'
#list subnets 'twitter'
option custom_domains_list_enabled '0'
#list custom_domains ''
option custom_local_domains_list_enabled '0'
#list custom_local_domains ''
option custom_download_domains_list_enabled '0'
#list custom_download_domains ''
option custom_subnets_list_enabled '0'

View File

@@ -299,6 +299,13 @@ list_update() {
config_list_foreach main custom_download_domains "list_custom_download_domains_create" "podkop"
fi
config_get_bool custom_local_domains_list_enabled "main" "custom_local_domains_list_enabled" "0"
if [ "$custom_local_domains_list_enabled" -eq 1 ]; then
log "Adding a custom local domain list"
add_set "podkop_domains" "main"
config_list_foreach main custom_local_domains "list_custom_local_domains_create" "podkop"
fi
config_get_bool delist_domains_enabled "main" "delist_domains_enabled" "0"
if [ "$delist_domains_enabled" -eq 1 ] && [ "$domain_list_enabled" -eq 1 ]; then
log "Exclude domains from the common list"
@@ -637,6 +644,19 @@ list_custom_domains_create() {
log "$domain added to the list"
}
list_custom_local_domains_create() {
local local_file="$1"
local name="$2"
local filename=$(basename "$local_file" | cut -d. -f1)
local config="/tmp/dnsmasq.d/${name}-${filename}.lst"
rm -f $config
while IFS= read -r domain; do
echo "nftset=/$domain/4#inet#PodkopTable#${name}_domains" >>$config
done <"$local_file"
dnsmasq_config_check ${name}-${filename}.lst
}
list_custom_download_domains_create() {
local URL="$1"
local name="$2"