diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2024-02-27 07:20:27 +0200 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2024-02-27 07:20:27 +0200 |
commit | fa5d6becb482da75e65683b0ae690d35fa3eade6 (patch) | |
tree | 131bae638ebcdde7179620a0b0b5153aa36b927a /bin | |
parent | 1da7813fe8dab6deb3bcbcfe79f4ad44c5f7fe0c (diff) | |
download | arching-kaos-tools-fa5d6becb482da75e65683b0ae690d35fa3eade6.tar.gz arching-kaos-tools-fa5d6becb482da75e65683b0ae690d35fa3eade6.tar.bz2 arching-kaos-tools-fa5d6becb482da75e65683b0ae690d35fa3eade6.zip |
Refactor Arching Kaos ID to node_info
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/ak-akid-get-ipfs-hash | 5 | ||||
-rwxr-xr-x | bin/ak-akid-get-ipns-key | 5 | ||||
-rwxr-xr-x | bin/ak-cjdns-scanner | 8 | ||||
-rwxr-xr-x | bin/ak-cli | 8 | ||||
-rwxr-xr-x | bin/ak-config | 2 | ||||
-rwxr-xr-x | bin/ak-node-info | 34 |
6 files changed, 43 insertions, 19 deletions
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 @@ -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 |