diff options
94 files changed, 3182 insertions, 932 deletions
@@ -74,6 +74,7 @@ programs used are: - curl (v7.79.1) - git (v2.34.1) - which (v2.21) +- rlwrap (v0.46.2) - jq (v1.6) - nodejs (v16+) - npm (v9.5.0) @@ -104,6 +105,9 @@ git pull Uninstall --------- +> WARNING: It will REMOVE the whole $HOME/.arching-kaos directory but your GPG +> keyring. Proceed with caution! Back up if you want to. + Navigate to your cloned repository and execute the following command: ``` @@ -111,8 +115,6 @@ Navigate to your cloned repository and execute the following command: ``` This will output an archive with your aknet-gpg-keyring to your $HOME folder. -It will NOT remove your IPFS repository, neither is going to clean it. - Podman (or Docker) ------------------ There is a ContainerFile that you can use to build an image which you can then @@ -170,6 +172,8 @@ Utilities - ak-network # Network Tools (connect to, scan for, dump peers) - ak-node-info # Returns IPFS CID or IPNS key for your online config - ak-pkg # Package manager + - ak-fs # File system + - ak-ns # Name system - ak-sblock # sblock tools - ak-schain # schain tools - ak-zblock # zblock tools @@ -234,6 +238,7 @@ Libraries - lib/_ak_settings - lib/_ak_gpg - lib/_ak_fs + - lib/_ak_ns - lib/_ak_pkg - lib/_ak_zblock - lib/_ak_log @@ -393,3 +398,49 @@ $ ak pkg --help # --uninstall Uninstalls a module selected from a menu # ``` + +NS tools +-------- + - ak-ns + +```bash +$ ak ns --help +# ak-ns - Name system +# =================== +# +# AKNS is a name system for Arching Kaos +# +# Usage: +# +# -h, --help Prints this help message +# -c, --create <name> Creates a new key-pair with name +# -l, --list List names +# -ll, --list-long List names with keys +# -rn, --resolve-name <name> Resolves value from name +# -rk, --resolve-key <key> Resolves value from key +# -p, --publish <key> <value> Publishes value to key +# -pn, --publish2name <name> <value> Publishes value to name +# -pz, --publish-zchain Publishes zchain +# -pc, --publish-config Publishes config +# -ek, --encode-key <key> Encodes a key to Base64 +# -dk, --decode-key <base64 key> Decodes a key from Base64 +# +ns command finished +``` + +Donations +--------- +While this project is developed with enthusiasm and it uses the spare time of +the only developer that is coding for it, donations would help allocating more +time on the project instead of the developer looking for different occupations +to support their life and project. + +If you do appreciate the project's goals and the developers efforts towards it, +take your time and consider donating some satoshis to the developer via BTC at +the following address + +``` +bc1q70rgp65t7acfgpwp74m7vdz0g4eduxm6a43gd8 +``` + +Thank you! diff --git a/api/config.js b/api/config.js index 3fe7c0d..82f90b8 100644 --- a/api/config.js +++ b/api/config.js @@ -25,6 +25,7 @@ const config = { chunksDir: env.AK_CHUNKSDIR, leafsDir: env.AK_LEAFSDIR, mapsDir: env.AK_MAPSDIR, - printDebug: env.AK_DEBUG + printDebug: env.AK_DEBUG, + akNSDir: `${env.AK_WORKDIR}/akns` } module.exports = config; diff --git a/api/index.js b/api/index.js index f5cf8c8..f22d448 100755 --- a/api/index.js +++ b/api/index.js @@ -1,6 +1,8 @@ const http = require("node:http"); const welcomeMessage = require("./routes/default/index.js"); +const getAKNSKey = require("./routes/getAKNSKey/index.js"); +const getAKNSKeyFromBase = require("./routes/getAKNSKeyFromBase/index.js"); const getNodeInfo = require('./routes/getNodeInfo/index.js'); const getPeers = require('./routes/getPeers/index.js'); const getIPFSHash = require('./routes/getIPFSHash/index.js'); @@ -59,6 +61,7 @@ function getRoutes(req, res) case 'peers': getPeers(req, res); break; case 'node_info': getNodeInfo(req, res); break; case 'ipfs_hash': getIPFSHash(req, res); break; + case 'ipfs': getIPFSHash(req, res); break; case 'zlatest': getZlatest(req, res); break; case 'sblock': getSblock(req, res); break; case 'slatest': getSlatest(req, res); break; @@ -67,6 +70,8 @@ function getRoutes(req, res) case 'map': getMap(req, res); break; case 'remote_node_info': getRemoteNodeInfo(req, res); break; case 'remote_peers': getRemotePeers(req, res); break; + case 'ns_get': getAKNSKey(req, res); break; + case 'ns_get_base': getAKNSKeyFromBase(req, res); break; default: notImplemented(req, res); } } diff --git a/api/lib/akLogMessage/index.js b/api/lib/akLogMessage/index.js index 6dfb8f2..59a1300 100644 --- a/api/lib/akLogMessage/index.js +++ b/api/lib/akLogMessage/index.js @@ -1,7 +1,8 @@ const { spawn } = require('child_process'); const config = require('../../config') -module.exports = (type, message) => { +function akLogMessage(type, message) +{ const command = spawn( "ak-log", ["-m", "ak-daemon", type, message] @@ -26,3 +27,4 @@ module.exports = (type, message) => { console.log(`child process exited with code ${code}`); }); }; +module.exports = akLogMessage; diff --git a/api/lib/checkIfAllowedIP/index.js b/api/lib/checkIfAllowedIP/index.js index d9693d9..2e50418 100644 --- a/api/lib/checkIfAllowedIP/index.js +++ b/api/lib/checkIfAllowedIP/index.js @@ -1,8 +1,9 @@ - -module.exports = (address) => { +function checkIfAllowedIP(address) +{ var test_cjdns = /^fc[0-9a-z]{1,2}:([0-9a-z]{1,4}:){1,6}[0-9a-z]{1,4}/ var test_yggdrasil = /^2[0-9a-z]{1,2}:([0-9a-z]{1,4}:){1,6}[0-9a-z]{1,4}/ var test_yggdrasil_sub = /^3[0-9a-z]{1,2}:([0-9a-z]{1,4}:){1,6}[0-9a-z]{1,4}/ return (test_cjdns.test(address) || test_yggdrasil.test(address) || test_yggdrasil_sub.test(address)) ? true : false; }; +module.exports = checkIfAllowedIP; diff --git a/api/lib/storeIncomingIP/index.js b/api/lib/storeIncomingIP/index.js index c45def6..72273d0 100644 --- a/api/lib/storeIncomingIP/index.js +++ b/api/lib/storeIncomingIP/index.js @@ -1,6 +1,8 @@ const fs = require("node:fs"); const config = require("../../config"); -module.exports = (ip_address) => { +function storeIncomingIP(ip_address) +{ fs.appendFileSync(`${config.peersDir}/incomingRequests`, `${ip_address}\n`); } +module.exports = storeIncomingIP; diff --git a/api/routes/announceZBlock/index.js b/api/routes/announceZBlock/index.js index 254e1dc..dc1467a 100644 --- a/api/routes/announceZBlock/index.js +++ b/api/routes/announceZBlock/index.js @@ -13,7 +13,8 @@ * */ const getvalidity = require('../../validators/ZblockValidator') -module.exports = (req, res) => { +function announceZBlock(req, res) +{ console.log(req); if ( (req.body.zblock) && typeof req.body.zblock === "string" && req.body.zblock.length === 46 ){ let zblock = req.body.zblock; @@ -27,3 +28,4 @@ module.exports = (req, res) => { res.send({error:"Invalid data"}); } } +module.exports = announceZBlock; diff --git a/api/routes/announceZChain/index.js b/api/routes/announceZChain/index.js index 0261aa4..ca23a72 100644 --- a/api/routes/announceZChain/index.js +++ b/api/routes/announceZChain/index.js @@ -14,7 +14,8 @@ */ const getNSvalidity = require('../../validators/ZchainValidator'); -module.exports = (req, res) => { +function announceZChain(req, res) +{ console.log(req); if ( (req.body.zchain) && typeof req.body.zchain === "string" && req.body.zchain.length === 62 ){ let zchain = req.body.zchain; @@ -30,3 +31,4 @@ module.exports = (req, res) => { res.end(JSON.stringify({error:"Invalid data"})); } } +module.exports = announceZChain; diff --git a/api/routes/default/index.js b/api/routes/default/index.js index 24e334b..db1495f 100644 --- a/api/routes/default/index.js +++ b/api/routes/default/index.js @@ -1,7 +1,8 @@ const rsettings = require('../../settings'); const settings = rsettings(); -module.exports = (req, res) => { +function welcome(req, res) +{ res.writeHead(404, { 'Content-Type': 'application/json'}); res.end(JSON.stringify({ message:"Hello! Welcome to Arching Kaos API! See available routes below!", @@ -36,4 +37,4 @@ module.exports = (req, res) => { } })); } - +module.exports = welcome; diff --git a/api/routes/getAKNSKey/index.js b/api/routes/getAKNSKey/index.js new file mode 100644 index 0000000..5e78f81 --- /dev/null +++ b/api/routes/getAKNSKey/index.js @@ -0,0 +1,75 @@ +const { spawn } = require('child_process'); +const fs = require('fs'); +const config = require("../../config.js"); + +/* + * Gets the local latest zblock AKA zlatest + * + * Returns: + * - JSON object + * { zlatest: "Qm..." } + * + */ +function replyIfOkay(key, res) +{ + const program = "ak-ns"; + const command = spawn(program, ["-rj", key]); + var buffer = ""; + command.stdout.on("data", data => { + buffer += data; + }); + command.stderr.on("data", data => { + console.log(`stderr: ${data}`); + }); + command.on('error', (error) => { + console.log(`error: ${error.message}`); + }); + command.on("close", code => { + console.log(`child process ${program} exited with code ${code}`); + if (code === 0){ + buffer = buffer.trim() + res.writeHead(200, {'Content-Type': 'application/json'}); + res.end(`${buffer}`); + } else { + res.writeHead(404, {'Content-Type': 'application/json'}); + res.end({"error":"unreachable"}); + } |