From fa5d6becb482da75e65683b0ae690d35fa3eade6 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Tue, 27 Feb 2024 07:20:27 +0200 Subject: Refactor Arching Kaos ID to node_info --- README | 2 +- api/routes/default/index.js | 2 +- api/routes/index.js | 4 ++-- bin/ak-akid-get-ipfs-hash | 5 ----- bin/ak-akid-get-ipns-key | 5 ----- bin/ak-cjdns-scanner | 8 ++++---- bin/ak-cli | 8 ++++---- bin/ak-config | 2 +- bin/ak-node-info | 34 ++++++++++++++++++++++++++++++++++ 9 files changed, 47 insertions(+), 23 deletions(-) delete mode 100755 bin/ak-akid-get-ipfs-hash delete mode 100755 bin/ak-akid-get-ipns-key create mode 100755 bin/ak-node-info diff --git a/README b/README index 637a62e..6d6173b 100644 --- a/README +++ b/README @@ -214,7 +214,7 @@ ak-config # Publish your configuration to IPNS ak-data-expand # Expands and verifies DATA blocks ak-enter # Crawls ZCHAINS ak-extract-cids # Prints the CIDs from your ZCHAIN for further usage -ak-get-akid # Returns IPFS CID of your AKID (ak-config) +ak-node-info # Returns IPFS CID or IPNS key for your online config ak-get-chain-minified # Obsolete, ak-enter default output ak-get-gpg # Return your GPG key as IPFS CID ak-get-zlatest # Returns zlatest ZBLOCK according to IPFS FS diff --git a/api/routes/default/index.js b/api/routes/default/index.js index e5db7f5..f3eb50e 100644 --- a/api/routes/default/index.js +++ b/api/routes/default/index.js @@ -9,7 +9,7 @@ module.exports = (req, res) => { {gathered_zchain_zlatest_pairs:settings.DEF_PROTO+"["+settings.LOCAL_IP+"]:"+settings.PORT+settings.URL_PREFIX+"/seens"}, {node_local_chain:settings.DEF_PROTO+"["+settings.LOCAL_IP+"]:"+settings.PORT+settings.URL_PREFIX+"/chain"}, {node_local_peers:settings.DEF_PROTO+"["+settings.LOCAL_IP+"]:"+settings.PORT+settings.URL_PREFIX+"/peers"}, - {node_local_akid:settings.DEF_PROTO+"["+settings.LOCAL_IP+"]:"+settings.PORT+settings.URL_PREFIX+"/akid"}, + {node_local_info:settings.DEF_PROTO+"["+settings.LOCAL_IP+"]:"+settings.PORT+settings.URL_PREFIX+"/node_info"}, {node_local_zlatest:settings.DEF_PROTO+"["+settings.LOCAL_IP+"]:"+settings.PORT+settings.URL_PREFIX+"/zlatest"}, {latest_known_mined_block:settings.DEF_PROTO+"["+settings.LOCAL_IP+"]:"+settings.PORT+settings.URL_PREFIX+"/slatest"}, {show_mined_block:settings.DEF_PROTO+"["+settings.LOCAL_IP+"]:"+settings.PORT+settings.URL_PREFIX+"/sblock"}, diff --git a/api/routes/index.js b/api/routes/index.js index 3755524..174ed66 100644 --- a/api/routes/index.js +++ b/api/routes/index.js @@ -40,8 +40,8 @@ router.route(settings.URL_PREFIX+'/sblock/:sblock').get(getSBlock); router.route(settings.URL_PREFIX+'/zchain').get(getZChain); // Returns latest zblock from node's local chain router.route(settings.URL_PREFIX+'/zlatest').get(getZLatest); -// Returns local node's akid -router.route(settings.URL_PREFIX+'/akid').get(getAkid); +// Returns local node's info +router.route(settings.URL_PREFIX+'/node_info').get(getAkid); // Returns local node's peers router.route(settings.URL_PREFIX+'/peers').get(getPeers); // Returns content diff --git a/bin/ak-akid-get-ipfs-hash b/bin/ak-akid-get-ipfs-hash deleted file mode 100755 index 996a34f..0000000 --- a/bin/ak-akid-get-ipfs-hash +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# Resolves the IPNS key "ak-config" to its current IPFS value -# Return IPFS CIDv0 without /ipfs/ prefix -ak-ipfs-name-resolve /ipns/$(ak-akid-get-ipns-key) | sed -e 's/\/ipfs\///' - diff --git a/bin/ak-akid-get-ipns-key b/bin/ak-akid-get-ipns-key deleted file mode 100755 index 6db3705..0000000 --- a/bin/ak-akid-get-ipns-key +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# Resolves the IPNS key "ak-config" to its current IPFS value -# Return IPFS CIDv0 without /ipfs/ prefix -ak-ipfs-key-list-full | grep ak-config | awk '{print $1}' - diff --git a/bin/ak-cjdns-scanner b/bin/ak-cjdns-scanner index aee1fd2..81c3814 100755 --- a/bin/ak-cjdns-scanner +++ b/bin/ak-cjdns-scanner @@ -13,18 +13,18 @@ dumpLinks \ | uniq \ | while read -r ip || [ -n "$ip" ] do - akid="`curl \ + node_info="`curl \ -A 'akd/0.1.0; https://github.com/arching-kaos' \ --connect-timeout 3 \ - "http://[$(publictoip6 $ip)]:8610/v0/akid" 2>/dev/null`" + "http://[$(publictoip6 $ip)]:8610/v0/node_info" 2>/dev/null`" if [ "$?" == "0" ] then if [ "$counter" -ne "0" ] then printf ',' >> walk.aknet fi - printf '{"cjdnsPublicKey":"%s","cjdnsIp":"%s","akid":%s}' \ - "$ip" "`publictoip6 $ip`" "$akid" >> walk.aknet + printf '{"cjdns":{"public_key":"%s","ip":"%s"},"node_info":%s}' \ + "$ip" "`publictoip6 $ip`" "$node_info" >> walk.aknet counter="`expr $counter + 1`" fi done diff --git a/bin/ak-cli b/bin/ak-cli index cf90f15..6923823 100755 --- a/bin/ak-cli +++ b/bin/ak-cli @@ -109,11 +109,11 @@ _config(){ publish) ak-config publish ;; - get-akid) - ak-akid-get-ipfs-hash + node-info-ipfs) + ak-node-info ipfs ;; - get-akid-ipns) - ak-akid-get-ipns-key + node-info-ipns) + ak-node-info ipns ;; *) help_config diff --git a/bin/ak-config b/bin/ak-config index aee2f7d..c20e8d7 100755 --- a/bin/ak-config +++ b/bin/ak-config @@ -51,7 +51,7 @@ _ak_config_publish(){ } _ak_config_published(){ - ak-ipfs-cat $(ak-akid-get-ipfs-hash) | jq -c + ak-ipfs-cat $(ak-node-info ipfs) | jq -c } if [ ! -z $1 ]; then diff --git a/bin/ak-node-info b/bin/ak-node-info new file mode 100755 index 0000000..73217a0 --- /dev/null +++ b/bin/ak-node-info @@ -0,0 +1,34 @@ +#!/bin/bash +PROGRAM="$(basename $0)" +# Resolves the IPNS key "ak-config" to its current IPFS value +# Return IPFS CIDv0 without /ipfs/ prefix +_ak_node_info_ipfs_hash(){ + ak-ipfs-name-resolve /ipns/$(_ak_node_info_ipns_key) | sed -e 's/\/ipfs\///' +} + +# Finds ak-config ipns key +# Returns IPNS key +_ak_node_info_ipns_key(){ + ak-ipfs-key-list-full | grep ak-config | awk '{print $1}' +} + +_ak_node_info_usage(){ + echo "$PROGRAM ipfs | ipns" +} + +if [ ! -z "$1" ] +then + case "$1" in + ipfs) + _ak_node_info_ipfs_hash + ;; + ipns) + _ak_node_info_ipns_key + ;; + *) + _ak_node_info_usage + ;; + esac +else + _ak_node_info_usage +fi -- cgit v1.2.3