aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2025-07-14 22:30:27 +0300
committerkaotisk <kaotisk@arching-kaos.org>2025-07-14 22:30:27 +0300
commitcd464e1508df4f136ce3272231eeb623f47cd578 (patch)
treec86563c96402729c547c22d8e1fe7bfb7638d65b /lib
parentbe4166b3a06ab5bf32f020b6d764288ad3a3c2da (diff)
downloadarching-kaos-tools-cd464e1508df4f136ce3272231eeb623f47cd578.tar.gz
arching-kaos-tools-cd464e1508df4f136ce3272231eeb623f47cd578.tar.bz2
arching-kaos-tools-cd464e1508df4f136ce3272231eeb623f47cd578.zip
Improvement: Compacts the way of storing yggdrasil scans
Diffstat (limited to 'lib')
-rwxr-xr-xlib/_ak_network_yggdrasil14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/_ak_network_yggdrasil b/lib/_ak_network_yggdrasil
index afabe70..5620fae 100755
--- a/lib/_ak_network_yggdrasil
+++ b/lib/_ak_network_yggdrasil
@@ -71,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' \
@@ -80,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
@@ -91,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