Browse Source

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.
pull/2304/head
Jerry 6 years ago
parent
commit
6734e12172
No known key found for this signature in database GPG Key ID: 9D9CE43650FF2BAA
1 changed files with 24 additions and 18 deletions
  1. 42
      src/ss-nat

42
src/ss-nat

@ -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

Loading…
Cancel
Save