From f1840729881fee95685cc8359434e9e8ffa99206 Mon Sep 17 00:00:00 2001 From: epoch Date: Thu, 2 Apr 2020 08:05:04 +0000 Subject: added caching to the map --- share/hackvr/examples/anonet_map/map | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'share') diff --git a/share/hackvr/examples/anonet_map/map b/share/hackvr/examples/anonet_map/map index 13279ab..e983590 100755 --- a/share/hackvr/examples/anonet_map/map +++ b/share/hackvr/examples/anonet_map/map @@ -1,5 +1,18 @@ #!/bin/bash -paths="$(ncat --recv-only 21.41.41.1 64777 | sort | uniq)" +paths="$(ncat --recv-only 21.41.41.1 64777 | sort | uniq | tee /var/cache/hackvr/anonet_data.new)" + +MAP=/var/cache/hackvr/anonet_map.hackvr + +#see if the data actually changed before regenerating this shit... +if cmp /var/cache/hackvr/anonet_data.new /var/cache/hackvr/anonet_data.old ; then + cat $MAP + exit 0 +fi + +mv /var/cache/hackvr/anonet_data.new /var/cache/hackvr/anonet_data.old + +> $MAP + nodes=$(printf "%s\n" "$paths" | tr ' ' '\n' | sort | uniq) nodes_count="$(printf "%s\n" "$nodes" | tr ' ' '\n' | wc -l | tr -cd '0-9')" #echo $nodes @@ -45,11 +58,11 @@ for node in $nodes;do printf "