diff options
author | KatolaZ <katolaz@freaknet.org> | 2018-07-16 15:56:58 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2018-07-16 15:56:58 +0100 |
commit | bfc10ee6b315fb282bdcdb3652370b6e85c274f5 (patch) | |
tree | e3a11d992528831c1e39b16d7badb987f91a5712 | |
parent | e5f23ea72935a4b1164914aaf56e6fb40d747d5b (diff) |
removed -c from netcat options (using fifos)
-rwxr-xr-x | gosher | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -22,6 +22,19 @@ ## server... ## +NETCAT=netcat +OPREFIX=/tmp/outf_ +IPREFIX=/tmp/inf_ + + +## function +cleanup(){ + [ -p "${OPREFIX}$$" ] && rm -f ${OPREFIX}$$ + [ -p "${IPREFIX}$$" ] && rm -f ${IPREFIX}$$ + exit 1 + +} + MYNAME=$(basename $0) if [ -z "${MYNAME#gosher}" ]; then @@ -30,8 +43,15 @@ if [ -z "${MYNAME#gosher}" ]; then PORT=${1:-70} GOPHERDIR=${2:-"./"} + trap cleanup 0 HUP INT TRAP TERM QUIT + while [ 1 -eq 1 ]; do - netcat -vv -k -l -p ${PORT} -c "./gosher_serve ${GOPHERDIR}" + OUTF=${OPREFIX}$$ + INF=${IPREFIX}$$ + mkfifo -m 600 $OUTF $INF + ./gosher_serve ${GOPHERDIR} <$INF >$OUTF & + ${NETCAT} -vv -l -p ${PORT} >$INF <$OUTF + rm $OUTF $INF ret=$? done exit 0 |