Added full-duplex all-protocol tests through socat, fixed makefile.in for manual inst
All checks were successful
Altlinux build / build-alt (push) Successful in 2m16s
Archlinux build / build-arch (push) Successful in 3m2s
Debian build / build-ubuntu (push) Successful in 3m51s

This commit is contained in:
Alexey Khromov 2025-04-17 21:40:34 +03:00
parent 14d2f2992d
commit ee9c78d129
11 changed files with 131 additions and 47 deletions

View File

@ -28,7 +28,7 @@ CONFDIR = @sysconfdir@
BINDIR = @bindir@ BINDIR = @bindir@
LOGDIR = @LOGDIR@ LOGDIR = @LOGDIR@
SPOOLDIR = @SPOOLDIR@ SPOOLDIR = @SPOOLDIR@
MANDIR = @MANDIR@ MANDIR = /usr/share/man/man1
DAEMON_LOGFILE = $(LOGDIR)/bf-daemon DAEMON_LOGFILE = $(LOGDIR)/bf-daemon
BFORCE_LOGFILE = $(LOGDIR)/bf-log BFORCE_LOGFILE = $(LOGDIR)/bf-log

View File

@ -6,7 +6,7 @@ proto_order %PROTO%
#domain schoolnet /var/spool/ftn/schoolnet/ 461 #domain schoolnet /var/spool/ftn/schoolnet/ 461
log_file %TESTZONE%/logsA/bf-log log_file %TESTZONE%/logsA/bf-log
debug_file %TESTZONE%/logsA/bf-debug debug_file %TESTZONE%/logsA/bf-debug
debug_level modem hshake event freq debug_level info modem hshake event prot override
nodial_flag %TESTZONE%/etc/nodial nodial_flag %TESTZONE%/etc/nodial
inbound_directory (Protected) %TESTZONE%/inboundA inbound_directory (Protected) %TESTZONE%/inboundA
inbound_directory %TESTZONE%/inbound-unsecureA inbound_directory %TESTZONE%/inbound-unsecureA
@ -19,6 +19,7 @@ status_directory %TESTZONE%/logsA
history_file %TESTZONE%/logsA/history history_file %TESTZONE%/logsA/history
password 99:1/2 testpwd1 password 99:1/2 testpwd1
override 99:1/2 flags INA:localhost,IFC:59999,IBN:59999
#min_speed_in 1200 #min_speed_in 1200
#min_speed_out 1200 #min_speed_out 1200
#session_limit_in 1800 #session_limit_in 1800

View File

@ -6,7 +6,7 @@ proto_order %PROTO%
#domain schoolnet /var/spool/ftn/schoolnet/ 461 #domain schoolnet /var/spool/ftn/schoolnet/ 461
log_file %TESTZONE%/logsB/bf-log log_file %TESTZONE%/logsB/bf-log
debug_file %TESTZONE%/logsB/bf-debug debug_file %TESTZONE%/logsB/bf-debug
debug_level modem hshake event freq debug_level info modem hshake event prot override
nodial_flag %TESTZONE%/etc/nodial nodial_flag %TESTZONE%/etc/nodial
inbound_directory (Protected) %TESTZONE%/inboundB inbound_directory (Protected) %TESTZONE%/inboundB
inbound_directory %TESTZONE%/inbound-unsecureB inbound_directory %TESTZONE%/inbound-unsecureB
@ -19,6 +19,7 @@ status_directory %TESTZONE%/logsB
history_file %TESTZONE%/logsB/history history_file %TESTZONE%/logsB/history
password 99:1/1 testpwd1 password 99:1/1 testpwd1
override 99:1/1 flags INA:localhost,IFC:59999,IBN:59999
#min_speed_in 1200 #min_speed_in 1200
#min_speed_out 1200 #min_speed_out 1200
#session_limit_in 1800 #session_limit_in 1800

0
tests/configs/genpkt.sh Executable file → Normal file
View File

View File

