diff options
author | KatolaZ <katolaz@freaknet.org> | 2018-08-14 07:01:14 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2018-08-14 07:01:14 +0100 |
commit | e8292927e355e6d5499ff5691482923ffc576202 (patch) | |
tree | 21cb23c1751e823d0c66456b62315dfa7c44df9d | |
parent | 02f1dc94fdad9b09db9cd4f40d8bf3ce02142da2 (diff) |
-rwxr-xr-x | gosher | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -51,7 +51,7 @@ NETCAT="nc" ## ## NETCAT_OPTS: any additional options to netcat ## -NETCAT_OPTS="" +NETCAT_OPTS="-v" ## ## STYLE: The way in which netcat will talk to gosher_serve @@ -94,20 +94,36 @@ if [ -z "${MYNAME#gosher}" ]; then echo "Wrong NETCAT -- Exiting" >&2 exit 2 } + is_openbsd=$(echo "${NETCAT}" | grep -i "certfile") if [ -f "${MYDIR}/gosher_serve" ] || [ -h "${MYDIR}/gosher_serve" ]; then GOSHER_SERVE="${MYDIR}/gosher_serve" trap cleanup 0 HUP INT TRAP TERM QUIT INF="${IPREFIX}$$" - [ "$STYLE" = "pipe" ] && { + [ "$STYLE" = "pipe" -a -n "${is_openbsd}" ] && { + echo "Genuine OpenBSD nc detected" >&2 mkfifo -m 600 "$INF" # shellcheck disable=SC2050 while :; do # shellcheck disable=SC2094 ${GOSHER_SERVE} "${GOPHERDIR}" \ "${HOSTNAME}" "${PORT}" <"$INF" |\ - ${NETCAT} -vvvvv -l "${HOSTNAME}" "${PORT}" >"$INF" + ${NETCAT} ${NETCAT_OPTS} -l "${HOSTNAME}" "${PORT}" >"$INF" + sleep 1 + done + rm -f $INF + exit 0 + } + [ "$STYLE" = "pipe" -a -z "${is_openbsd}" ] && { + echo "Other nc implementation detected" >&2 + mkfifo -m 600 "$INF" +# shellcheck disable=SC2050 + while :; do +# shellcheck disable=SC2094 + ${GOSHER_SERVE} "${GOPHERDIR}" \ + "${HOSTNAME}" "${PORT}" <"$INF" |\ + ${NETCAT} ${NETCAT_OPTS} -l -p "${PORT}" >"$INF" sleep 1 done rm -f $INF @@ -116,7 +132,7 @@ if [ -z "${MYNAME#gosher}" ]; then [ "$STYLE" = 'fork' ] && { # shellcheck disable=SC2050 while :; do - ${NETCAT} -vv -l -p "$PORT" -c \ + ${NETCAT} ${NETCAT_OPTS} -l -p "$PORT" -c \ "${GOSHER_SERVE} ${GOPHERDIR} ${HOSTNAME} ${PORT}" sleep 1 done |