diff --git a/index.js b/index.js index 313dd5d..ab05c60 100644 --- a/index.js +++ b/index.js @@ -13,12 +13,15 @@ const con = require('./src/console.js') const api = require('./src/api.js') app.use((req, res, next) => { - const public = { ... req.body } - if (public.password !== undefined) { - public.password = '********' + var ip = req.headers['x-real-ip'] || req.connection.remoteAddress; + if (req.path !== '/console') { + const public = { ... req.body } + if (public.password !== undefined) { + public.password = '********' + } + console.log(ip, req.method, req.path, public) + con.requests.push({ip: ip, method: req.method, path: req.path, body: public}) } - console.log(req.ip, req.method, req.path, public) - con.update(req.ip, req.method, req.path, public) next() }) diff --git a/public/js/api.js b/public/js/api.js index 371ecf3..c0ae980 100644 --- a/public/js/api.js +++ b/public/js/api.js @@ -1,4 +1,4 @@ -const endpoint = 'https://xssbook.com/api' +const endpoint = 'http://localhost:8080/api' const request = async (url, body, method) => { if (method === undefined) method = 'POST' diff --git a/src/console.js b/src/console.js index c7f4089..cbc8f51 100644 --- a/src/console.js +++ b/src/console.js @@ -1,30 +1,16 @@ const express = require('express') const router = express.Router() -const sleep = ms => new Promise(r => setTimeout(r, ms)); -const connections = [] +var requests = [] router.get('/', async (req, res) => { - res.write(` - - -
- - -