diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/_ak_checks | 4 | ||||
-rwxr-xr-x | lib/_ak_cjdns | 7 | ||||
-rwxr-xr-x | lib/_ak_coin | 2 | ||||
-rwxr-xr-x | lib/_ak_config | 4 | ||||
-rwxr-xr-x | lib/_ak_datetime (renamed from lib/_ak_utils) | 1 | ||||
-rwxr-xr-x | lib/_ak_fm | 6 | ||||
-rwxr-xr-x | lib/_ak_fs | 7 | ||||
-rwxr-xr-x | lib/_ak_gpg | 20 | ||||
-rwxr-xr-x | lib/_ak_hash_exchange | 8 | ||||
-rwxr-xr-x | lib/_ak_html | 5 | ||||
-rwxr-xr-x | lib/_ak_ipfs | 12 | ||||
-rwxr-xr-x | lib/_ak_irc | 10 | ||||
-rwxr-xr-x | lib/_ak_lib_load | 32 | ||||
-rwxr-xr-x | lib/_ak_log | 9 | ||||
-rwxr-xr-x | lib/_ak_maintainance | 5 | ||||
-rwxr-xr-x | lib/_ak_network | 18 | ||||
-rwxr-xr-x | lib/_ak_network_cjdns | 5 | ||||
-rwxr-xr-x | lib/_ak_network_incoming | 95 | ||||
-rwxr-xr-x | lib/_ak_network_ipfs | 11 | ||||
-rwxr-xr-x | lib/_ak_network_stellar | 50 | ||||
-rwxr-xr-x | lib/_ak_network_utils | 81 | ||||
-rwxr-xr-x | lib/_ak_network_yggdrasil | 7 | ||||
-rwxr-xr-x | lib/_ak_node | 6 | ||||
-rwxr-xr-x | lib/_ak_ns | 202 | ||||
-rwxr-xr-x | lib/_ak_pkg | 66 | ||||
-rwxr-xr-x | lib/_ak_sblock | 6 | ||||
-rwxr-xr-x | lib/_ak_schain | 2 | ||||
-rwxr-xr-x | lib/_ak_script | 5 | ||||
-rwxr-xr-x | lib/_ak_settings | 9 | ||||
-rwxr-xr-x | lib/_ak_sh | 6 | ||||
-rwxr-xr-x | lib/_ak_smfiles | 5 | ||||
-rwxr-xr-x | lib/_ak_wallet | 2 | ||||
-rwxr-xr-x | lib/_ak_yggdrasil | 8 | ||||
-rwxr-xr-x | lib/_ak_zblock | 17 | ||||
-rwxr-xr-x | lib/_ak_zchain | 15 |
35 files changed, 654 insertions, 94 deletions
diff --git a/lib/_ak_checks b/lib/_ak_checks index c08863e..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(){ @@ -41,3 +42,4 @@ function _ak_checks_example_check_for_base64_strings(){ fi } +_ak_log_debug "_ak_checks loaded $(caller)" diff --git a/lib/_ak_cjdns b/lib/_ak_cjdns index 69e5ffc..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" @@ -198,3 +199,5 @@ function _ak_cjdns_get_ip(){ awk '{print $2}' | \ cut -d'/' -f1 } + +_ak_log_debug "_ak_cjdns loaded $(caller)" diff --git a/lib/_ak_coin b/lib/_ak_coin index 4c58e2d..413d575 100755 --- a/lib/_ak_coin +++ b/lib/_ak_coin @@ -30,3 +30,5 @@ function _ak_coin_stats(){ echo "Coinbase: $COINBASE" echo "Genesis: $GENESIS" } + +_ak_log_debug "_ak_coin loaded $(caller)" diff --git a/lib/_ak_config b/lib/_ak_config index f8b1460..6c71e9c 100755 --- a/lib/_ak_config +++ b/lib/_ak_config @@ -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_node +source $AK_LIBDIR/_ak_lib_load +_ak_lib_load _ak_node function _ak_config_show(){ # We will be using our public key also to put it in the block later @@ -58,3 +59,4 @@ function _ak_config_published(){ _ak_ipfs_cat $(_ak_node_info_ipfs_hash) | jq } +_ak_log_debug "_ak_config loaded $(caller)" diff --git a/lib/_ak_utils b/lib/_ak_datetime index 98f6ca0..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' } @@ -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)" @@ -51,3 +53,5 @@ function _ak_fm_sort_uniq_file(){ _ak_log_info "Sorting $1... Done!" fi } + +_ak_log_debug "_ak_fm loaded $(caller)" @@ -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 @@ -759,3 +760,5 @@ function _ak_fs_net_cat_from_map_hash(){ _ak_fs_net_cat `_ak_fs_from_map_net_get_root_hash $1` `_ak_fs_from_map_net_get_original_hash $1` fi } + +_ak_log_debug "_ak_fs loaded $(caller)" diff --git a/lib/_ak_gpg b/lib/_ak_gpg index c8cc669..7832ca1 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 @@ -299,3 +309,5 @@ function _ak_gpg_delete_secret_key(){ fi fi } + +_ak_log_debug "_ak_gpg loaded $(caller)" diff --git a/lib/_ak_hash_exchange b/lib/_ak_hash_exchange index 2e39658..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" @@ -73,3 +75,5 @@ function _ak_he_url_request_map_hash_from_random_peer(){ _ak_he_url_request_map_hash_from_peer "$(_ak_he_select_random_peer)" "$1" fi } + +_ak_log_debug "_ak_he loaded $(caller)" diff --git a/lib/_ak_html b/lib/_ak_html index 491cb6c..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' @@ -305,3 +306,5 @@ function _ak_generate_html_zblock(){ printf ' </table>\n' fi } + +_ak_log_debug "_ak_html loaded $(caller)" diff --git a/lib/_ak_ipfs b/lib/_ak_ipfs index eb4ee31..07595ae 100755 --- a/lib/_ak_ipfs +++ b/lib/_ak_ipfs @@ -17,7 +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_lib_load +_ak_lib_load _ak_log + AK_IPFS_REPO="$AK_WORKDIR/ipfsrepo" AK_IPFS_ARTIFACTS="$AK_WORKDIR/ipfs_artifacts" if [ ! -d $AK_IPFS_ARTIFACTS ] @@ -116,7 +118,7 @@ function _ak_ipfs_scanner(){ function _ak_ipfs_add(){ if [ -z $1 ] || [ ! -n "$1" ] then - _ak_log_error "no argument given" + _ak_log_error "_ak_ipfs_add: no argument given" exit 1 fi # Receives a file @@ -132,7 +134,7 @@ function _ak_ipfs_add(){ function _ak_ipfs_block_stat(){ if [ -z $1 ] || [ ! -n "$1" ] then - _ak_log_error "no argument given" + _ak_log_error "_ak_ipfs_block_stat: no argument given" exit 1 fi _ak_ipfs block stat "$1" @@ -256,7 +258,7 @@ function _ak_ipfs_get(){ function _ak_ipfs_cat(){ if [ -z $1 ] || [ ! -n "$1" ] then - _ak_log_error "no argument given" + _ak_log_error "_ak_ipfs_cat: no argument given" exit 1 fi if [ ! -f $AK_IPFS_ARTIFACTS/$1 ] @@ -564,3 +566,5 @@ function _ak_ipfs_swarm_install(){ function _ak_ipfs_get_config_ipns_key(){ _ak_ipfs_key_list_full | grep 'ak-config' | cut -d ' ' -f 1 } + +_ak_log_debug "_ak_ipfs loaded $(caller)" diff --git a/lib/_ak_irc b/lib/_ak_irc index 17cfd83..85e8bc7 100755 --- a/lib/_ak_irc +++ b/lib/_ak_irc @@ -1,8 +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 c45794d..51064e7 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" @@ -81,6 +82,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 @@ -190,4 +196,5 @@ function _ak_log_info(){ _ak_log_message "$PROGRAM" "INFO" "$*" } +# _ak_log_debug "_ak_log loaded $(caller)" # vim: set syntax=bash diff --git a/lib/_ak_maintainance b/lib/_ak_maintainance index 030060e..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}" ] @@ -81,3 +82,5 @@ function _ak_maintainance_nuke_all_but_core(){ _ak_log_error "No AK_WORKDIR found or it does not exist" fi } + +_ak_log_debug "_ak_maintainance loaded $(caller)" diff --git a/lib/_ak_network b/lib/_ak_network index d23d913..c6d048e 100755 --- a/lib/_ak_network +++ b/lib/_ak_network @@ -17,11 +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_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" ] @@ -31,6 +33,7 @@ function _ak_network_scan(){ ipfs) _ak_network_ipfs_scan; exit;; cjdns) shift; _ak_network_cjdns_scan $1; exit;; yggdrasil) shift; _ak_network_yggdrasil_scan $1; exit;; + incoming) shift; _ak_network_incoming_scan; exit;; * ) _ak_log_error "Unknown network $1";exit 1;; esac else @@ -49,10 +52,11 @@ function _ak_network_show_peers(){ cjdns) _ak_network_cjdns_show_peers; exit;; ipfs) _ak_network_ipfs_show_peers; exit;; yggdrasil) _ak_network_yggdrasil_show_peers; exit;; + incoming) _ak_network_incoming_show_peers; exit;; * ) _ak_log_error "Unknown network $1";exit 1;; esac else - (_ak_network_stellar_show_peers; _ak_network_cjdns_show_peers; _ak_network_yggdrasil_show_peers; _ak_network_ipfs_show_peers) | \ + (_ak_network_stellar_show_peers; _ak_network_cjdns_show_peers; _ak_network_yggdrasil_show_peers; _ak_network_incoming_show_peers) | \ jq -j | \ sed -e 's/]\[/,/g' | \ jq @@ -72,3 +76,5 @@ function _ak_network_connect(){ _ak_network_ipfs_connect_bootstrap fi } + +_ak_log_debug "_ak_network loaded $(caller)" diff --git a/lib/_ak_network_cjdns b/lib/_ak_network_cjdns index 31c587b..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" @@ -212,3 +213,5 @@ function _ak_network_cjdns_connect(){ function _ak_network_cjdns_connect_bootstrap(){ _ak_network_cjdns_connect } + +_ak_log_debug "_ak_network_cjdns loaded $(caller)" diff --git a/lib/_ak_network_incoming b/lib/_ak_network_incoming new file mode 100755 index 0000000..12384a3 --- /dev/null +++ b/lib/_ak_network_incoming @@ -0,0 +1,95 @@ +#!/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/>. +### +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 + +function _ak_network_incoming_tidy(){ + exit 224 +} + +function _ak_network_incoming_show_peers(){ + if [ -f $AK_ZPEERSFILE.incoming ] + then + cat $AK_ZPEERSFILE.incoming | jq + else + _ak_log_debug "No incoming peers found" + fi +} + +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" ] + 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 + done + printf ']' >> walk.aknet + mv walk.aknet $AK_ZPEERSFILE.incoming + rm -rf $TEMPDIR + else + _ak_log_info "No incoming requests found." + fi + fi +} + +_ak_log_debug "_ak_network_incoming loaded $(caller)" diff --git a/lib/_ak_network_ipfs b/lib/_ak_network_ipfs index da52d12..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(){ @@ -34,3 +35,5 @@ function _ak_network_ipfs_connect_bootstrap(){ _ak_ipfs_swarm_connect "$peer" done } + +_ak_log_debug "_ak_network_ipfs loaded $(caller)" diff --git a/lib/_ak_network_stellar b/lib/_ak_network_stellar index 04ce29b..d4fffcf 100755 --- a/lib/_ak_network_stellar +++ b/lib/_ak_network_stellar @@ -17,8 +17,18 @@ ### 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_script +_ak_lib_load _ak_ipfs + +stellarPeersDir="$AK_ZPEERSDIR/stellar" +_ak_check_and_create_dir $stellarPeersDir + +stellarParticipants="$stellarPeersDir/trustlines" +_ak_let_there_be_file $stellarParticipants +stellarParticipantsOnline="$stellarPeersDir/configured.trustlines" +_ak_let_there_be_file $stellarParticipantsOnline function _ak_network_stellar_show_ids(){ i=0 @@ -73,24 +83,8 @@ function _ak_network_stellar_scan(){ tempdir=`_ak_make_temp_directory` tempfile="$tempdir/tmp" tempaddr="$tempdir/tmpaddr" - stellarParticipants="$AK_WORKDIR/stellar-network-participants" - stellarParticipantsOnline="$AK_WORKDIR/stellar-network-participants-online" - if [ ! -f "$stellarParticipants" ] - then - touch $stellarParticipants - fi - if [ ! -f "$stellarParticipantsOnline" ] - then - touch $stellarParticipantsOnline - fi - if [ ! -f "$tempdir" ] - then - touch $tempdir - fi - if [ ! -f "$tempaddr" ] - then - touch $tempaddr - fi + _ak_let_there_be_file $tempdir + _ak_let_there_be_file $tempaddr if [ ! -z $1 ] && [ "$1" == "-l" ] && [ ! -z $2 ] then limit=$2 @@ -135,8 +129,6 @@ function _ak_network_stellar_scan(){ } function _ak_network_stellar_show_peers(){ - stellarParticipants="$AK_WORKDIR/stellar-network-participants" - stellarParticipantsOnline="$AK_WORKDIR/stellar-network-participants-online" if [ -f "${stellarParticipantsOnline}" ] then ( @@ -150,10 +142,16 @@ function _ak_network_stellar_show_peers(){ fi counter=$(( $counter + 1 )) akConfigHash="$(_ak_ipfs_name_resolve /ipns/$akConfig|cut -d '/' -f 3)" - printf '{"stellar":{"address":"%s","config":"%s"},"node_info":%s}' \ + printf '{"stellar":{"address":"%s","config":"%s"}' \ "$stellarAddress" \ - "$akConfig" \ - "$(_ak_ipfs_cat $akConfigHash)" + "$akConfig" + if [ -n "$akConfigHash" ] + then + printf ',"node_info":%s}' \ + "$(_ak_ipfs_cat $akConfigHash)" + else + printf '}' + fi done printf ']' ) | sed -e 's/\[]//g' #| jq @@ -161,3 +159,5 @@ function _ak_network_stellar_show_peers(){ _ak_log_debug "No stellar peers found" fi } + +_ak_log_debug "_ak_network_stellar loaded $(caller)" diff --git a/lib/_ak_network_utils b/lib/_ak_network_utils new file mode 100755 index 0000000..d3689fe --- /dev/null +++ b/lib/_ak_network_utils @@ -0,0 +1,81 @@ +#!/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/>. +### +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 +# ircerr +# +# Changes: +# - name of function from padip to _ak_network_utils_pad_ip +# +function _ak_network_utils_pad_ip() { #Pad IP - fill in missing zeros + ip=$1 + if [ "$ip" == "" ]; then return; fi + PADIP="" + if [ "`echo \"$ip\"|grep '::'`" != "" ] + then + CC="$((`echo \"$ip\"|sed 's/:://g'|tr ':' '\n'|wc -l`))" #count cols + if [ "$CC" != "8" ] + then + NC=$((7-$CC)) + RS="" + for X in `seq 1 $NC` + do + if [ "$RS" == "" ] + then + RS="0000" + else + RS="$RS:0000" + fi + done + ip="`echo \"$ip\"|sed \"s/\:\:/\:$RS\:/g\"`" + fi + fi + SEGIP="`echo $ip|tr ':' ' '`" + for S in $SEGIP + do + while : + do + if [ "`echo $S|cut -b 4`" == "" ] + then + S="0$S" + continue + fi + if [ "$PADIP" == "" ] + then + PADIP="$S" + else + PADIP="$PADIP:$S" + fi + break + done + done + if [ "$PADIP" != "" ] + then + ip="$PADIP" + fi + echo "$ip" + return +} + +_ak_log_debug "_ak_network_utils loaded $(caller)" diff --git a/lib/_ak_network_yggdrasil b/lib/_ak_network_yggdrasil index 4d365ff..afabe70 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 @@ -114,3 +115,5 @@ function _ak_network_yggdrasil_scan(){ _ak_network_yggdrasil_scan_full fi } + +_ak_log_debug "_ak_network_yggdrasil loaded $(caller)" diff --git a/lib/_ak_node b/lib/_ak_node index 37d8a00..5ca8521 100755 --- a/lib/_ak_node +++ b/lib/_ak_node @@ -17,7 +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_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 @@ -30,3 +32,5 @@ function _ak_node_info_ipfs_hash(){ function _ak_node_info_ipns_key(){ _ak_ipfs_key_list_full | grep 'ak-config' | awk '{print $1}' } + +_ak_log_debug "_ak_node loaded $(caller)" diff --git a/lib/_ak_ns b/lib/_ak_ns new file mode 100755 index 0000000..683f572 --- /dev/null +++ b/lib/_ak_ns @@ -0,0 +1,202 @@ +#!/usr/bin/env bash +### +### arching-kaos-tools +### Tools to interact and build an Arching Kaos Infochain +### Copyright (C) 2021 - 2025 kaotisk +## |