From f9fe15e6a2ea74e523e51e9542df1bf00b23ce7c Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Tue, 28 Aug 2018 12:10:22 +0100 Subject: avoid self-loops and cgi traps --- burrow | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/burrow b/burrow index 9335ba8..87b4e79 100755 --- a/burrow +++ b/burrow @@ -22,14 +22,26 @@ ### ## function get_dirs(){ - src_id="$1" + src_type=$(echo "$1" | cut -d "|" -f 1) + src_sel=$(echo "$1" | cut -d "|" -f 2 | cut -d "?" -f 1) + src_host=$(echo "$1" | cut -d "|" -f 3) + src_port=$(echo "$1" | cut -d "|" -f 4) + src_id=$(echo "$1" | cut -d "|" -f 5) + ##echo "src_sel: \"${src_sel}\"" >&2 OLDIFS=$IFS #IFS=$'\t\n' IFS="|" src_dir=$(echo "${src_id}" | cut -c -2) touch "${src_dir}/${src_id}" while read name sel host port; do + ##echo "sel: \"$sel\"" >&2 + [ "$sel" = "Err" -o -z "$sel" ] && continue TYPE=$(echo "$name" | cut -c 1) + [ "$TYPE" = "i" ] && continue + dst_sel=$(echo "$sel" | cut -d "?" -f 1) + ##echo "dst_sel: \"${dst_sel}\"" >&2 + [ "${dst_sel}" = "${src_sel}" -a "${src_type}" = "$TYPE" \ + -a "${src_host}" = "$host" -a "${src_port}" = "$port" ] && continue; port=$(echo $port | sed -r -e 's/\r//g') dir_id=$(echo "${TYPE}|${sel}|${host}|${port}" | sed 's/^1||/1|\/|/g') dest_id=$(echo "${dir_id}" | sha256sum | cut -d " " -f 1 ) @@ -91,6 +103,6 @@ echo "selector ${src_id} not found" >> logfile.txt MYNAME=$(basename $0) if [ -z "${MYNAME##burrow}" ]; then - retrieve_selector "$SRC" | sed -r -e 's/\t/|/g' | get_dirs "${src_id}" + retrieve_selector "$SRC" | sed -r -e 's/\t/|/g' | get_dirs "$SRC" fi -- cgit v1.2.3