diff --git a/xtrn/wttr.in/locator.js b/xtrn/wttr.in/locator.js index 1de3c6088c46086a3400b89df5b05c5143bcf583..6dccc119154087417b178b6de678960183f5b512 100644 --- a/xtrn/wttr.in/locator.js +++ b/xtrn/wttr.in/locator.js @@ -1,13 +1,15 @@ -/* - * Just IP address lookup for now - * wttr.in does the geoip for us (albeit inaccurately) - * To do: do something with user.location / zipcode as an alternative? - */ +// To do: use user.location / zipcode if available? function getAddress() { const addrRe = /(^0\.0\.0\.0$)|(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^169\.254\.)|(^::1$)|(^[fF][cCdD])/; - if (client.ip_address.search(addrRe) < 0) return client.ip_address; + if (client.ip_address.search(addrRe) < 0) return client.ip_address; // Not a private/local address + /* + * User has a private address and may be coming from websocketservice.js. + * Check if their IP address was written to a temp file for us. + * + * There's a very slim chance of false positives here, but whatever. + */ const f = new File(system.temp_path + 'sbbs-ws-' + client.socket.remote_port + '.ip'); if (!f.exists) return; if (!f.open('r')) return;