jgkaplan / gemini-server

Node server for the gemini protocol, based on express
ISC License
65 stars 9 forks source link

Get request IP address #24

Closed pedrogpimenta closed 2 years ago

pedrogpimenta commented 2 years ago

(I'm sorry if this is not the place)

I'm curious to see if anyone visits and what they do on my capsule :)

I didn't find any built-in logging, so I'm doing my own on each request. I'm fine with not having it but would like to know if there's any way to get the IP address of each request, so I can see if someone else visits, not just me reviewing changes!

I have logged the req object but nothing like that appears to exist.

Is there any way to do this?

Thanks!

jgkaplan commented 2 years ago

Client IP isn't included in the request object. If you need it, it's probably possible to modify the creation of the request object to include it. However, if you're just trying to know if someone else visits, I'd recommend looking at the certificate or fingerprint, which are included in the request object.

pedrogpimenta commented 2 years ago

@jgkaplan OK I can filter myself out of the logs by using a certificate, that'll do it for me, thanks!

And only for learning purposes, when you say

modify the creation of the request object to include [IP adress]

you mean on the server code base, not something I can do on my end, right?

jgkaplan commented 2 years ago

I did mean on the server code base (which you could technically fork and modify), although on further thought, the listen method returns a tls.Server. It might be possible to hook into it somehow from your end.

pedrogpimenta commented 2 years ago

@jgkaplan Oh that's great! Yeah, just wanted to know, thanks! I'll close this now.