aboutsummaryrefslogtreecommitdiff
path: root/lib/_ak_network_yggdrasil
diff options
context:
space:
mode:
Diffstat (limited to 'lib/_ak_network_yggdrasil')
-rwxr-xr-xlib/_ak_network_yggdrasil19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/_ak_network_yggdrasil b/lib/_ak_network_yggdrasil
index 6e3b796..5620fae 100755
--- a/lib/_ak_network_yggdrasil
+++ b/lib/_ak_network_yggdrasil
@@ -17,8 +17,9 @@
### You should have received a copy of the GNU General Public License
### along with this program. If not, see <http://www.gnu.org/licenses/>.
###
-source $AK_LIBDIR/_ak_log
-source $AK_LIBDIR/_ak_utils
+source $AK_LIBDIR/_ak_lib_load
+_ak_lib_load _ak_log
+_ak_lib_load _ak_datetime
function _ak_network_yggdrasil_scan_full(){
# This scan is using HIA resources to scan the whole cjdns network for peers
@@ -70,8 +71,12 @@ function _ak_network_yggdrasil_scan_full(){
if [ ! -d ${node_fs_path} ]
then
mkdir -p ${node_fs_path}
+ echo ${scan_ts} > ${node_fs_path}/first_seen
+ echo ${scan_ts} > ${node_fs_path}/last_seen
+ else
+ echo ${scan_ts} > ${node_fs_path}/last_seen
fi
- node_fs_pathname="${node_fs_path}/${scan_ts}"
+ node_fs_pathname="${node_fs_path}/${scan_ts}_node_info"
curl \
--connect-timeout 3 \
-A 'akd/0.1.0; https://github.com/arching-kaos' \
@@ -79,6 +84,12 @@ function _ak_network_yggdrasil_scan_full(){
node_info="$(cat ${node_fs_pathname})"
if [ $? -eq 0 ] && [ $(echo -n "$node_info" | wc -c) -gt 0 ]
then
+ ni_hash="$(echo -n "${node_info}" | sha512sum | cut -d ' ' -f 1)"
+ if [ ! -f "${node_fs_path}/${ni_hash}" ]
+ then
+ mv ${node_fs_pathname} ${node_fs_path}/${ni_hash}
+ echo "${scan_ts} ${ni_hash}" >> ${node_fs_path}/db
+ fi
if [ "$counter" -ne "0" ]
then
printf ',' >> walk.aknet
@@ -90,6 +101,8 @@ function _ak_network_yggdrasil_scan_full(){
printf '{"yggdrasil":{"public_key":"%s","ip":"%s"},"node_info":%s}' \
"$pkey" "$ip" "$node_info" >> walk.aknet
counter="`expr $counter + 1`"
+ else
+ rm ${node_fs_pathname}
fi
done
printf ']' >> walk.aknet