Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option for using custom source #43

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Valid options are:
(If not given, ipset rules will not be generated.)
-o, --output <FILE>
/path/to/output_filename
-u, --userlocalfile <FILE>
/path/from/gfwlist_filename
(If not given, shell will will get source online.)
-i, --insecure
Force bypass certificate validation (insecure)
-l, --domain-list
Expand Down
18 changes: 17 additions & 1 deletion gfwlist2dnsmasq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Valid options are:
(If not given, ipset rules will not be generated.)
-o, --output <FILE>
/path/to/output_filename
-u, --uselocalfile <FILE>
/path/from/gfwlist_filename
-i, --insecure
Force bypass certificate validation (insecure)
-l, --domain-list
Expand Down Expand Up @@ -101,6 +103,8 @@ check_depends(){

get_args(){
OUT_TYPE='DNSMASQ_RULES'
USE_LOCALFILE=0
SOURCE_FILE=""
DNS_IP='127.0.0.1'
DNS_PORT='5353'
IPSET_NAME=''
Expand Down Expand Up @@ -141,6 +145,11 @@ get_args(){
OUT_FILE="$2"
shift
;;
--uselocalfile | -u)
USE_LOCALFILE=1
SOURCE_FILE="$2"
shift
;;
--extra-domain-file)
EXTRA_DOMAIN_FILE="$2"
shift
Expand Down Expand Up @@ -226,7 +235,14 @@ process(){

# 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
Expand Down