From 30f438957c73c14c8a77311700be8dae2ef5ceca Mon Sep 17 00:00:00 2001 From: ElonJunior Date: Sat, 15 Mar 2025 22:58:07 +0800 Subject: [PATCH] hiddify-geo --- .github/workflows/run.yml | 7 +++++++ resouces/cn_adblockfilters.sh | 32 +++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index 37cb51eb..cd4d7e56 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -58,6 +58,13 @@ jobs: path: Iran-sing-box-rules ref: rule-set + - name: Checkout hiddify-geo + uses: actions/checkout@v4 + with: + repository: hiddify/hiddify-geo + path: hiddify-geo + ref: rule-set + - name: IR copy geo rules env: NO_SKIP: true diff --git a/resouces/cn_adblockfilters.sh b/resouces/cn_adblockfilters.sh index ca4536e5..8721b4f6 100644 --- a/resouces/cn_adblockfilters.sh +++ b/resouces/cn_adblockfilters.sh @@ -20,6 +20,9 @@ work_dir=$(realpath "$target_dir") target_dir="${work_dir}/chinese" sing_exe="${work_dir}/sing-box" +LOG_FILE="merge.log" +# cat /dev/null > $LOG_FILE + # ——————————————————————————————————————————————————————————————————————————————————————————————— @@ -69,6 +72,32 @@ function download_adblockfilters() { } +function merge_hiddify_geo(){ + src_dir=$(dirname $work_dir)/hiddify-geo/country + LOG_FILE="${work_dir}/geo/${LOG_FILE}" + echo "merge dir >> ${src_dir}" + + # 遍历country目录下所有以geoip或geosite开头的.srs文件 + for file1 in $(ls $src_dir/geo*-*.srs); do + filename1=${file1##*/} + # 修正2:移除多余的$$符号 + caty=${filename1%%-*} # 截取第一个"-"前的部分 + country=${filename1#*-} # 截取第一个"-"后的部分 + # echo "类型: $caty, 国家代码: $country" + + # Check if file exists in folder b with the same name + file2="$work_dir/geo/$caty/$country" + + # If file not found, print filename + if [ ! -f $file2 ]; then + cp $file1 $file2 + echo "hiddify-geo/country/${filename1}" >> $LOG_FILE + fi + + done +} + + # ——————————————————————————————————————————————————————————————————————————————————————————————— chmod +x $sing_exe @@ -76,7 +105,8 @@ chmod +x $sing_exe mkdir $target_dir ; cd $target_dir echo "start<= ${target_dir}" -download_adblockfilters +# download_adblockfilters +merge_hiddify_geo echo "end<= ${target_dir}" #END FILE