From 0aa7ab54e734f9317e204c15890ee1b4794d8132 Mon Sep 17 00:00:00 2001 From: sairaj mote Date: Tue, 16 Jan 2024 04:35:37 +0530 Subject: [PATCH] testing bug fix --- routes/is-tor.js | 17 +++++++++++------ routes/is-tor.min.js | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/routes/is-tor.js b/routes/is-tor.js index 2f17d58..4c7c829 100644 --- a/routes/is-tor.js +++ b/routes/is-tor.js @@ -1,16 +1,21 @@ const express = require('express'); const router = express.Router(); const axios = require('axios'); - router.get('/', async (req, res) => { try { - const ip = req.socket.remoteAddress; - const response = await axios.get(`https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=${ip}`); - const isTor = response.data.includes(ip); - res.json({ isTor, ip }); + console.log(req.ip, req.socket.remoteAddress, req.connection.remoteAddress, req.headers['x-forwarded-for']) + const ip = req.ip; + const response = await axios.get(`https://check.torproject.org/api/ip?ip=${ip}`); + res.json({ + ...response.data, + reqIp: ip, + reqSocketRemoteAddress: req.socket.remoteAddress, + reqConnectionRemoteAddress: req.connection.remoteAddress, + reqHeadersXForwardedFor: req.headers['x-forwarded-for'] + }); } catch (error) { res.status(500).json({ error: error.message }); } }); -module.exports = router; +module.exports = router; \ No newline at end of file diff --git a/routes/is-tor.min.js b/routes/is-tor.min.js index e83cfa6..53e7a03 100644 --- a/routes/is-tor.min.js +++ b/routes/is-tor.min.js @@ -1 +1 @@ -const express=require("express"),router=express.Router(),axios=require("axios");router.get("/",(async(req,res)=>{try{const ip=req.socket.remoteAddress,isTor=(await axios.get(`https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=${ip}`)).data.includes(ip);res.json({isTor:isTor,ip:ip})}catch(error){res.status(500).json({error:error.message})}})),module.exports=router; \ No newline at end of file +const express=require("express"),router=express.Router(),axios=require("axios");router.get("/",(async(req,res)=>{try{console.log(req.ip,req.socket.remoteAddress,req.connection.remoteAddress,req.headers["x-forwarded-for"]);const ip=req.ip,response=await axios.get(`https://check.torproject.org/api/ip?ip=${ip}`);res.json({...response.data,reqIp:ip,reqSocketRemoteAddress:req.socket.remoteAddress,reqConnectionRemoteAddress:req.connection.remoteAddress,reqHeadersXForwardedFor:req.headers["x-forwarded-for"]})}catch(error){res.status(500).json({error:error.message})}})),module.exports=router; \ No newline at end of file