mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-12-06 15:54:15 +00:00
ss-nat: fix hostname lookup bugs introduced in #2230
Fixes: An ipv4 address went through dig and returns nothing, causing the script to print help. ip address can be handled correctly now.
This commit is contained in:
+24
-18
@@ -171,29 +171,35 @@ EOF
|
||||
while getopts ":s:l:S:L:i:I:e:a:b:w:ouUfh" arg; do
|
||||
case "$arg" in
|
||||
s)
|
||||
command -v dig > /dev/null &&
|
||||
server=$(dig +short $OPTARG) ||
|
||||
if ! [[ $OPTARG =~ $IP_REGEX ]]
|
||||
then
|
||||
loger 3 "Hostname detected for server but no dig present to resolve!"
|
||||
exit 1
|
||||
else
|
||||
server=$OPTARG
|
||||
fi
|
||||
if [[ $OPTARG =~ $IP_REGEX ]]
|
||||
then
|
||||
server=$OPTARG
|
||||
else
|
||||
if command -v dig > /dev/null
|
||||
then
|
||||
server=$(dig +short $OPTARG)
|
||||
else
|
||||
loger 3 "Hostname detected for server but no dig present to resolve!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
l)
|
||||
local_port=$OPTARG
|
||||
;;
|
||||
S)
|
||||
command -v dig > /dev/null &&
|
||||
SERVER=$(dig +short $OPTARG) ||
|
||||
if ! [[ $OPTARG =~ $IP_REGEX ]]
|
||||
then
|
||||
loger 3 "Hostname detected for UDP server but no dig present to resolve!"
|
||||
exit 1
|
||||
else
|
||||
SERVER=$OPTARG
|
||||
fi
|
||||
if [[ $OPTARG =~ $IP_REGEX ]]
|
||||
then
|
||||
SERVER=$OPTARG
|
||||
else
|
||||
if command -v dig > /dev/null
|
||||
then
|
||||
SERVER=$(dig +short $OPTARG)
|
||||
else
|
||||
loger 3 "Hostname detected for UDP server but no dig present to resolve!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
L)
|
||||
LOCAL_PORT=$OPTARG
|
||||
|
||||
Reference in New Issue
Block a user