See who is pinging my site?

Is there an way to see who or what ip dress is pinging my website


I’m not sure if Glitch emits the X-Forwarded-For header? You can try to check that though.

Ok I will try registering for cloudfare

then it shows in firewall events

1 Like

Glitch also emits the IP address:

const express = require("express");
const app = express();

app.use(async (req, res, next) => {
  req._ip = req.headers['x-forwarded-for'] || req.headers["x-real-api"] || req.connection.remoteAddress;
  if (req._ip.includes(",")) req._ip = req._ip.split(",")[0];

app.use(async (req, res, next) => {
  res.end("Your IP address is: " + req._ip);

app.listen(3000, () => console.log(":3000"));
1 Like

Yes but using a dash like cloudflare is nicer with more functionality like ip and user agent blocking

IIRC Cloudflare doesn’t trust the XFF or XRA headers, so if i.e. you decide to set a rule against my Glix service, my service won’t be able to go through that cloudflare service.

Interesting, I guess this would be possible to test

I have a doubt.
You have used async, but isn’t express by default asynchronous (like node)?
If I’ll not use it, then will my server become synchronous, like python?

app.use((req, res, next) => {
  // this is still async, but if you want
  // to use async-await, u need add 'async' before (req, res, next)

but correct me if i wrong

1 Like

What @EriecTan is partly true, express is by default synchronous. That also means there are no race conditions, if your entire express application only uses synchronous functions then a similar effect like FIFO (first in, first out) will happen. However when you make a function asynchronous it will yield once it needs something from the system that requires signals, which means that the program will continue the code elsewhere until the event-loop receives the data needed to continue.

Note: All official Node.js API Sync methods block the event-loop from continuing also when using async.

1 Like

Thanks for this information @ihack2712 . I think I shoukd use async-await to make my request handlers async. Is it?

It doesn’t really make the performance a lot faster, but in my experience it is best practice to learn async-await, yes.

for node.js, its really a waste if not use async. the ‘fast’ effect will come at many request which is node that can handle request asyncly will result of faster result because there is no blocking event.

Where async makes a big difference is functions that take a long time, like reading/writing the filesystem, encryption functions, or waiting for a response from another site.

1 Like