diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/config.js | 1 | ||||
-rwxr-xr-x | api/index.js | 2 | ||||
-rw-r--r-- | api/lib/storeIncomingIP/index.js | 6 | ||||
-rw-r--r-- | api/routes/default/index.js | 13 |
4 files changed, 21 insertions, 1 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"}, ] } |