@ -1,52 +1,93 @@
#!/bin/bash #!/bin/bash
# Making tests of BForce # Making tests of BForce
CURDIR=$(pwd) CURDIR="${CURDIR:-$(pwd)}"
BFBIN=$(pwd)/../source/bin/bforce BFBIN=${BFBIN:-$(pwd)/../source/bin/bforce}
SOCATCMD=${SOCATCMD:-$(which socat)}
function prepconfig() { function prepconfig() {
echo "Preparing configs with $1 as protocol..." echo "Preparing configs with $1 as protocol..."
cp ${CURDIR}/configs/bforceA.conf ${CURDIR}/etc/bforceA.conf if [[ ! -d "${CURDIR}/ftntest" ]] ;
sed -i -e "s/%PROTO%/$1/" ${CURDIR}/etc/bforceA.conf then
sed -i -e "s#%TESTZONE%#${CURDIR}#" ${CURDIR}/etc/bforceA.conf echo -n "(o_O) "
else
echo "Dir exists!"
rm -rf ${CURDIR}/ftntest/{etc,inboundA,inboundB,inbound-unsecureA,inbound-unsecureB,logsA,logsB,outboundA,outboundB}
fi
cp ${CURDIR}/configs/bforceB.conf ${CURDIR}/etc/bforceB.conf mkdir -p "${CURDIR}"/ftntest/{etc,inbound-unsecureA,inbound-unsecureB,inboundA,inboundB,logsA,logsB,outboundA,outboundB}
sed -i -e "s/%PROTO%/$1/" ${CURDIR}/etc/bforceB.conf
sed -i -e "s#%TESTZONE%#${CURDIR}#" ${CURDIR}/etc/bforceB.conf
cp ${CURDIR}/configs/00010002.cut ${CURDIR}/outboundA/00010002.cut cp -f ${CURDIR}/configs/bforceA.conf ${CURDIR}/ftntest/etc/bforceA.conf
cp ${CURDIR}/configs/00010001.cut ${CURDIR}/outboundB/00010001.cut sed -i -e "s/%PROTO%/$1/" ${CURDIR}/ftntest/etc/bforceA.conf
sed -i -e "s#%TESTZONE%#${CURDIR}/ftntest#" ${CURDIR}/ftntest/etc/bforceA.conf
cp -f ${CURDIR}/configs/bforceB.conf ${CURDIR}/ftntest/etc/bforceB.conf
sed -i -e "s/%PROTO%/$1/" ${CURDIR}/ftntest/etc/bforceB.conf
sed -i -e "s#%TESTZONE%#${CURDIR}/ftntest#" ${CURDIR}/ftntest/etc/bforceB.conf
cp -f ${CURDIR}/configs/00010002.cut ${CURDIR}/ftntest/outboundA/00010002.cut
cp -f ${CURDIR}/configs/00010001.cut ${CURDIR}/ftntest/outboundB/00010001.cut
} }
function testcomm() { function testcomm() {
rm -rf ${CURDIR}/inboundA/* rm -rf ${CURDIR}/ftntest/inboundA/*
rm -rf ${CURDIR}/inboundB/* rm -rf ${CURDIR}/ftntest/inboundB/*
echo " over ${1}"
# for V1 and V2
#mkfifo ${CURDIR}/bforceAtoB
#mkfifo ${CURDIR}/bforceBtoA
mkfifo ${CURDIR}/bforceAtoB BFCFGA=${CURDIR}/ftntest/etc/bforceA.conf
mkfifo ${CURDIR}/bforceBtoA BFCFGB=${CURDIR}/ftntest/etc/bforceB.conf
BFCFGA=${CURDIR}/etc/bforceA.conf
BFCFGB=${CURDIR}/etc/bforceB.conf
# Works for Linux # Works for Linux
# Variant 1
BFCONFIG=${BFCFGA} #BFCONFIG=${BFCFGA}
BFCONFIG=${BFCFGA} ${BFBIN} -o 99:1/2 > ${CURDIR}/bforceAtoB < ${CURDIR}/bforceBtoA & #BFCONFIG=${BFCFGA} ${BFBIN} -o 99:1/2 > ${CURDIR}/bforceAtoB < ${CURDIR}/bforceBtoA &
# #
BFCONFIG=${BFCFGB} #BFCONFIG=${BFCFGB}
BFCONFIG=${BFCFGB} ${BFBIN} -S"CONNECT 9600" auto < ${CURDIR}/bforceAtoB > ${CURDIR}/bforceBtoA #BFCONFIG=${BFCFGB} ${BFBIN} -S"CONNECT 9600" auto < ${CURDIR}/bforceAtoB > ${CURDIR}/bforceBtoA
# Variant 2
#${CURDIR}/runbfA.sh ${BFBIN} ${BFCFGA} > ${CURDIR}/bforceAtoB < ${CURDIR}/bforceBtoA &
#${CURDIR}/runbfB.sh ${BFBIN} ${BFCFGB} < ${CURDIR}/bforceAtoB > ${CURDIR}/bforceBtoA
# Variant 3 works with sockets and pipes - not pty
case ${1} in
"PSTN")
socat -ly -Wlock EXEC:"${CURDIR}/runbfB.sh ${BFBIN} ${BFCFGB}" EXEC:"${CURDIR}/runbfA.sh ${BFBIN} ${BFCFGA}"
sleep 2
;;
"IFC")
${CURDIR}/runbfC.sh ${BFBIN} ${BFCFGA} &
socat -ly -Wlock TCP4-LISTEN:59999 EXEC:"${CURDIR}/runbfD.sh ${BFBIN} ${BFCFGB}"
sleep 2
;;
"BKP")
${CURDIR}/runbfE.sh ${BFBIN} ${BFCFGA} &
socat -ly -Wlock TCP4-LISTEN:59999 EXEC:"${CURDIR}/runbfF.sh ${BFBIN} ${BFCFGB}"
sleep 2
;;
esac
# For [Free]BSD it need to be replaced - pipes are bidirectional: # For [Free]BSD it need to be replaced - pipes are bidirectional:
# ./ping <&1 | ./pong >&0 # ./ping <&1 | ./pong >&0
rm ${CURDIR}/{bforceAtoB,bforceBtoA} # for V1 and V2
#rm ${CURDIR}/{bforceAtoB,bforceBtoA}
## WE MUST CHECK THAT INBOUND ARE FULL!!! ## ## WE MUST CHECK THAT INBOUND ARE FULL!!! ##
FCNTA=$( find ${CURDIR}/inboundA -name *.pkt | wc -l ) FCNTA=$( find ${CURDIR}/ftntest/inboundA -name *.pkt | wc -l )
FCNTB=$( find ${CURDIR}/inboundB -name *.pkt | wc -l ) FCNTB=$( find ${CURDIR}/ftntest/inboundB -name *.pkt | wc -l )
DIFFA=$( diff ${CURDIR}/inboundA/*.pkt ${CURDIR}/configs/00010001.cut && echo $? ) if [[ "${FCNTA}" -eq "1" ]]
DIFFB=$( diff ${CURDIR}/inboundB/*.pkt ${CURDIR}/configs/00010002.cut && echo $? ) then
DIFFA=$( diff ${CURDIR}/ftntest/inboundA/*.pkt ${CURDIR}/configs/00010001.cut && echo $? )
fi
if [[ "${FCNTB}" -eq "1" ]]
then
DIFFB=$( diff ${CURDIR}/ftntest/inboundB/*.pkt ${CURDIR}/configs/00010002.cut && echo $? )
fi
if [[ "${DIFFA}" -eq "0" ]] && [[ "${FCNTA}" -eq "1" ]] if [[ "${DIFFA}" -eq "0" ]] && [[ "${FCNTA}" -eq "1" ]]
then then
@ -55,48 +96,76 @@ function testcomm() {
echo "....Result: OK" echo "....Result: OK"
else else
echo "....Failed DiffB" echo "....Failed DiffB"
RES=2
fi fi
else else
echo "....Failed DiffA" echo "....Failed DiffA"
RES=1
fi fi
cat ${CURDIR}/logsA/bf-debug >> ${CURDIR}/debugA.log if [[ -f ${CURDIR}/ftntest/logsA/bf-debug ]]
cat ${CURDIR}/logsB/bf-debug >> ${CURDIR}/debugB.log then
cat ${CURDIR}/ftntest/logsA/bf-debug >> ${CURDIR}/debugA.log
fi
if [[ -f ${CURDIR}/ftntest/logsB/bf-debug ]]
then
cat ${CURDIR}/ftntest/logsB/bf-debug >> ${CURDIR}/debugB.log
fi
rm -rf ${CURDIR}/ftntest
} }
if [[ ! -d "${CURDIR}/inboundA" ]]
then
echo "All clear to begin"
else
echo "Dir exists!"
rm -rf {etc,inboundA,inboundB,inbound-unsecureA,inbound-unsecureB,logsA,logsB,outboundA,outboundB}
fi
mkdir -p "${CURDIR}"/{etc,inbound-unsecureA,inbound-unsecureB,inboundA,inboundB,logsA,logsB,outboundA,outboundB}
if [[ ! -f "${BFBIN}" ]] if [[ ! -f "${BFBIN}" ]]
then then
# No executable to test! # No executable to test!
echo "No executable to run! Aborting..." echo "No executable to run! Aborting..."
exit -1
else else
if [[ ! -f "${SOCATCMD}" ]]
then
# No socat
echo "No socat cmd! Aborting..."
exit -1
fi
# All doing here # All doing here
echo "Bforce executable found" echo "Bforce executable found: ${BFBIN}"
RES=0
prepconfig "ZMO" prepconfig "ZMO"
echo -n "--> Running ZMO test..." echo -n "--> Running ZMO test..."
testcomm testcomm "PSTN"
prepconfig "ZAP" prepconfig "ZAP"
echo -n "--> Running ZAP test..." echo -n "--> Running ZAP test..."
testcomm testcomm "PSTN"
prepconfig "HYD" prepconfig "HYD"
echo -n "--> Running Hydra test..." echo -n "--> Running Hydra test..."
testcomm testcomm "PSTN"
prepconfig "ZMO"
echo -n "--> Running ZMO test..."
testcomm "IFC"
prepconfig "ZAP"
echo -n "--> Running ZAP test..."
testcomm "IFC"
prepconfig "HYD"
echo -n "--> Running HYD test..."
testcomm "IFC"
prepconfig "ZMO"
echo -n "--> Running BINKP test..."
testcomm "BKP"
# TODO: make binkd test over netcat possibly # TODO: make binkd test over netcat possibly
fi fi
# rm -rf ${CURDIR}/ftntest/{etc,inboundA,inboundB,inbound-unsecureA,inbound-unsecureB,logsA,logsB,outboundA,outboundB}
rm -rf ${CURDIR}/ftntest
rm -rf {etc,inboundA,inboundB,inbound-unsecureA,inbound-unsecureB,logsA,logsB,outboundA,outboundB} # printf $RES
exit ${RES}

3
tests/runbfA.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
BFCONFIG=${2} ${1} -C ${2} -o 99:1/2

2
tests/runbfB.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
BFCONFIG=${2} ${1} -C ${2} -S"CONNECT 9600" -i auto

2
tests/runbfC.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
BFCONFIG=${2} ${1} -C ${2} -a 127.0.0.1:59999 -u ifcico 99:1/2

2
tests/runbfD.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
BFCONFIG=${2} ${1} -C ${2} -S"" -i auto

2
tests/runbfE.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
BFCONFIG=${2} ${1} -C ${2} -a 127.0.0.1:59999 -u binkp 99:1/2

2
tests/runbfF.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
BFCONFIG=${2} ${1} -C ${2} -i binkp