aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README55
-rw-r--r--api/config.js3
-rwxr-xr-xapi/index.js5
-rw-r--r--api/lib/akLogMessage/index.js4
-rw-r--r--api/lib/checkIfAllowedIP/index.js5
-rw-r--r--api/lib/storeIncomingIP/index.js4
-rw-r--r--api/routes/announceZBlock/index.js4
-rw-r--r--api/routes/announceZChain/index.js4
-rw-r--r--api/routes/default/index.js5
-rw-r--r--api/routes/getAKNSKey/index.js75
-rw-r--r--api/routes/getAKNSKeyFromBase/index.js91
-rw-r--r--api/routes/getChunk/index.js5
-rw-r--r--api/routes/getIPFSHash/index.js23
-rw-r--r--api/routes/getInnerIPFSContent/index.js4
-rw-r--r--api/routes/getLeaf/index.js4
-rw-r--r--api/routes/getMap/index.js5
-rw-r--r--api/routes/getNodeInfo/index.js4
-rw-r--r--api/routes/getPeers/index.js4
-rw-r--r--api/routes/getRemoteNodeInfo/index.js8
-rw-r--r--api/routes/getRemotePeers/index.js7
-rw-r--r--api/routes/getSBlock/index.js8
-rw-r--r--api/routes/getZChain/index.js5
-rw-r--r--api/routes/showEntriesFile/index.js6
-rw-r--r--api/routes/showNSEntriesFile/index.js6
-rw-r--r--api/validators/ZblockValidator/index.js4
-rw-r--r--api/validators/ZchainValidator/index.js5
-rwxr-xr-xbin/ak8
-rwxr-xr-xbin/ak-cjdns5
-rwxr-xr-xbin/ak-clean4
-rwxr-xr-xbin/ak-coin4
-rwxr-xr-xbin/ak-config4
-rwxr-xr-xbin/ak-fs4
-rwxr-xr-xbin/ak-get-balances5
-rwxr-xr-xbin/ak-gpg9
-rwxr-xr-xbin/ak-ipfs5
-rwxr-xr-xbin/ak-irc5
-rwxr-xr-xbin/ak-log5
-rwxr-xr-xbin/ak-maintainance5
-rwxr-xr-xbin/ak-mine7
-rwxr-xr-xbin/ak-network5
-rwxr-xr-xbin/ak-node-info4
-rwxr-xr-xbin/ak-ns73
-rwxr-xr-xbin/ak-pkg5
-rwxr-xr-xbin/ak-profile7
-rwxr-xr-xbin/ak-sblock5
-rwxr-xr-xbin/ak-schain5
-rwxr-xr-xbin/ak-settings5
-rwxr-xr-xbin/ak-sh4
-rwxr-xr-xbin/ak-startup5
-rwxr-xr-xbin/ak-template5
-rwxr-xr-xbin/ak-transactions2
-rwxr-xr-xbin/ak-wallet5
-rwxr-xr-xbin/ak-yggdrasil5
-rwxr-xr-xbin/ak-zblock5
-rwxr-xr-xbin/ak-zchain5
-rw-r--r--c_implementation/Makefile.am65
-rwxr-xr-xc_implementation/build_tree/ak_fs_build.sh17
-rw-r--r--c_implementation/include/libakdatetime.h14
-rw-r--r--c_implementation/include/libakfs.h347
-rw-r--r--c_implementation/include/libaklog.h23
-rw-r--r--c_implementation/include/libaksettings.h7
-rw-r--r--c_implementation/src/ak_datetime.c70
-rw-r--r--c_implementation/src/ak_fs.c383
-rw-r--r--c_implementation/src/ak_fs_defuse.c98
-rw-r--r--c_implementation/src/ak_fs_main.c51
-rw-r--r--c_implementation/src/ak_fs_map_v3.c213
-rw-r--r--c_implementation/src/ak_fs_map_v4.c8
-rw-r--r--c_implementation/src/ak_fs_maps_v3.c98
-rw-r--r--c_implementation/src/ak_fs_mt.c52
-rw-r--r--c_implementation/src/ak_fs_sha512sum.c221
-rw-r--r--c_implementation/src/ak_log.c246
-rw-r--r--c_implementation/src/ak_log_main.c32
-rw-r--r--c_implementation/src/ak_logcatter.c (renamed from c_implementation/src/aklogcatter.c)1
-rw-r--r--c_implementation/src/ak_settings.c (renamed from c_implementation/src/aksettings.c)42
-rw-r--r--c_implementation/src/ak_utils.c (renamed from c_implementation/src/akutils.c)0
-rw-r--r--c_implementation/src/akfs.c349
-rw-r--r--c_implementation/src/aklog.c287
-rw-r--r--c_implementation/tests/test_akfs.c210
-rw-r--r--c_implementation/tests/test_akfs_mkdir.c20
-rw-r--r--c_implementation/tests/test_aklog.c36
-rw-r--r--c_implementation/tests/test_aklogwrite.c2
-rw-r--r--c_implementation/tests/test_aksettings.c75
-rw-r--r--c_implementation/tests/test_aksettings_read.c2
-rw-r--r--c_implementation/tests/test_sha512_string.c8
-rwxr-xr-xlib/_ak_config7
-rwxr-xr-xlib/_ak_fs8
-rwxr-xr-xlib/_ak_gpg25
-rwxr-xr-xlib/_ak_ipfs16
-rwxr-xr-xlib/_ak_log19
-rwxr-xr-xlib/_ak_network_incoming92
-rwxr-xr-xlib/_ak_network_yggdrasil14
-rwxr-xr-xlib/_ak_node2
-rwxr-xr-xlib/_ak_ns364
-rwxr-xr-xlib/_ak_script22
94 files changed, 3182 insertions, 932 deletions
diff --git a/README b/README
index 7323655..0129622 100644
--- a/README
+++ b/README
@@ -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"});
+ }