ISP detection does not work for LAN clients behind NAT

Aperta
#862 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
php
Ambito
api, backend

Direzione di ricerca

Start with backend/getIP.php, especially getLocalOrPrivateIpInfo($ip) and the existing IPinfo request used by /backend/getIP.php?isp=true. Trace how configuration is defined and how the response is formatted before deciding where the opt-in setting belongs. Done means private client IPs remain unchanged while enabled deployments can use the server's public IP for ISP/location data, without changing the default behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hi Team, I'm running LibreSpeed on a server inside my home network. When I access the speedtest from another device on the same LAN, LibreSpeed correctly detects the client's private IP address, but ISP detection is skipped.

For example, the client is:

192.168.1.23

and the LibreSpeed server is:

192.168.1.10

Calling:

/backend/getIP.php?isp=true

returns:

{
  "processedString": "192.168.1.23 - private IPv4 access",
  "rawIspInfo": ""
}
Why this happens

backend/getIP.php checks for private addresses before trying IPinfo:

$localIpInfo = getLocalOrPrivateIpInfo($ip);

if (is_string($localIpInfo)) {
    echo formatResponse_simple($ip,$localIpInfo);
}

So an address such as 192.168.1.23 is never sent to IPinfo.

That makes sense by itself, since a private IP cannot be geolocated. However, for a typical home network the LibreSpeed server and the client are behind the same NAT gateway and therefore share the same public IP.

The server can already determine its public IP using the existing IPinfo integration:

https://ipinfo.io/json?token=...

So it seems possible to use the server's public IP for ISP/location lookup when the client IP is private.

Possible solution

Would it make sense to add an optional setting for this use case?

For example:

USE_SERVER_PUBLIC_IP_FOR_PRIVATE_CLIENTS=true

When enabled:

  1. Detect the client IP as usual.
  2. If it is a private/local address, don't send that address to IPinfo.
  3. Instead query IPinfo without an IP address so that IPinfo sees the server's public address.
  4. Use the returned ISP/country/location information for the result.
  5. Keep the actual client IP unchanged.

For example, instead of:

192.168.1.23 - private IPv4 access

the result could show something like:

192.168.1.23 - Example ISP, DE
Why should this be optional?

The server and client do not necessarily have to use the same public IP. This could be wrong when LibreSpeed is behind a VPN, proxy, multiple network interfaces, etc.

Therefore I think this should be opt-in rather than changing the current behavior for every private IP.

Environment
  • LibreSpeed Docker image: ghcr.io/librespeed/speedtest:latest
  • Client and server are on the same private LAN
  • Server has Internet access through a NAT router
  • IPinfo API key is configured and working
  • /backend/getIP.php?isp=true works correctly for public IPs
Expected behavior

It would be useful if LibreSpeed could optionally provide ISP/location information for LAN clients behind NAT, while still correctly identifying the actual client IP as private.

Is this something that would be considered?

Lingua principale
JavaScript
Stelle
15.3k
Fork
2.5k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di librespeed/speedtest

Tutte le issue di librespeed/speedtest

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.