mirror of
https://repo.or.cz/socat.git
synced 2025-07-11 22:23:24 +00:00
Fixed UDP-LISTEN with bind to IPv4 address on option -0
This commit is contained in:
parent
c4844692f3
commit
0f1c5dd85a
5 changed files with 131 additions and 26 deletions
104
test.sh
104
test.sh
|
@ -3231,18 +3231,20 @@ echo "$da" |$CMD2 >>"$tf" 2>>"${te}2"
|
|||
rc2=$?
|
||||
kill $pid1 2>/dev/null; wait
|
||||
if [ $rc2 -ne 0 ]; then
|
||||
$PRINTF "$FAILED: $TRACE $SOCAT:\n"
|
||||
$PRINTF "$FAILED (rc2=$rc2)\n"
|
||||
echo "$CMD1 &"
|
||||
cat "${te}1" >&2
|
||||
echo "$CMD2"
|
||||
cat "${te}1" "${te}2"
|
||||
cat "${te}2" >&2
|
||||
failed
|
||||
elif ! echo "$da" |diff - "$tf" >"$tdiff"; then
|
||||
$PRINTF "$FAILED\n"
|
||||
$PRINTF "$FAILED (diff)\n"
|
||||
echo "$CMD1 &"
|
||||
cat "${te}1"
|
||||
cat "${te}1" >&2
|
||||
echo "$CMD2"
|
||||
cat "${te}2"
|
||||
cat "$tdiff"
|
||||
cat "${te}2" >&2
|
||||
echo "// diff:" >&2
|
||||
cat "$tdiff" >&2
|
||||
failed
|
||||
else
|
||||
$PRINTF "$OK\n"
|
||||
|
@ -3279,14 +3281,20 @@ echo "$da" |$CMD2 >>"$tf" 2>>"${te}2"
|
|||
rc2=$?
|
||||
kill $pid1 2>/dev/null; wait
|
||||
if [ $rc2 -ne 0 ]; then
|
||||
$PRINTF "$FAILED: $TRACE $SOCAT:\n"
|
||||
$PRINTF "$FAILED (rc2=$rc2)\n"
|
||||
echo "$CMD1 &"
|
||||
cat "${te}1" >&2
|
||||
echo "$CMD2"
|
||||
cat "${te}1" "${te}2"
|
||||
cat "${te}2" >&2
|
||||
failed
|
||||
elif ! echo "$da" |diff - "$tf" >"$tdiff"; then
|
||||
$PRINTF "$FAILED\n"
|
||||
cat "$tdiff"
|
||||
$PRINTF "$FAILED (diff)\n"
|
||||
echo "$CMD1 &"
|
||||
cat "${te}1" >&2
|
||||
echo "$CMD2"
|
||||
cat "${te}2" >&2
|
||||
echo "// diff:" >&2
|
||||
cat "$tdiff" >&2
|
||||
failed
|
||||
else
|
||||
$PRINTF "$OK\n"
|
||||
|
@ -3540,8 +3548,7 @@ elif ! cond=$(checkconds \
|
|||
"ignoreeof" \
|
||||
"" ); then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}$cond${NORMAL}\n" $N
|
||||
numCANT=$((numCANT+1))
|
||||
listCANT="$listCANT $N"
|
||||
cant
|
||||
else
|
||||
ti="$td/test$N.file"
|
||||
tf="$td/test$N.stdout"
|
||||
|
@ -3593,8 +3600,7 @@ elif ! cond=$(checkconds \
|
|||
"ignoreeof" \
|
||||
"" ); then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}$cond${NORMAL}\n" $N
|
||||
numCANT=$((numCANT+1))
|
||||
listCANT="$listCANT $N"
|
||||
cant
|
||||
else
|
||||
# Let Socat read from an empty file, this would terminate immediately due to
|
||||
# EOF. Wait for more than one second, then append data to the file; when Socat
|
||||
|
@ -13046,9 +13052,7 @@ elif ! cond=$(checkconds \
|
|||
"ipv6-join-group" \
|
||||
"udp6" ); then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}$cond${NORMAL}\n" $N
|
||||
numCANT=$((numCANT+1))
|
||||
listCANT="$listCANT $N"
|
||||
namesCANT="$namesCANT $NAME"
|
||||
cant
|
||||
else
|
||||
tf="$td/test$N.stdout"
|
||||
te="$td/test$N.stderr"
|
||||
|
@ -19278,6 +19282,7 @@ N=$((N+1))
|
|||
# Below tests introduced with 1.8.0.3 (or later)
|
||||
|
||||
|
||||
|
||||
# Test the SOCKS5-CONNECT and SOCKS5-LISTEN addresses with IPv4
|
||||
for SUFFIX in CONNECT LISTEN; do
|
||||
|
||||
|
@ -19353,6 +19358,71 @@ N=$((N+1))
|
|||
done # CONNECT LISTEN
|
||||
|
||||
|
||||
# Test UDP-LISTEN with bind to IPv4 address; this failed with Socat version
|
||||
# 1.8.0.0
|
||||
NAME=UDP_LISTEN_BIND4
|
||||
case "$TESTS" in
|
||||
*%$N%*|*%functions%*|*%bugs%*|*%socket%*|*%ip4%*|*%udp%*|*%udp4%*|*%listen%*|*%$NAME%*)
|
||||
TEST="$NAME: Test UDP-LISTEN with bind to IPv4 addr"
|
||||
# Start a listener with UDP-LISTEN and bind to 127.0.0.1; when it starts
|
||||
# without error and even processes data the test succeeded
|
||||
if ! eval $NUMCOND; then :
|
||||
# Remove unneeded checks, adapt lists of the remaining ones
|
||||
elif ! cond=$(checkconds \
|
||||
"" \
|
||||
"" \
|
||||
"" \
|
||||
"IP4 UDP LISTEN STDIO PIPE" \
|
||||
"UDP-LISTEN PIPE STDIO UDP" \
|
||||
"bind" \
|
||||
"udp4" ); then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}$cond${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"
|
||||
newport udp4
|
||||
CMD0="$TRACE $SOCAT $opts UDP-LISTEN:$PORT,bind=$LOCALHOST4 PIPE"
|
||||
CMD1="$TRACE $SOCAT $opts - UDP-CONNECT:$LOCALHOST4:$PORT"
|
||||
printf "test $F_n $TEST... " $N
|
||||
$CMD0 >/dev/null 2>"${te}0" &
|
||||
pid0=$!
|
||||
waitudp4port $PORT 1
|
||||
echo "$da" |$CMD1 >"${tf}1" 2>"${te}1"
|
||||
rc1=$?
|
||||
kill $pid0 2>/dev/null; wait
|
||||
if [ "$rc1" -ne 0 ]; then
|
||||
$PRINTF "$FAILED (rc1=$rc1)\n"
|
||||
echo "$CMD0 &"
|
||||
cat "${te}0" >&2
|
||||
echo "$CMD1"
|
||||
cat "${te}1" >&2
|
||||
fail
|
||||
elif ! echo "$da" |diff - "${tf}1" >$tdiff; then
|
||||
$PRINTF "$FAILED (diff)\n"
|
||||
echo "$CMD0 &"
|
||||
cat "${te}0" >&2
|
||||
echo "$CMD1"
|
||||
cat "${te}1" >&2
|
||||
echo "// diff:" >&2
|
||||
cat "$tdiff" >&2
|
||||
fail
|
||||
else
|
||||
$PRINTF "$OK\n"
|
||||
if [ "$VERBOSE" ]; then echo "$CMD0 &"; fi
|
||||
if [ "$DEBUG" ]; then cat "${te}0" >&2; fi
|
||||
if [ "$VERBOSE" ]; then echo "$CMD1"; fi
|
||||
if [ "$DEBUG" ]; then cat "${te}1" >&2; fi
|
||||
ok
|
||||
fi
|
||||
fi # NUMCOND
|
||||
;;
|
||||
esac
|
||||
N=$((N+1))
|
||||
|
||||
|
||||
# end of common tests
|
||||
|
||||
##################################################################################
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue