mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-12-06 07:49:12 +00:00
check if dig exists first
This commit is contained in:
+21
-4
@@ -10,6 +10,7 @@
|
||||
TAG="SS_SPEC" # iptables tag
|
||||
IPT="iptables -t nat" # alias of iptables
|
||||
FWI=$(uci get firewall.shadowsocks.path 2>/dev/null) # firewall include file
|
||||
REGEX="[^0-9.]" # used to check if hostnames have letters
|
||||
|
||||
usage() {
|
||||
cat <<-EOF
|
||||
@@ -21,9 +22,9 @@ usage() {
|
||||
|
||||
Valid options are:
|
||||
|
||||
-s <server_ip> Host name or IP address of shadowsocks remote server
|
||||
-s <server_ip> hostname (requires dig) or ip address of shadowsocks remote server
|
||||
-l <local_port> port number of shadowsocks local server
|
||||
-S <server_ip> Host name or IP address of shadowsocks remote UDP server
|
||||
-S <server_ip> hostname (requires dig) or ip address of shadowsocks remote UDP server
|
||||
-L <local_port> port number of shadowsocks local UDP server
|
||||
-i <ip_list_file> a file content is bypassed ip list
|
||||
-I <interface> lan interface of nat, default: eth0
|
||||
@@ -170,13 +171,29 @@ EOF
|
||||
while getopts ":s:l:S:L:i:I:e:a:b:w:ouUfh" arg; do
|
||||
case "$arg" in
|
||||
s)
|
||||
server=$(dig +short $OPTARG)
|
||||
command -v dig > /dev/null &&
|
||||
server=$(dig +short $OPTARG) ||
|
||||
if [[ $OPTARG =~ $REGEX ]]
|
||||
then
|
||||
loger 3 "Hostname detected for server but no dig present to resolve!"
|
||||
exit 1
|
||||
else
|
||||
server=$OPTARG
|
||||
fi
|
||||
;;
|
||||
l)
|
||||
local_port=$OPTARG
|
||||
;;
|
||||
S)
|
||||
SERVER=$(dig +short $OPTARG)
|
||||
command -v dig > /dev/null &&
|
||||
SERVER=$(dig +short $OPTARG) ||
|
||||
if [[ $OPTARG =~ $REGEX ]]
|
||||
then
|
||||
loger 3 "Hostname detected for UDP server but no dig present to resolve!"
|
||||
exit 1
|
||||
else
|
||||
SERVER=$OPTARG
|
||||
fi
|
||||
;;
|
||||
L)
|
||||
LOCAL_PORT=$OPTARG
|
||||
|
||||
Reference in New Issue
Block a user