aboutsummaryrefslogtreecommitdiff
path: root/api/routes/getRemotePeers/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'api/routes/getRemotePeers/index.js')
-rw-r--r--api/routes/getRemotePeers/index.js11
1 files changed, 5 insertions, 6 deletions
diff --git a/api/routes/getRemotePeers/index.js b/api/routes/getRemotePeers/index.js
index 78dbba4..dac0f04 100644
--- a/api/routes/getRemotePeers/index.js
+++ b/api/routes/getRemotePeers/index.js
@@ -6,31 +6,29 @@
const { spawn } = require('child_process');
const config = require("../../config.js");
+const checkIfAllowedIP = require('../../lib/checkIfAllowedIP/index.js');
-module.exports = (req, res) => {
+function getRemotePeers(req, res)
+{
var args = req.url.split("/");
var ip = "";
if ( args.length === 4 )
{
ip = args[3];
}
- var test = /^fc[0-9a-z]{1,2}:([0-9a-z]{1,4}:){1,6}[0-9a-z]{1,4}/
- if (test.test(ip))
+ if (checkIfAllowedIP(ip))
{
const command = spawn("curl", ["--retry-max-time","3","-s",`http://[${ip}]:8610/v0/peers`]);
var buffer = "";
command.stdout.on("data", data => {
buffer = buffer + data;
});
-
command.stderr.on("data", data => {
console.log(`stderr: ${data}`);
});
-
command.on('error', (error) => {
console.log(`error: ${error.message}`);
});
-
command.on("close", code => {
if ( code === 0 )
{
@@ -52,3 +50,4 @@ module.exports = (req, res) => {
}
}
+module.exports = getRemotePeers;