aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/_ak_checks3
-rwxr-xr-xlib/_ak_cjdns5
-rwxr-xr-xlib/_ak_config10
-rwxr-xr-xlib/_ak_datetime (renamed from lib/_ak_utils)3
-rwxr-xr-xlib/_ak_fm4
-rwxr-xr-xlib/_ak_fs13
-rwxr-xr-xlib/_ak_gpg43
-rwxr-xr-xlib/_ak_hash_exchange6
-rwxr-xr-xlib/_ak_html3
-rwxr-xr-xlib/_ak_ipfs20
-rwxr-xr-xlib/_ak_irc8
-rwxr-xr-xlib/_ak_lib_load32
-rwxr-xr-xlib/_ak_log29
-rwxr-xr-xlib/_ak_maintainance3
-rwxr-xr-xlib/_ak_network13
-rwxr-xr-xlib/_ak_network_cjdns3
-rwxr-xr-xlib/_ak_network_incoming101
-rwxr-xr-xlib/_ak_network_ipfs9
-rwxr-xr-xlib/_ak_network_stellar7
-rwxr-xr-xlib/_ak_network_utils5
-rwxr-xr-xlib/_ak_network_yggdrasil19
-rwxr-xr-xlib/_ak_node6
-rwxr-xr-xlib/_ak_ns364
-rwxr-xr-xlib/_ak_pkg12
-rwxr-xr-xlib/_ak_sblock4
-rwxr-xr-xlib/_ak_script27
-rwxr-xr-xlib/_ak_settings7
-rwxr-xr-xlib/_ak_sh4
-rwxr-xr-xlib/_ak_smfiles3
-rwxr-xr-xlib/_ak_yggdrasil6
-rwxr-xr-xlib/_ak_zblock15
-rwxr-xr-xlib/_ak_zchain11
32 files changed, 665 insertions, 133 deletions
diff --git a/lib/_ak_checks b/lib/_ak_checks
index 90b01ad..97b3d8a 100755
--- a/lib/_ak_checks
+++ b/lib/_ak_checks
@@ -17,7 +17,8 @@
### 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_lib_load
+_ak_lib_load _ak_log
function _ak_checks_example_check_for_base64_strings(){
diff --git a/lib/_ak_cjdns b/lib/_ak_cjdns
index 76b39db..51832d3 100755
--- a/lib/_ak_cjdns
+++ b/lib/_ak_cjdns
@@ -17,9 +17,10 @@
### 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_lib_load
+_ak_lib_load _ak_log
+_ak_lib_load _ak_network
-source $AK_LIBDIR/_ak_log
-source $AK_LIBDIR/_ak_network
rust_sh_install_url="https://sh.rustup.rs"
cjdns_src_git_repo_url="https://github.com/cjdelisle/cjdns"
cjdnstoolspath="$HOME/cjdns/tools"
diff --git a/lib/_ak_config b/lib/_ak_config
index 25a9563..085d79f 100755
--- a/lib/_ak_config
+++ b/lib/_ak_config
@@ -17,10 +17,14 @@
### 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_node
+source $AK_LIBDIR/_ak_lib_load
+_ak_lib_load _ak_node
+_ak_lib_load _ak_fs
function _ak_config_show(){
# We will be using our public key also to put it in the block later
+ tempdir="$(_ak_make_temp_directory)"
+ cd $tempdir
KEY="self.pub"
ak-gpg --export-key-self-to-file
_ak_log_debug "$KEY"
@@ -31,6 +35,7 @@ function _ak_config_show(){
{
"profile":'$profile',
"genesis":"'$(cat $AK_WORKDIR/config/zgenesis)'",
+ "keymaps":'$(ak gpg -l 2>/dev/null | while read line; do ak gpg --export-key $line $line && ak fs --add $line | sed -e 's/.*/{"fingerprint":"'$line'","map":"&"},/' ; done | tr -d '\n'|sed 's/^/[/;s/,$/],/')'
"gpg":{
"ipfs":"'$GPG_PUB_KEY'",
"fingerprint":"'$(ak gpg --get-key-fingerprint-from-ipfs $GPG_PUB_KEY)'"
@@ -38,10 +43,13 @@ function _ak_config_show(){
"zchain":"'$(cat $AK_WORKDIR/config/zchain)'",
"zlatest":"'$(ak zchain --get-latest)'"
}'| jq;
+ cd
+ rm -rf $tempdir
}
function _ak_config_publish(){
_ak_config_show | jq -c -M > tmpfile
+ akfs_map_v3="$(_ak_fs_import tmpfile)"
ipfs_hash="$(_ak_ipfs_add tmpfile)"
_ak_ipfs_config_publish $ipfs_hash
if [ $? != 0 ]
diff --git a/lib/_ak_utils b/lib/_ak_datetime
index 571fff4..a25696f 100755
--- a/lib/_ak_utils
+++ b/lib/_ak_datetime
@@ -17,6 +17,7 @@
### You should have received a copy of the GNU General Public License
### along with this program. If not, see <http://www.gnu.org/licenses/>.
###
+
function _ak_datetime_unix(){
date -u +%s | tr -d '\n'
}
@@ -43,5 +44,3 @@ function _ak_datetime_unix_to_human(){
date --date=@$1 +%Y%m%d_%H%M%S 2>/dev/null || date -r $1 +%Y%m%d_%H%M%S 2>/dev/null
fi
}
-
-_ak_log_debug "_ak_utils loaded $(caller)"
diff --git a/lib/_ak_fm b/lib/_ak_fm
index d77cac7..5971a88 100755
--- a/lib/_ak_fm
+++ b/lib/_ak_fm
@@ -18,7 +18,9 @@
### along with this program. If not, see <http://www.gnu.org/licenses/>.
###
-source $AK_LIBDIR/_ak_script
+source $AK_LIBDIR/_ak_lib_load
+_ak_lib_load _ak_log
+_ak_lib_load _ak_script
function _ak_fm_remove_line_from_file(){
tempfile="$(_ak_make_temp_file)"
diff --git a/lib/_ak_fs b/lib/_ak_fs
index 9bf7022..07929b6 100755
--- a/lib/_ak_fs
+++ b/lib/_ak_fs
@@ -18,8 +18,9 @@
### along with this program. If not, see <http://www.gnu.org/licenses/>.
###
-source $AK_LIBDIR/_ak_log
-source $AK_LIBDIR/_ak_hash_exchange
+source $AK_LIBDIR/_ak_lib_load
+_ak_lib_load _ak_log
+_ak_lib_load _ak_hash_exchange
function _ak_fs_dir_init_setup(){
_ak_check_and_create_dir $AK_MAPSDIR
@@ -111,6 +112,14 @@ function _ak_fs_import(){
#
_ak_log_info "Storing original hash of $1 along with its name"
sha512sum "$1" > $TEMPDIR/3rd_gen_map
+ hashgrep="$(grep -rn $(cat $TEMPDIR/3rd_gen_map | cut -d ' ' -f 1) $AK_MAPSDIR)"
+ if [ $? -eq 0 ]
+ then
+ map="$(basename $( echo $hashgrep | cut -d ':' -f 1 ))"
+ _ak_log_error "File $1 found @ $map"
+ echo $map
+ exit 0
+ fi
_ak_log_info "Encoding to base64"
base64 $1 > file
FILE="file"
diff --git a/lib/_ak_gpg b/lib/_ak_gpg
index edfc1d7..8f014f8 100755
--- a/lib/_ak_gpg
+++ b/lib/_ak_gpg
@@ -17,10 +17,11 @@
### 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_ipfs
-source $AK_LIBDIR/_ak_config
-source $AK_LIBDIR/_ak_settings
+source $AK_LIBDIR/_ak_lib_load
+_ak_lib_load _ak_log
+_ak_lib_load _ak_ipfs
+_ak_lib_load _ak_config
+_ak_lib_load _ak_settings
export AK_FINGERPRINT="$(_ak_settings_get gpg.fingerprint)"
@@ -133,6 +134,15 @@ function _ak_gpg_sign_clear(){
fi
}
+function _ak_gpg_sign_clear_with_key(){
+ if [ ! -z $1 ] && [ -n "$1" ] && [ ! -z $2 ] && [ -n "$2" ] && [ ! -z $3 ] && [ -n "$3" ]
+ then
+ _ak_gpg --clear-sign --sign-with $3 --armor --output $1 $2
+ else
+ exit 1
+ fi
+}
+
function _ak_gpg_encrypt_sign(){
if [ ! -z $1 ] && [ -n "$1" ] && [ ! -z $2 ] && [ -n "$2" ] && [ ! -z $3 ] && [ -n "$3" ]
then
@@ -196,10 +206,19 @@ function _ak_gpg_verify_signature(){
fi
}
+function _ak_gpg_key_export(){
+ if [ ! -z $1 ] && [ -n "$1" ] && [ ! -z $2 ] && [ -n "$2" ]
+ then
+ _ak_gpg --armour --output $2 --export $1
+ else
+ exit 1
+ fi
+}
+
function _ak_gpg_key_self_export(){
if [ ! -z $1 ] && [ -n "$1" ]
then
- _ak_gpg --armour --output $1 --export $AK_FINGERPRINT
+ _ak_gpg_key_export $AK_FINGERPRINT $1
else
exit 1
fi
@@ -243,6 +262,20 @@ function _ak_gpg_list_secret_keys_long(){
uniq
}
+function _ak_gpg_select_key_to_export(){
+ select x in $(_ak_gpg_list_secret_keys | tr '\n' ' ')
+ do
+ if [ -n "$x" ]
+ then
+ _ak_log_info "$x was selected"
+ _ak_gpg_key_export "$x" "$x.asc"
+ break
+ else
+ _ak_log_warning "You didn't select a key"
+ fi
+ done
+}
+
function _ak_gpg_select_key(){
select x in $(_ak_gpg_list_secret_keys | tr '\n' ' ')
do
diff --git a/lib/_ak_hash_exchange b/lib/_ak_hash_exchange
index e2ce310..3751a8e 100755
--- a/lib/_ak_hash_exchange
+++ b/lib/_ak_hash_exchange
@@ -17,8 +17,10 @@
### 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_fm
+source $AK_LIBDIR/_ak_lib_load
+_ak_lib_load _ak_log
+_ak_lib_load _ak_fm
+
AK_TREEFS="$AK_WORKDIR/tree"
AK_SESSIONSDIR="$AK_WORKDIR/sessions"
diff --git a/lib/_ak_html b/lib/_ak_html
index c9a898d..281790e 100755
--- a/lib/_ak_html
+++ b/lib/_ak_html
@@ -17,7 +17,8 @@
### 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_lib_load
+_ak_lib_load _ak_log
function _ak_generate_html_header(){
printf '<!DOCTYPE html>\n<html>\n<head>\n'
diff --git a/lib/_ak_ipfs b/lib/_ak_ipfs
index e30c1e1..16397a7 100755
--- a/lib/_ak_ipfs
+++ b/lib/_ak_ipfs
@@ -17,13 +17,20 @@
### 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_lib_load
+_ak_lib_load _ak_log
+
AK_IPFS_REPO="$AK_WORKDIR/ipfsrepo"
AK_IPFS_ARTIFACTS="$AK_WORKDIR/ipfs_artifacts"
+AK_IPNS_ARTIFACTS="$AK_WORKDIR/ipns_artifacts"
if [ ! -d $AK_IPFS_ARTIFACTS ]
then
mkdir -p $AK_IPFS_ARTIFACTS
fi
+if [ ! -d $AK_IPNS_ARTIFACTS ]
+then
+ mkdir -p $AK_IPNS_ARTIFACTS
+fi
function _ak_ipfs(){
export IPFS_PATH=$AK_IPFS_REPO; kubo $*
@@ -314,12 +321,17 @@ function _ak_ipfs_name_publish(){
_ak_log_error "No argument given"
exit 1
fi
- _ak_ipfs name publish --key="$1" "$2"
+ key="$(_ak_ipfs key list -l | grep $1 | cut -d ' ' -f 1)"
if [ $? -ne 0 ]
then
_ak_log_error "Failed to get $1"
exit 1
fi
+ if [ -f "$AK_IPNS_ARTIFACTS/$key" ]
+ then
+ cat $AK_IPNS_ARTIFACTS/$key >> $AK_IPNS_ARTIFACTS/$key.history
+ fi
+ echo $2 > $AK_IPNS_ARTIFACTS/$key
}
function _ak_ipfs_config_publish(){
@@ -338,12 +350,12 @@ function _ak_ipfs_name_resolve(){
_ak_log_error "No argument given"
exit 1
fi
- _ak_ipfs name resolve "$1"
- if [ $? -ne 0 ]
+ if [ ! -f $AK_IPNS_ARTIFACTS/$1 ]
then
_ak_log_error "Failed to resolve $1"
exit 1
fi
+ cat $AK_IPNS_ARTIFACTS/$1
}
function _ak_ipfs_swarm_peers(){
diff --git a/lib/_ak_irc b/lib/_ak_irc
index 25d3f10..85e8bc7 100755
--- a/lib/_ak_irc
+++ b/lib/_ak_irc
@@ -1,10 +1,10 @@
#!/usr/bin/env bash
-
-source $AK_LIBDIR/_ak_log
-source $AK_LIBDIR/_ak_script
+source $AK_LIBDIR/_ak_lib_load
+_ak_lib_load _ak_log
+_ak_lib_load _ak_script
function _ak_irc_connect(){
- _ak_not_implemented "LOL"
+ _ak_not_implemented "${FUNCNAME}"
}
_ak_log_debug "_ak_irc loaded $(caller)"
diff --git a/lib/_ak_lib_load b/lib/_ak_lib_load
new file mode 100755
index 0000000..2790458
--- /dev/null
+++ b/lib/_ak_lib_load
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+###
+### arching-kaos-tools
+### Tools to interact and build an Arching Kaos Infochain
+### Copyright (C) 2021 - 2025 kaotisk
+###
+### This program is free software: you can redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation, either version 3 of the License, or
+### (at your option) any later version.
+###
+### This program is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with this program. If not, see <http://www.gnu.org/licenses/>.
+###
+
+function _ak_lib_load(){
+ typeset -F | grep $1 2>/dev/null 1>&2 || if [ -f "$AK_LIBDIR/$1" ]
+ then
+ source $AK_LIBDIR/$1
+ elif [ -f "./lib/$1" ]
+ then
+ source ./lib/$1
+ else
+ printf "Error: Could not load $1 lib"
+ fi
+
+}
diff --git a/lib/_ak_log b/lib/_ak_log
index b547c4d..d28e663 100755
--- a/lib/_ak_log
+++ b/lib/_ak_log
@@ -18,7 +18,8 @@
### along with this program. If not, see <http://www.gnu.org/licenses/>.
###
-source $AK_LIBDIR/_ak_utils 2>/dev/null || source ./lib/_ak_utils 2>/dev/null
+source ./lib/_ak_lib_load 2>/dev/null || source $AK_LIBDIR/_ak_lib_load 2>/dev/null
+_ak_lib_load _ak_datetime
export AK_LOGSDIR="$AK_WORKDIR/logs"
export AK_LOGSFILE="$AK_LOGSDIR/log"
@@ -74,6 +75,21 @@ function _ak_log_print_log_line(){
fi
}
+function _ak_log_print_log_line_irc(){
+ if [ -n "$1" ]
+ then
+ timestamp="$(echo "$*" | awk '{print $1}')"
+ program="$(echo "$*" | awk '{print $2}')"
+ messagetype="$(echo "$*" | awk '{print $3}')"
+ message="$(echo "$*" | cut -d ' ' -f4-)"
+ printf '\x0300,01%s \x0303,01%s\x0300,01 \x0304,01%s\x0300,01 %s\x0301,00\n' \
+ "$(_ak_datetime_unix_to_human $timestamp)" \
+ "$program" \
+ "$messagetype" \
+ "$message"
+ fi
+}
+
function _ak_log_follow(){
tail -f $AK_LOGSFILE | while read -r p || [ -n "$p" ]
do
@@ -81,6 +97,11 @@ function _ak_log_follow(){
done
}
+function _ak_log_last_line(){
+ p="$(tail -n 1 $AK_LOGSFILE | tr -d '\n')"
+ _ak_log_print_log_line "$p"
+}
+
function _ak_log_grep(){
if [ ! -z $1 ] && [ -n "$1" ]
then
@@ -138,6 +159,10 @@ function _ak_log_message(){
then
_ak_log_print_log_line "$TS <$prg> [$tp] $msg" >&2
fi
+ if [ ! -z $AK_DEBUG_IRC ] && [ -n "$AK_DEBUG_IRC" ] && [ "$AK_DEBUG_IRC" == "yes" ]
+ then
+ _ak_log_print_log_line_irc "$TS <$prg> [$tp] $msg" >&2
+ fi
else
echo "$TS" "<$prg>" "[ERROR]" "No message" >> $AK_LOGSFILE
if [ "$AK_DEBUG" == "yes" ]
@@ -190,5 +215,5 @@ function _ak_log_info(){
_ak_log_message "$PROGRAM" "INFO" "$*"
}
-_ak_log_debug "_ak_log loaded $(caller)"
+# _ak_log_debug "_ak_log loaded $(caller)"
# vim: set syntax=bash
diff --git a/lib/_ak_maintainance b/lib/_ak_maintainance
index bd7441b..ab8d9da 100755
--- a/lib/_ak_maintainance
+++ b/lib/_ak_maintainance
@@ -17,7 +17,8 @@
### 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_lib_load
+_ak_lib_load _ak_log
function _ak_maintainance_backup(){
if [ -n "${AK_WORKDIR}" ] && [ -d "${AK_WORKDIR}" ]
diff --git a/lib/_ak_network b/lib/_ak_network
index 442bf90..c6d048e 100755
--- a/lib/_ak_network
+++ b/lib/_ak_network
@@ -17,12 +17,13 @@
### 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_network_ipfs
-source $AK_LIBDIR/_ak_network_cjdns
-source $AK_LIBDIR/_ak_network_yggdrasil
-source $AK_LIBDIR/_ak_network_stellar
-source $AK_LIBDIR/_ak_network_incoming
+source $AK_LIBDIR/_ak_lib_load
+_ak_lib_load _ak_log
+_ak_lib_load _ak_network_ipfs
+_ak_lib_load _ak_network_cjdns
+_ak_lib_load _ak_network_yggdrasil
+_ak_lib_load _ak_network_stellar
+_ak_lib_load _ak_network_incoming
function _ak_network_scan(){
if [ ! -z $1 ] && [ -n "$1" ]
diff --git a/lib/_ak_network_cjdns b/lib/_ak_network_cjdns
index 9f385f9..9a75690 100755
--- a/lib/_ak_network_cjdns
+++ b/lib/_ak_network_cjdns
@@ -17,7 +17,8 @@
### 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_lib_load
+_ak_lib_load _ak_log
cjdnstoolspath="$HOME/cjdns/tools"
diff --git a/lib/_ak_network_incoming b/lib/_ak_network_incoming
index 39eb67f..cf8920d 100755
--- a/lib/_ak_network_incoming
+++ b/lib/_ak_network_incoming
@@ -17,10 +17,11 @@
### 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_network_utils
-source $AK_LIBDIR/_ak_fm
+source $AK_LIBDIR/_ak_lib_load
+_ak_lib_load _ak_log
+_ak_lib_load _ak_datetime
+_ak_lib_load _ak_network_utils
+_ak_lib_load _ak_fm
export AK_ZPEERSINCOMING=$AK_ZPEERSDIR/incomingRequests
@@ -40,54 +41,58 @@ function _ak_network_incoming_show_peers(){
function _ak_network_incoming_scan(){
if [ -f "${AK_ZPEERSINCOMING}" ]
then
- if [ $(cat ${AK_ZPEERSINCOMING}|wc -l) -gt 0 ]
- then
- counter=0
- count=0
- _ak_fm_sort_uniq_file ${AK_ZPEERSINCOMING}
- max="$(cat ${AK_ZPEERSINCOMING}|wc -l)"
- printf '[' > walk.aknet
- cat ${AK_ZPEERSINCOMING} \
- | sort \
- | uniq \
- | while read -r uip || [ -n "$uip" ]
- do
- ip="$(_ak_network_utils_pad_ip $uip)"
- count="$(( $count + 1 ))"
- _ak_log_debug "Scanning [${count}/${max}] $ip..."
- node_fs_path="$AK_ZPEERSDIR/inc/$(echo -n $ip| sed 's/://g')"
- scan_ts="$(_ak_datetime_unix)"
- if [ ! -d ${node_fs_path} ]
- then
- mkdir -p ${node_fs_path}
- fi
- node_fs_pathname="${node_fs_path}/${scan_ts}"
- curl \
- --connect-timeout 3 \
- -A 'akd/0.1.0; https://github.com/arching-kaos' \
- "http://[$ip]:8610/v0/node_info" 2>/dev/null | jq -c -M > ${node_fs_pathname}
- node_info="$(cat ${node_fs_pathname})"
- if [ $? -eq 0 ] && [ $(echo -n "$node_info" | wc -c) -gt 0 ]
- then
- if [ "$counter" -ne "0" ]
+ if [ $(cat ${AK_ZPEERSINCOMING}|wc -l) -gt 0 ]
+ then
+ counter=0
+ count=0
+ _ak_fm_sort_uniq_file ${AK_ZPEERSINCOMING}
+ max="$(cat ${AK_ZPEERSINCOMING}|grep -v '\.'|wc -l)"
+ printf '[' > walk.aknet
+ cat ${AK_ZPEERSINCOMING} \
+ | grep -v '\.' \
+ | sort \
+ | uniq \
+ | while read -r uip || [ -n "$uip" ]
+ do
+ ip="$(_ak_network_utils_pad_ip $uip)"
+ count="$(( $count + 1 ))"
+ _ak_log_debug "Scanning [${count}/${max}] $ip..."
+ node_fs_path="$AK_ZPEERSDIR/inc/$(echo -n $ip| sed 's/://g')"
+ scan_ts="$(_ak_datetime_unix)"
+ if [ ! -d ${node_fs_path} ]
then
- printf ',' >> walk.aknet
+ _ak_log_info "New peer: $ip..."
+ mkdir -p ${node_fs_path}
fi
- if [ ! -n "$node_info" ]
+ node_fs_pathname="${node_fs_path}/${scan_ts}"
+ _ak_log_info "Requesting peer's node info: $ip..."
+ curl \
+ --connect-timeout 3 \
+ -A 'akd/0.1.0; https://github.com/arching-kaos' \
+ "http://[$ip]:8610/v0/node_info" 2>/dev/null | jq -c -M > ${node_fs_pathname}
+ node_info="$(cat ${node_fs_pathname})"
+ if [ $? -eq 0 ] && [ $(echo -n "$node_info" | wc -c) -gt 0 ]
then
- node_info="null"
+ _ak_log_info "Appending: $ip..."
+ if [ "$counter" -ne "0" ]
+ then
+ printf ',' >> walk.aknet
+ fi
+ if [ ! -n "$node_info" ]
+ then
+ node_info="null"
+ fi
+ printf '{"incoming":{"ip":"%s"},"node_info":%s}' \
+ "$ip" "$node_info" >> walk.aknet
+ counter="`expr $counter + 1`"
fi
- printf '{"incoming":{"ip":"%s"},"node_info":%s}' \
- "$ip" "$node_info" >> walk.aknet
- counter="`expr $counter + 1`"
- fi
- done
- printf ']' >> walk.aknet
- mv walk.aknet $AK_ZPEERSFILE.incoming
- rm -rf $TEMPDIR
- else
- _ak_log_info "No incoming requests found."
- fi
+ done
+ printf ']' >> walk.aknet
+ mv walk.aknet $AK_ZPEERSFILE.incoming
+ rm -rf $TEMPDIR
+ else
+ _ak_log_info "No incoming requests found."
+ fi
fi
}
diff --git a/lib/_ak_network_ipfs b/lib/_ak_network_ipfs
index f666586..172794f 100755
--- a/lib/_ak_network_ipfs
+++ b/lib/_ak_network_ipfs
@@ -17,15 +17,16 @@
### 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_ipfs
+source $AK_LIBDIR/_ak_lib_load
+_ak_lib_load _ak_log
+_ak_lib_load _ak_ipfs
function _ak_network_ipfs_scan(){
- _ak_not_implemented _ak_network_ipfs_scan
+ _ak_not_implemented ${FUNCNAME}
}
function _ak_network_ipfs_show_peers(){
- _ak_not_implemented _ak_network_ipfs_show_peers
+ _ak_not_implemented ${FUNCNAME}
}
function _ak_network_ipfs_connect_bootstrap(){
diff --git a/lib/_ak_network_stellar b/lib/_ak_network_stellar
index cca8ff0..d4fffcf 100755
--- a/lib/_ak_network_stellar
+++ b/lib/_ak_network_stellar
@@ -17,9 +17,10 @@
### 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_ipfs
-source $AK_LIBDIR/_ak_script
+source $AK_LIBDIR/_ak_lib_load
+_ak_lib_load _ak_log
+_ak_lib_load _ak_script
+_ak_lib_load _ak_ipfs
stellarPeersDir="$AK_ZPEERSDIR/stellar"
_ak_check_and_create_dir $stellarPeersDir
diff --git a/lib/_ak_network_utils b/lib/_ak_network_utils
index 9f4b8ef..d3689fe 100755
--- a/lib/_ak_network_utils
+++ b/lib/_ak_network_utils
@@ -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
##
# Copied from http://y.yggdrasil-network.ca/yia/crawler/crawler-yia.sh made by
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
diff --git a/lib/_ak_node b/lib/_ak_node
index 71dec12..937ff84 100755
--- a/lib/_ak_node
+++ b/lib/_ak_node
@@ -17,12 +17,14 @@
### 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_ipfs
+source $AK_LIBDIR/_ak_lib_load
+_ak_lib_load _ak_log
+_ak_lib_load _ak_ipfs
# Resolves the IPNS key "ak-config" to its current IPFS value
# Return IPFS CIDv0 without /ipfs/ prefix
function _ak_node_info_ipfs_hash(){
- _ak_ipfs_name_resolve /ipns/$(_ak_node_info_ipns_key) | sed -e 's/\/ipfs\///'
+ _ak_ipfs_name_resolve $(_ak_node_info_ipns_key) | sed -e 's/\/ipfs\///'
}
# Finds ak-config ipns key
diff --git a/lib/_ak_ns b/lib/_ak_ns
new file mode 100755
index 0000000..24c0761
--- /dev/null
+++ b/lib/_ak_ns
@@ -0,0 +1,364 @@
+#!/usr/bin/env bash
+###
+### arching-kaos-tools
+### Tools to interact and build an Arching Kaos Infochain
+### Copyright (C) 2021 - 2025 kaotisk
+###
+### This program is free software: you can redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation, either version 3 of the License, or
+### (at your option) any later version.
+###
+### This program is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with this program. If not, see <http://ww