From 3c2dc5b88ac2122d351d8d2d44e01ba2ee6776a4 Mon Sep 17 00:00:00 2001 From: Sieuno <62740936+Sieuno@users.noreply.github.com> Date: Sat, 20 Nov 2021 16:49:41 +0800 Subject: [PATCH 1/3] Update gfwlist2dnsmasq.sh Add use custom local file. --- gfwlist2dnsmasq.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gfwlist2dnsmasq.sh b/gfwlist2dnsmasq.sh index 08018ae..d1eabe1 100755 --- a/gfwlist2dnsmasq.sh +++ b/gfwlist2dnsmasq.sh @@ -44,6 +44,8 @@ Valid options are: (If not given, ipset rules will not be generated.) -o, --output /path/to/output_filename + -u, --uselocalfile + /path/from/gfwlist_filename -i, --insecure Force bypass certificate validation (insecure) -l, --domain-list @@ -101,6 +103,7 @@ check_depends(){ get_args(){ OUT_TYPE='DNSMASQ_RULES' + USE_LOCALFILE=0 DNS_IP='127.0.0.1' DNS_PORT='5353' IPSET_NAME='' @@ -141,6 +144,11 @@ get_args(){ OUT_FILE="$2" shift ;; + --uselocalfile | -u) + USE_LOCALFILE=1 + SOURCE_FILE="$2" + shift + ;; --extra-domain-file) EXTRA_DOMAIN_FILE="$2" shift @@ -223,10 +231,18 @@ process(){ DOMAIN_FILE="$TMP_DIR/gfwlist2domain.txt" CONF_TMP_FILE="$TMP_DIR/gfwlist.conf.tmp" OUT_TMP_FILE="$TMP_DIR/gfwlist.out.tmp" + SOURCE_FILE="" # Fetch GfwList and decode it into plain text printf 'Fetching GfwList... ' - if [ $USE_WGET = 0 ]; then + + if [ $USE_LOCALFILE = 1 ]; then + cp $SOURCE_FILE $BASE64_FILE + if [ $? != 0 ]; then + _red '\nFailed to copy local file. Please check your file is accessible.\n' + clean_and_exit 2 + fi + elif [ $USE_WGET = 0 ]; then curl -s -L $CURL_EXTARG -o$BASE64_FILE $BASE_URL else wget -q $WGET_EXTARG -O$BASE64_FILE $BASE_URL From e6163e85f80c54d0ac83c1ded3a82b6eea87f437 Mon Sep 17 00:00:00 2001 From: Sieuno <62740936+Sieuno@users.noreply.github.com> Date: Sat, 20 Nov 2021 16:54:20 +0800 Subject: [PATCH 2/3] Update gfwlist2dnsmasq.sh move a new variable to get_args() --- gfwlist2dnsmasq.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfwlist2dnsmasq.sh b/gfwlist2dnsmasq.sh index d1eabe1..bc04fa1 100755 --- a/gfwlist2dnsmasq.sh +++ b/gfwlist2dnsmasq.sh @@ -104,6 +104,7 @@ check_depends(){ get_args(){ OUT_TYPE='DNSMASQ_RULES' USE_LOCALFILE=0 + SOURCE_FILE="" DNS_IP='127.0.0.1' DNS_PORT='5353' IPSET_NAME='' @@ -231,7 +232,6 @@ process(){ DOMAIN_FILE="$TMP_DIR/gfwlist2domain.txt" CONF_TMP_FILE="$TMP_DIR/gfwlist.conf.tmp" OUT_TMP_FILE="$TMP_DIR/gfwlist.out.tmp" - SOURCE_FILE="" # Fetch GfwList and decode it into plain text printf 'Fetching GfwList... ' From 362a5a3a646c4de102d17f2903873619aa332c9b Mon Sep 17 00:00:00 2001 From: Sieuno <62740936+Sieuno@users.noreply.github.com> Date: Mon, 22 Nov 2021 13:39:48 +0800 Subject: [PATCH 3/3] Update README.md Add -u specification --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 93c98bf..0ae1f1a 100755 --- a/README.md +++ b/README.md @@ -18,6 +18,9 @@ Valid options are: (If not given, ipset rules will not be generated.) -o, --output /path/to/output_filename + -u, --userlocalfile + /path/from/gfwlist_filename + (If not given, shell will will get source online.) -i, --insecure Force bypass certificate validation (insecure) -l, --domain-list