aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/config.js1
-rwxr-xr-xapi/index.js2
-rw-r--r--api/lib/storeIncomingIP/index.js6
-rw-r--r--api/routes/default/index.js13
-rwxr-xr-xlib/_ak_network_yggdrasil2
-rwxr-xr-xlib/_ak_utils4
6 files changed, 26 insertions, 2 deletions
diff --git a/api/config.js b/api/config.js
index fc944e1..3fe7c0d 100644
--- a/api/config.js
+++ b/api/config.js
@@ -18,6 +18,7 @@ const config = {
blocksFile : env.AK_ZBLOCKSFILE,
pairsFile : env.AK_ZPAIRSFILE,
peersFile : env.AK_ZPEERSFILE,
+ peersDir : env.AK_ZPEERSDIR,
cacheDir : env.AK_CACHEDIR,
ipfsArtifactsDir: `${env.AK_WORKDIR}/ipfs_artifacts`,
minedBlocksDir: env.AK_MINEDBLOCKSDIR,
diff --git a/api/index.js b/api/index.js
index 3394a0d..f5cf8c8 100755
--- a/api/index.js
+++ b/api/index.js
@@ -15,12 +15,14 @@ const getRemotePeers = require('./routes/getRemotePeers/index.js');
const akLogMessage = require('./lib/akLogMessage');
const checkIfAllowedIP = require('./lib/checkIfAllowedIP/index.js');
+const storeIncomingIP = require("./lib/storeIncomingIP/index.js");
akLogMessage('INFO', 'akLogMessage loaded');
const serverOptions = { keepAliveTimeout: 60000 };
function printRequest(req)
{
+ storeIncomingIP(req.connection.remoteAddress);
console.log(req.connection.remoteAddress);
console.log(req.headers.host);
console.log(req.headers);
diff --git a/api/lib/storeIncomingIP/index.js b/api/lib/storeIncomingIP/index.js
new file mode 100644
index 0000000..c45def6
--- /dev/null
+++ b/api/lib/storeIncomingIP/index.js
@@ -0,0 +1,6 @@
+const fs = require("node:fs");
+const config = require("../../config");
+
+module.exports = (ip_address) => {
+ fs.appendFileSync(`${config.peersDir}/incomingRequests`, `${ip_address}\n`);
+}
diff --git a/api/routes/default/index.js b/api/routes/default/index.js
index c9f6bd3..24e334b 100644
--- a/api/routes/default/index.js
+++ b/api/routes/default/index.js
@@ -10,6 +10,17 @@ module.exports = (req, res) => {
routes:{
GET:[
{welcome:settings.DEF_PROTO+req.headers.host+"/"},
+ {peers:settings.DEF_PROTO+req.headers.host+settings.URL_PREFIX+"/peers"},
+ {node_info:settings.DEF_PROTO+req.headers.host+settings.URL_PREFIX+"/node_info"},
+ {ipfs_hash:settings.DEF_PROTO+req.headers.host+settings.URL_PREFIX+"/ipfs_hash/<hash>"},
+ {zlatest:settings.DEF_PROTO+req.headers.host+settings.URL_PREFIX+"/zlatest"},
+ {sblock:settings.DEF_PROTO+req.headers.host+settings.URL_PREFIX+"/sblock/<hash>"},
+ {slatest:settings.DEF_PROTO+req.headers.host+settings.URL_PREFIX+"/slatest"},
+ {chunk:settings.DEF_PROTO+req.headers.host+settings.URL_PREFIX+"/chunk/<hash>"},
+ {leaf:settings.DEF_PROTO+req.headers.host+settings.URL_PREFIX+"/leaf/<hash>"},
+ {map:settings.DEF_PROTO+req.headers.host+settings.URL_PREFIX+"/map/<hash>"},
+ ],
+ oldGET:[
{gathered_zblocks:settings.DEF_PROTO+req.headers.host+settings.URL_PREFIX+"/see"},
{node_local_chain:settings.DEF_PROTO+req.headers.host+settings.URL_PREFIX+"/chain"},
{node_local_peers:settings.DEF_PROTO+req.headers.host+settings.URL_PREFIX+"/peers"},
@@ -19,7 +30,7 @@ module.exports = (req, res) => {
{show_mined_block:settings.DEF_PROTO+req.headers.host+settings.URL_PREFIX+"/sblock"},
{getMerkleTree:settings.DEF_PROTO+req.headers.host+settings.URL_PREFIX+"/mrk/:mkr"},
],
- POST:[
+ oldPOST:[
{send_me_a_zblock:settings.DEF_PROTO+req.headers.host+settings.URL_PREFIX+"/announce/zblock"},
]
}
diff --git a/lib/_ak_network_yggdrasil b/lib/_ak_network_yggdrasil
index 27fc0c8..4d365ff 100755
--- a/lib/_ak_network_yggdrasil
+++ b/lib/_ak_network_yggdrasil
@@ -36,7 +36,7 @@ function _ak_network_yggdrasil_scan_full(){
filtered_online_pubkeys_ips="$TEMPDIR/fopi"
curl -s \
--connect-timeout 5 \
- "http://yia.yggdrasil-network.ca/crawler/crawler-yia.peers.$(date -u +%Y%m%d)" > $last_seen
+ "http://yia.yggdrasil-network.ca/crawler/crawler-yia.peers.$(_ak_datetime_human_date_only_yesterday)" > $last_seen
if [ $? -ne 0 ]
then
_ak_log_error "Couldn't fetch active peers from YIA"
diff --git a/lib/_ak_utils b/lib/_ak_utils
index d9204e9..98f6ca0 100755
--- a/lib/_ak_utils
+++ b/lib/_ak_utils
@@ -33,6 +33,10 @@ function _ak_datetime_human_date_only(){
date -u +%Y%m%d
}
+function _ak_datetime_human_date_only_yesterday(){
+ date --date=yesterday -u +%Y%m%d 2>/dev/null || date -v -1d -u +%Y%m%d 2>/dev/null
+}
+
function _ak_datetime_unix_to_human(){
if [ ! -z $1 ] && [ -n "$1" ] && [ "$(echo $1 | sed -e 's/[0-9]\{10\}//g')" == "" ]
then