mirror of
https://repo.or.cz/socat.git
synced 2025-05-20 04:22:40 +00:00
Catch problems caused by ISPs DNS
This commit is contained in:
parent
34b09a44ee
commit
245f5e657f
2 changed files with 54 additions and 25 deletions
4
CHANGES
4
CHANGES
|
@ -1,7 +1,7 @@
|
|||
|
||||
Security:
|
||||
readline.sh has new option -lf <logfile> for stderr. If this option is
|
||||
not given it logs to a file in . (cwd) only when it is not writable by
|
||||
not given it logs to a file in . (cwd) only when . is not writable by
|
||||
other users.
|
||||
|
||||
Corrections:
|
||||
|
@ -172,6 +172,8 @@ Testing:
|
|||
|
||||
UDPLITE4STREAM was trice, changed one of them to UDPLITE6STREAM.
|
||||
|
||||
Catch problems caused by ISPs that filter *.dest-unreach.net records.
|
||||
|
||||
Documentation:
|
||||
Removed obsolete CHANGES.ISO-8859-1 file.
|
||||
|
||||
|
|
75
test.sh
75
test.sh
|
@ -93,6 +93,9 @@ while [ "$1" ]; do
|
|||
done
|
||||
debug=$DEBUG
|
||||
|
||||
# Applying patch 1.8.0.3 to 1.8.0.2 generates this non executably
|
||||
[ -f ./socks5server-echo.sh ] && chmod a+x ./socks5server-echo.sh
|
||||
|
||||
[ "$DEFS" ] && echo "BASH_VERSION=\"$BASH_VERSION\"" >&2
|
||||
|
||||
[ "$DEFS" ] && echo "ECHO=\"$ECHO\"" >&2
|
||||
|
@ -259,12 +262,12 @@ fi
|
|||
|
||||
# for some tests we need a network interface
|
||||
if type ip >/dev/null 2>&1; then
|
||||
INTERFACE=$(ip r get 8.8.8.8 |grep ' dev ' |head -n 1 |sed "s/.*dev[[:space:]][[:space:]]*\([^[:space:]][^[:space:]]*\).*/\1/")
|
||||
INTERFACE=$(ip r get 9.9.9.9 |grep ' dev ' |head -n 1 |sed "s/.*dev[[:space:]][[:space:]]*\([^[:space:]][^[:space:]]*\).*/\1/")
|
||||
else
|
||||
case "$UNAME" in
|
||||
Linux)
|
||||
if [ "$IP" ]; then
|
||||
INTERFACE="$($IP route get 8.8.8.8 |grep ' dev ' |sed -e 's/.* dev //' -e 's/ .*//')"
|
||||
INTERFACE="$($IP route get 9.9.9.9 |grep ' dev ' |sed -e 's/.* dev //' -e 's/ .*//')"
|
||||
else
|
||||
INTERFACE="$(netstat -rn |grep -e "^default" -e "^0\.0\.0\.0" |awk '{print($8);}')"
|
||||
fi ;;
|
||||
|
@ -489,7 +492,7 @@ if2bc4() {
|
|||
case "$UNAME" in
|
||||
Linux)
|
||||
if [ "$IP" ]; then
|
||||
BROADCASTIF=$($IP r get 8.8.8.8 |grep ' dev ' |sed 's/.*\<dev[[:space:]][[:space:]]*\([a-z0-9][a-z0-9]*\).*/\1/')
|
||||
BROADCASTIF=$($IP r get 9.9.9.9 |grep ' dev ' |sed 's/.*\<dev[[:space:]][[:space:]]*\([a-z0-9][a-z0-9]*\).*/\1/')
|
||||
else
|
||||
BROADCASTIF=$(route -n |grep '^0.0.0.0 ' |awk '{print($8);}')
|
||||
fi
|
||||
|
@ -2077,11 +2080,22 @@ case "$UNAME" in
|
|||
esac
|
||||
|
||||
|
||||
HAVEDNS=1
|
||||
if [ "$INTERNET" ]; then
|
||||
# No "-s 24" on Solaris
|
||||
if ! ping -c 1 "server-4.dest-unreach.net" >/dev/null 2>&1; then
|
||||
echo "$0: Option --internet but no connectivity or DNS" >&2
|
||||
#exit 1
|
||||
if ! ping -c 1 "9.9.9.9" >/dev/null 2>&1; then
|
||||
echo "$0: Option --internet but no connectivity" >&2
|
||||
HAVEDNS=
|
||||
elif type nslookup >/dev/null 2>&1; then
|
||||
if ! nslookup server-4.dest-unreach.net. |grep '^Name:' >/dev/null 2>&1; then
|
||||
echo "$0: Option --internet but broken DNS (cannot resolve server-4.dest-unreach.net)" >&2
|
||||
HAVEDNS=
|
||||
fi
|
||||
elif type host >/dev/null 2>&1; then
|
||||
if ! host server-4.dest-unreach.net. |grep "has address" >/dev/null 2>&1; then
|
||||
echo "$0: Option --internet but broken DNS (cannot resolve server-4.dest-unreach.net)" >&2
|
||||
HAVEDNS=
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -16227,12 +16241,6 @@ TEST="$NAME: try all available TCP4 addresses"
|
|||
# that is closed on both addresses.
|
||||
# The test succeeded when the log shows that Socat tried to connect two times.
|
||||
if ! eval $NUMCOND; then :;
|
||||
elif ! $(type nslookup >/dev/null 2>&1); then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}nslookup not available${NORMAL}\n" $N
|
||||
cant
|
||||
#elif ! $(type nslookup >/dev/null 2>&1) && ! $(type host >/dev/null 2>&1); then
|
||||
# $PRINTF "test $F_n $TEST... ${YELLOW}nslookup and host not available${NORMAL}\n" $N
|
||||
# cant
|
||||
elif ! F=$(testfeats IP4 TCP GOPEN); then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}Feature $F not available${NORMAL}\n" $N
|
||||
cant
|
||||
|
@ -16245,16 +16253,14 @@ elif ! runsip4 >/dev/null; then
|
|||
elif [ -z "$INTERNET" ]; then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}use test.sh option --internet${NORMAL}\n" $N
|
||||
cant
|
||||
elif [ -z "$HAVEDNS" ]; then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}Broken DNS${NORMAL}\n" $N
|
||||
cant
|
||||
else
|
||||
tf="$td/test$N.stdout"
|
||||
te="$td/test$N.stderr"
|
||||
tdiff="$td/test$N.diff"
|
||||
da="test$N $(date) $RANDOM"
|
||||
if type nslookup >/dev/null 2>&1; then
|
||||
ADDRS=$(nslookup server-4.dest-unreach.net. |sed -n '/^$/,$ p' |grep ^Address |awk '{print($2);}')
|
||||
elif type host >/dev/null 2>&1; then
|
||||
ADDRS=$(host server-4.dest-unreach.net. |sed 's/.*address //')
|
||||
fi
|
||||
while true; do
|
||||
newport tcp4
|
||||
OPEN=
|
||||
|
@ -16302,9 +16308,6 @@ TEST="$NAME: for TCP try all available IPv4 and IPv6 addresses"
|
|||
# neither IPv4 nor IPv6
|
||||
# Check the log if Socat tried both addresses
|
||||
if ! eval $NUMCOND; then :;
|
||||
#elif ! $(type nslookup >/dev/null 2>&1) && ! $(type host >/dev/null 2>&1); then
|
||||
# $PRINTF "test $F_n $TEST... ${YELLOW}nslookup and host not available${NORMAL}\n" $N
|
||||
# cant
|
||||
elif ! F=$(testfeats IP4 IP6 TCP); then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}Feature $F not available${NORMAL}\n" $N
|
||||
cant
|
||||
|
@ -16320,9 +16323,12 @@ elif ! runsip4 >/dev/null; then
|
|||
elif ! runsip6 >/dev/null; then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}IPv6 not available or not routable${NORMAL}\n" $N
|
||||
cant
|
||||
elif [ -z "$INTERNET" ]; then # only needs Internet DNS
|
||||
elif [ -z "$INTERNET" -a "$RES" != 'DEVTESTS' ]; then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}use test.sh option --internet${NORMAL}\n" $N
|
||||
cant
|
||||
elif [ -z "$HAVEDNS" ] && ! testfeats DEVTESTS >/dev/null; then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}Broken DNS${NORMAL}\n" $N
|
||||
cant
|
||||
else
|
||||
tf="$td/test$N.stdout"
|
||||
te="$td/test$N.stderr"
|
||||
|
@ -19565,6 +19571,7 @@ fi
|
|||
CNAME=$(echo $CADDR |tr - _)
|
||||
PROTO=$(toupper $proto)
|
||||
FEAT=$ADDR
|
||||
addr=$(tolower $ADDR)
|
||||
runs=$proto
|
||||
case "$CPARMS" in
|
||||
PORT) newport $proto; CPARMS=$PORT ;;
|
||||
|
@ -19582,7 +19589,7 @@ esac
|
|||
# Test if bind on *-CONNECT selects the matching IP version
|
||||
NAME=${CNAME}_BIND_6_4
|
||||
case "$TESTS" in
|
||||
*%$N%*|*%functions%*|*%$proto%*|*%${proto}4%*|*%${proto}6%*|*%ip4%*|*%ip6%*|*%listen%*|*%bind%*|*%socket%*|*%$NAME%*)
|
||||
*%$N%*|*%functions%*|*%$addr%*|*%$proto%*|*%${proto}4%*|*%${proto}6%*|*%ip4%*|*%ip6%*|*%listen%*|*%bind%*|*%socket%*|*%$NAME%*)
|
||||
TEST="$NAME: $ADDR bind chooses matching IPv"
|
||||
# Have an IPv4 listener
|
||||
# Host name localhost-4-6.dest-unreach.net resolves to both 127.0.0.1 and [::1],
|
||||
|
@ -19609,6 +19616,12 @@ elif ! cond=$(checkconds \
|
|||
elif ! SOCAT_MAIN_WAIT= $SOCAT -h |grep -e '[[:space:]]-6[[:space:]]' >/dev/null; then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}no option -0${NORMAL}\n" $N
|
||||
cant
|
||||
elif [ -z "$INTERNET" -a "$RES" != 'DEVTESTS' ]; then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}use test.sh option --internet${NORMAL}\n" $N
|
||||
cant
|
||||
elif [ -z "$HAVEDNS" ] && ! testfeats DEVTESTS >/dev/null; then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}Broken DNS${NORMAL}\n" $N
|
||||
cant
|
||||
else
|
||||
tf="$td/test$N.stdout"
|
||||
te="$td/test$N.stderr"
|
||||
|
@ -19702,6 +19715,12 @@ elif ! cond=$(checkconds \
|
|||
elif ! SOCAT_MAIN_WAIT= $SOCAT -h |grep -e '[[:space:]]-6[[:space:]]' >/dev/null; then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}no option -0${NORMAL}\n" $N
|
||||
cant
|
||||
elif [ -z "$INTERNET" -a "$RES" != 'DEVTESTS' ]; then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}use test.sh option --internet${NORMAL}\n" $N
|
||||
cant
|
||||
elif [ -z "$HAVEDNS" ] && ! testfeats DEVTESTS >/dev/null; then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}Broken DNS${NORMAL}\n" $N
|
||||
cant
|
||||
else
|
||||
tf="$td/test$N.stdout"
|
||||
te="$td/test$N.stderr"
|
||||
|
@ -19785,6 +19804,12 @@ elif ! cond=$(checkconds \
|
|||
elif ! SOCAT_MAIN_WAIT= $SOCAT -h |grep -e '[[:space:]]-4[[:space:]]' >/dev/null; then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}no option -0${NORMAL}\n" $N
|
||||
cant
|
||||
elif [ -z "$INTERNET" -a "$RES" != 'DEVTESTS' ]; then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}use test.sh option --internet${NORMAL}\n" $N
|
||||
cant
|
||||
elif [ -z "$HAVEDNS" ] && ! testfeats DEVTESTS >/dev/null; then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}Broken DNS${NORMAL}\n" $N
|
||||
cant
|
||||
else
|
||||
tf="$td/test$N.stdout"
|
||||
te="$td/test$N.stderr"
|
||||
|
@ -19855,6 +19880,7 @@ fi
|
|||
CNAME=$(echo $CADDR |tr - _)
|
||||
PROTO=$(toupper $proto)
|
||||
FEAT=$ADDR
|
||||
addr=$(tolower $ADDR)
|
||||
runs=$proto
|
||||
case "$CPARMS" in
|
||||
PORT) newport $proto; CPARMS=$PORT ;;
|
||||
|
@ -19872,7 +19898,7 @@ esac
|
|||
# Test the retry option with *-CONNECT addresses
|
||||
NAME=${CNAME}_RETRY
|
||||
case "$TESTS" in
|
||||
*%$N%*|*%functions%*|*%$proto%*|*%${proto}4%*|*%ip4%*|*%listen%*|*%socket%*|*%retry%*|*%$NAME%*)
|
||||
*%$N%*|*%functions%*|*%$addr%*|*%$proto%*|*%${proto}4%*|*%ip4%*|*%listen%*|*%socket%*|*%retry%*|*%$NAME%*)
|
||||
TEST="$NAME: $ADDR can retry"
|
||||
# Have an IPv4 listener with delay
|
||||
# Start a connector whose first attempt must fail; check if the second attempt
|
||||
|
@ -19973,6 +19999,7 @@ fi
|
|||
CNAME=$(echo $CADDR |tr - _)
|
||||
PROTO=$(toupper $proto)
|
||||
FEAT=$ADDR
|
||||
addr=$(tolower $ADDR)
|
||||
runs=$proto
|
||||
case "$CPARMS" in
|
||||
PORT) newport $proto; CPARMS=$PORT ;;
|
||||
|
@ -19990,7 +20017,7 @@ esac
|
|||
# Test the fork and max-children options with CONNECT addresses
|
||||
NAME=${CNAME}_MAXCHILDREN
|
||||
case "$TESTS" in
|
||||
*%$N%*|*%functions%*|*%$proto%*|*%${proto}4%*|*%ip4%*|*%listen%*|*%socket%*|*%fork%*|*%maxchildren%*|*%$NAME%*)
|
||||
*%$N%*|*%functions%*|*%$addr%*|*%$proto%*|*%${proto}4%*|*%ip4%*|*%listen%*|*%socket%*|*%fork%*|*%maxchildren%*|*%$NAME%*)
|
||||
TEST="$NAME: $ADDR with fork,max-children"
|
||||
# Start a reader process that transfers received data to an output file;
|
||||
# run a sending client that forks at most 2 parallel child processes that
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue