diff options
| author | kaotisk <kaotisk@arching-kaos.org> | 2025-03-20 04:53:00 +0200 | 
|---|---|---|
| committer | kaotisk <kaotisk@arching-kaos.org> | 2025-03-20 04:53:00 +0200 | 
| commit | 823e381ca557b3c7f034aa44ac9193bb79cbe97c (patch) | |
| tree | 1b1e0d1457122cc1d739cd0048e2248ea4403d29 | |
| parent | 230abb69a127d4af1f38c853897c6deaa611cd92 (diff) | |
| download | arching-kaos-tools-823e381ca557b3c7f034aa44ac9193bb79cbe97c.tar.gz arching-kaos-tools-823e381ca557b3c7f034aa44ac9193bb79cbe97c.tar.bz2 arching-kaos-tools-823e381ca557b3c7f034aa44ac9193bb79cbe97c.zip  | |
[api] store incoming requests' IPs for future use
| -rwxr-xr-x | api/index.js | 2 | ||||
| -rw-r--r-- | api/lib/storeIncomingIP/index.js | 6 | 
2 files changed, 8 insertions, 0 deletions
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`); +}  | 
