RPM, tests, pointlist indexing and nlookup-ing, lint fixes #4

Merged
zx merged 15 commits from zx into master 2025-04-21 10:27:16 +03:00
11 changed files with 131 additions and 47 deletions
Showing only changes of commit ee9c78d129 - Show all commits

View File

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

View File

@ -6,7 +6,7 @@ proto_order %PROTO%
#domain schoolnet /var/spool/ftn/schoolnet/ 461
log_file %TESTZONE%/logsA/bf-log
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
inbound_directory (Protected) %TESTZONE%/inboundA
inbound_directory %TESTZONE%/inbound-unsecureA
@ -19,6 +19,7 @@ status_directory %TESTZONE%/logsA
history_file %TESTZONE%/logsA/history
password 99:1/2 testpwd1
override 99:1/2 flags INA:localhost,IFC:59999,IBN:59999
#min_speed_in 1200
#min_speed_out 1200
#session_limit_in 1800

View File

@ -6,7 +6,7 @@ proto_order %PROTO%
#domain schoolnet /var/spool/ftn/schoolnet/ 461
log_file %TESTZONE%/logsB/bf-log
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
inbound_directory (Protected) %TESTZONE%/inboundB
inbound_directory %TESTZONE%/inbound-unsecureB
@ -19,6 +19,7 @@ status_directory %TESTZONE%/logsB
history_file %TESTZONE%/logsB/history
password 99:1/1 testpwd1
override 99:1/1 flags INA:localhost,IFC:59999,IBN:59999
#min_speed_in 1200
#min_speed_out 1200
#session_limit_in 1800

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

View File

@ -1,52 +1,93 @@
#!/bin/bash
# Making tests of BForce
CURDIR=$(pwd)
BFBIN=$(pwd)/../source/bin/bforce
CURDIR="${CURDIR:-$(pwd)}"
BFBIN=${BFBIN:-$(pwd)/../source/bin/bforce}
SOCATCMD=${SOCATCMD:-$(which socat)}
function prepconfig() {
echo "Preparing configs with $1 as protocol..."
cp ${CURDIR}/configs/bforceA.conf ${CURDIR}/etc/bforceA.conf
sed -i -e "s/%PROTO%/$1/" ${CURDIR}/etc/bforceA.conf
sed -i -e "s#%TESTZONE%#${CURDIR}#" ${CURDIR}/etc/bforceA.conf
if [[ ! -d "${CURDIR}/ftntest" ]] ;
then
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
sed -i -e "s/%PROTO%/$1/" ${CURDIR}/etc/bforceB.conf
sed -i -e "s#%TESTZONE%#${CURDIR}#" ${CURDIR}/etc/bforceB.conf
mkdir -p "${CURDIR}"/ftntest/{etc,inbound-unsecureA,inbound-unsecureB,inboundA,inboundB,logsA,logsB,outboundA,outboundB}
cp -f ${CURDIR}/configs/bforceA.conf ${CURDIR}/ftntest/etc/bforceA.conf
sed -i -e "s/%PROTO%/$1/" ${CURDIR}/ftntest/etc/bforceA.conf
sed -i -e "s#%TESTZONE%#${CURDIR}/ftntest#" ${CURDIR}/ftntest/etc/bforceA.conf
cp ${CURDIR}/configs/00010002.cut ${CURDIR}/outboundA/00010002.cut
cp ${CURDIR}/configs/00010001.cut ${CURDIR}/outboundB/00010001.cut
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() {
rm -rf ${CURDIR}/inboundA/*
rm -rf ${CURDIR}/inboundB/*
rm -rf ${CURDIR}/ftntest/inboundA/*
rm -rf ${CURDIR}/ftntest/inboundB/*
echo " over ${1}"
# for V1 and V2
#mkfifo ${CURDIR}/bforceAtoB
#mkfifo ${CURDIR}/bforceBtoA
mkfifo ${CURDIR}/bforceAtoB
mkfifo ${CURDIR}/bforceBtoA
BFCFGA=${CURDIR}/etc/bforceA.conf
BFCFGB=${CURDIR}/etc/bforceB.conf
BFCFGA=${CURDIR}/ftntest/etc/bforceA.conf
BFCFGB=${CURDIR}/ftntest/etc/bforceB.conf
# Works for Linux
BFCONFIG=${BFCFGA}
BFCONFIG=${BFCFGA} ${BFBIN} -o 99:1/2 > ${CURDIR}/bforceAtoB < ${CURDIR}/bforceBtoA &
# Variant 1
#BFCONFIG=${BFCFGA}
#BFCONFIG=${BFCFGA} ${BFBIN} -o 99:1/2 > ${CURDIR}/bforceAtoB < ${CURDIR}/bforceBtoA &
#
BFCONFIG=${BFCFGB}
BFCONFIG=${BFCFGB} ${BFBIN} -S"CONNECT 9600" auto < ${CURDIR}/bforceAtoB > ${CURDIR}/bforceBtoA
#BFCONFIG=${BFCFGB}
#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:
# ./ping <&1 | ./pong >&0
rm ${CURDIR}/{bforceAtoB,bforceBtoA}
# for V1 and V2
#rm ${CURDIR}/{bforceAtoB,bforceBtoA}
## WE MUST CHECK THAT INBOUND ARE FULL!!! ##
FCNTA=$( find ${CURDIR}/inboundA -name *.pkt | wc -l )
FCNTB=$( find ${CURDIR}/inboundB -name *.pkt | wc -l )
DIFFA=$( diff ${CURDIR}/inboundA/*.pkt ${CURDIR}/configs/00010001.cut && echo $? )
DIFFB=$( diff ${CURDIR}/inboundB/*.pkt ${CURDIR}/configs/00010002.cut && echo $? )
FCNTA=$( find ${CURDIR}/ftntest/inboundA -name *.pkt | wc -l )
FCNTB=$( find ${CURDIR}/ftntest/inboundB -name *.pkt | wc -l )
if [[ "${FCNTA}" -eq "1" ]]
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" ]]
then
@ -55,48 +96,76 @@ function testcomm() {
echo "....Result: OK"
else
echo "....Failed DiffB"
RES=2
fi
else
echo "....Failed DiffA"
RES=1
fi
cat ${CURDIR}/logsA/bf-debug >> ${CURDIR}/debugA.log
cat ${CURDIR}/logsB/bf-debug >> ${CURDIR}/debugB.log
if [[ -f ${CURDIR}/ftntest/logsA/bf-debug ]]
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}" ]]
then
# No executable to test!
echo "No executable to run! Aborting..."
exit -1
else
if [[ ! -f "${SOCATCMD}" ]]
then
# No socat
echo "No socat cmd! Aborting..."
exit -1
fi
# All doing here
echo "Bforce executable found"
echo "Bforce executable found: ${BFBIN}"
RES=0
prepconfig "ZMO"
echo -n "--> Running ZMO test..."
testcomm
testcomm "PSTN"
prepconfig "ZAP"
echo -n "--> Running ZAP test..."
testcomm
testcomm "PSTN"
prepconfig "HYD"
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
fi
rm -rf {etc,inboundA,inboundB,inbound-unsecureA,inbound-unsecureB,logsA,logsB,outboundA,outboundB}
# rm -rf ${CURDIR}/ftntest/{etc,inboundA,inboundB,inbound-unsecureA,inbound-unsecureB,logsA,logsB,outboundA,outboundB}
rm -rf ${CURDIR}/ftntest
# 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