From 55461a881095d2f8b10fcad6074713a2e1193295 Mon Sep 17 00:00:00 2001 From: Akiyamov Date: Sat, 30 Nov 2024 18:46:36 +0500 Subject: [PATCH 1/4] Added custom domains from local file, no luci version right now --- podkop/files/etc/config/podkop | 2 ++ podkop/files/etc/init.d/podkop | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/podkop/files/etc/config/podkop b/podkop/files/etc/config/podkop index e629944..83fe72e 100644 --- a/podkop/files/etc/config/podkop +++ b/podkop/files/etc/config/podkop @@ -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' diff --git a/podkop/files/etc/init.d/podkop b/podkop/files/etc/init.d/podkop index 42801cf..a959b38 100755 --- a/podkop/files/etc/init.d/podkop +++ b/podkop/files/etc/init.d/podkop @@ -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=$(echo "${local_file%.*}") + 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" From 3b2c6de384b1b4384c7b673e91f6bf087d5b25ee Mon Sep 17 00:00:00 2001 From: Akiyamov <116005851+Akiyamov@users.noreply.github.com> Date: Sat, 30 Nov 2024 20:22:46 +0500 Subject: [PATCH 2/4] Fix filename --- podkop/files/etc/init.d/podkop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/podkop/files/etc/init.d/podkop b/podkop/files/etc/init.d/podkop index a959b38..29590b8 100755 --- a/podkop/files/etc/init.d/podkop +++ b/podkop/files/etc/init.d/podkop @@ -647,7 +647,7 @@ list_custom_domains_create() { list_custom_local_domains_create() { local local_file="$1" local name="$2" - local filename=$(echo "${local_file%.*}") + local filename=$(basename "$local_file" | cut -d. -f1) local config="/tmp/dnsmasq.d/${name}-${filename}.lst" rm -f $config From 1d4f25dd45462d8fb7a43c7625a036dad65c016e Mon Sep 17 00:00:00 2001 From: Akiyamov <116005851+Akiyamov@users.noreply.github.com> Date: Thu, 5 Dec 2024 15:17:40 +0500 Subject: [PATCH 3/4] Confdir for 24.10 --- install.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 218288e..b0cf819 100755 --- a/install.sh +++ b/install.sh @@ -25,7 +25,13 @@ main() { [ -f /etc/config/dhcp-opkg ] && cp /etc/config/dhcp /etc/config/dhcp-old && mv /etc/config/dhcp-opkg /etc/config/dhcp fi - + 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 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" From d832be781a1099f3cbeda12bf518a130cc7763aa Mon Sep 17 00:00:00 2001 From: Akiyamov <116005851+Akiyamov@users.noreply.github.com> Date: Thu, 5 Dec 2024 15:55:05 +0500 Subject: [PATCH 4/4] Execute confdir only for 24 and newer versions --- install.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index b0cf819..bba883f 100755 --- a/install.sh +++ b/install.sh @@ -25,12 +25,15 @@ main() { [ -f /etc/config/dhcp-opkg ] && cp /etc/config/dhcp /etc/config/dhcp-old && mv /etc/config/dhcp-opkg /etc/config/dhcp fi - 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 + 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"